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