b88a98c3911484396b0908a21ac497bc169faa58
[senf.git] / PPI / Module.ct
1 // Copyright (C) 2007 
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
21 /** \file
22     \brief Module non-inline template implementation  */
23
24 #include "Module.ih"
25
26 // Custom includes
27
28 #define prefix_
29 ///////////////////////////////ct.p////////////////////////////////////////
30
31 ///////////////////////////////////////////////////////////////////////////
32 // senf::ppi::module::Module
33
34 template <class Source, class Target>
35 prefix_ senf::ppi::Route<Source, Target> &
36 senf::ppi::module::Module::route(Source & source, Target & target)
37 {
38     detail::RouteHelper<Source,Target>::route(*this, source, target, source, target);
39     return static_cast< Route<Source,Target> & >(
40         addRoute(std::auto_ptr< RouteBase >(
41                      new Route<Source,Target>(*this, source, target))));
42 }
43
44 template <class Target, class Descriptor>
45 prefix_ void senf::ppi::module::Module::registerEvent(Target target, Descriptor & descriptor)
46 {
47     eventManager().registerEvent(
48         *this,
49         EventManager::Callback<Descriptor>::make(target,*this),
50         descriptor);
51     descriptor.enabled(true);
52 }
53
54 ///////////////////////////////////////////////////////////////////////////
55 // senf::ppi::module::detail namespace members
56
57 template <class Source, class Target>
58 prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
59 route(Module & module, Source & source, Target & target,
60       connector::InputConnector &, connector::OutputConnector &)
61 {
62     module.registerConnector(source);
63     module.registerConnector(target);
64 }
65
66 template <class Source, class Target>
67 prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
68 route(Module & module, Source & source, Target & target,
69       connector::InputConnector &, EventDescriptor &)
70 {
71     module.registerConnector(source);
72 }
73
74 template <class Source, class Target>
75 prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
76 route(Module & module, Source & source, Target & target,
77       EventDescriptor &, connector::OutputConnector &)
78 {
79     module.registerConnector(target);
80 }
81
82 ///////////////////////////////ct.e////////////////////////////////////////
83 #undef prefix_
84
85 \f
86 // Local Variables:
87 // mode: c++
88 // fill-column: 100
89 // comment-column: 40
90 // c-file-style: "senf"
91 // indent-tabs-mode: nil
92 // ispell-local-dictionary: "american"
93 // compile-command: "scons -u test"
94 // End: