808771c132380b3a3de5d193b7cf92e86938a8d8
[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 #ifndef DOXYGEN
35
36 template <class Source, class Target>
37 prefix_ senf::ppi::Route<Source, Target> &
38 senf::ppi::module::Module::route(Source & source, Target & target)
39 {
40     detail::RouteHelper<Source,Target>::route(*this, source, target, source, target);
41     return static_cast< Route<Source,Target> & >(
42         addRoute(std::auto_ptr< RouteBase >(
43                      new Route<Source,Target>(*this, source, target))));
44 }
45
46 #else
47 prefix_ senf::ppi::Route<connector::InputConnector, connector::OutputConnector> &
48 senf::ppi::module::Module::route(connector::InputConnector & input,
49                                  connector::OutputConnector & output)
50 {}
51 prefix_ senf::ppi::Route<connector::InputConnector, EventDescriptor> &
52 senf::ppi::module::Module::route(connector::InputConnector & input, EventDescriptor & output)
53 {}
54 #endif
55
56 #ifndef DOXYGEN
57
58 template <class Descriptor, class Target>
59 prefix_ void senf::ppi::module::Module::registerEvent(Descriptor & descriptor, Target target)
60 {
61     eventManager().registerEvent(
62         *this,
63         EventManager::Callback<Descriptor>::make(target,*this),
64         descriptor);
65     descriptor.enabled(true);
66 }
67
68 #else
69 template <class Target>
70 prefix_ void senf::ppi::module::Module::registerEvent(EventDescriptor & descriptor,
71                                                       Target target)
72 {}
73 #endif
74
75 ///////////////////////////////////////////////////////////////////////////
76 // senf::ppi::module::detail namespace members
77
78 template <class Source, class Target>
79 prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
80 route(Module & module, Source & source, Target & target,
81       connector::InputConnector &, connector::OutputConnector &)
82 {
83     module.registerConnector(source);
84     module.registerConnector(target);
85 }
86
87 template <class Source, class Target>
88 prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
89 route(Module & module, Source & source, Target & target,
90       connector::InputConnector &, EventDescriptor &)
91 {
92     module.registerConnector(source);
93 }
94
95 template <class Source, class Target>
96 prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
97 route(Module & module, Source & source, Target & target,
98       EventDescriptor &, connector::OutputConnector &)
99 {
100     module.registerConnector(target);
101 }
102
103 ///////////////////////////////ct.e////////////////////////////////////////
104 #undef prefix_
105
106 \f
107 // Local Variables:
108 // mode: c++
109 // fill-column: 100
110 // comment-column: 40
111 // c-file-style: "senf"
112 // indent-tabs-mode: nil
113 // ispell-local-dictionary: "american"
114 // compile-command: "scons -u test"
115 // End: