PPI: Complete connector implementation
[senf.git] / PPI / Route.ih
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
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 Route internal header */
25
26 #ifndef IH_Route_
27 #define IH_Route_ 1
28
29 // Custom includes
30
31 ///////////////////////////////ih.p////////////////////////////////////////
32
33 namespace senf {
34 namespace ppi {
35 namespace detail {
36
37     // Valid Forwarding routes:
38     //   Forward throttling
39     //     ActiveInput -> PassiveOutput
40     //       tempalte<> RouteImplementation<ActiveInput,PassiveOutput,false,false>
41     //     ActiveInput -> Event
42     //       template<class Event> class RouteImplementation<ActiveInput, Event, false, true>
43     //   Backward throttling
44     //     PassiveInput -> ActiveOutput
45     //       template<> RouteImplementation<PassiveInput, ActiveOutput, false, false>
46     //     Event -> ActiveOutput
47     //       template<class Event> class RouteImplementation<Event, ActiveOutput, true, false>
48
49     class NonForwardingRouteImplementation
50         : public RouteBase
51     {
52     protected:
53         NonForwardingRouteImplementation(module::Module & module, 
54                                          connector::InputConnector & source,
55                                          connector::OutputConnector & target);
56
57     private:
58         connector::InputConnector * source_;
59         connector::OutputConnector * target_;
60     };
61
62     class NonForwardingRouteToEventImplementation
63         : public RouteBase
64     {
65     protected:
66         NonForwardingRouteToEventImplementation(module::Module & module,
67                                                 connector::InputConnector & source,
68                                                 EventDescriptor & target);
69         
70     private:
71         connector::InputConnector * source_;
72         EventDescriptor * target_;
73     };
74
75     class NonForwardingRouteFromEventImplementation
76         : public RouteBase
77     {
78     protected:
79         NonForwardingRouteFromEventImplementation(module::Module & module,
80                                                   EventDescriptor & source,
81                                                   connector::OutputConnector & target);
82
83     private:
84         EventDescriptor * source_;
85         connector::OutputConnector * target_;
86     };
87
88     class ForwardForwardingRouteImplementation
89         : public ForwardingRoute
90     {
91     protected:
92         ForwardForwardingRouteImplementation(module::Module & module,
93                                              connector::ActiveInput & source,
94                                              connector::PassiveOutput & target);
95
96     private:
97         virtual void v_notifyThrottle();
98         virtual void v_notifyUnthrottle();
99
100         connector::ActiveInput * source_;
101         connector::PassiveOutput * target_;
102     };
103
104     class BackwardForwardingRouteImplementation
105         : public ForwardingRoute
106     {
107     protected:
108         BackwardForwardingRouteImplementation(module::Module & module,
109                                               connector::PassiveInput & source,
110                                               connector::ActiveOutput & target);
111
112     private:
113         virtual void v_notifyThrottle();
114         virtual void v_notifyUnthrottle();
115         
116         connector::PassiveInput * source_;
117         connector::ActiveOutput * target_;
118     };
119
120     class ForwardForwardingRouteToEventImplementation
121         : public ForwardingRoute
122     {
123     protected:
124         ForwardForwardingRouteToEventImplementation(module::Module & module,
125                                                     connector::ActiveInput & source,
126                                                     EventDescriptor & target);
127
128     private:
129         virtual void v_notifyThrottle();
130         virtual void v_notifyUnthrottle();
131
132         connector::ActiveInput * source_;
133         EventDescriptor * target_;
134     };
135
136     class BackwardForwardingRouteFromEventImplementation
137         : public ForwardingRoute
138     {
139     protected:
140         BackwardForwardingRouteFromEventImplementation(module::Module & module,
141                                                        EventDescriptor & source,
142                                                        connector::ActiveOutput & target); 
143
144     private:
145         virtual void v_notifyThrottle();
146         virtual void v_notifyUnthrottle();
147
148         EventDescriptor * source_;
149         connector::ActiveOutput * target_;
150     };
151
152     template <class Source, class Target, bool srcEvent, bool trgEvent>
153     class RouteImplementation
154         : public NonForwardingRouteImplementation
155     {
156     protected:
157         RouteImplementation(module::Module & module, Source & source, Target & target);
158     };
159
160 #   ifndef DOXYGEN
161
162     template <class Source, class Target>
163     class RouteImplementation<Source, Target, true, false>
164         : public NonForwardingRouteFromEventImplementation
165     {
166     protected:
167         RouteImplementation(module::Module & module, Source & source, Target & target);
168     };
169
170     template<class Source, class Target>
171     class RouteImplementation<Source, Target, false, true>
172         : public NonForwardingRouteToEventImplementation
173     {
174     protected:
175         RouteImplementation(module::Module & module, Source & source, Target & target);
176     };
177
178     template<>
179     class RouteImplementation<connector::ActiveInput, connector::PassiveOutput, false, false>
180         : public ForwardForwardingRouteImplementation
181     {
182     protected:
183         RouteImplementation(module::Module & module, connector::ActiveInput & source, 
184                             connector::PassiveOutput & target);
185     };
186
187     template <class Event>
188     class RouteImplementation<connector::ActiveInput, Event, false, true>
189         : public ForwardForwardingRouteToEventImplementation
190     {
191     protected:
192         RouteImplementation(module::Module & module, connector::ActiveInput & source, 
193                             Event & target);
194     };
195
196     template <>
197     class RouteImplementation<connector::PassiveInput, connector::ActiveOutput, false, false>
198         : public BackwardForwardingRouteImplementation
199     {
200     protected:
201         RouteImplementation(module::Module & module, connector::PassiveInput & source, 
202                             connector::ActiveOutput & target);
203     };
204     
205     template <class Event>
206     class RouteImplementation<Event, connector::ActiveOutput, true, false>
207         : public BackwardForwardingRouteFromEventImplementation
208     {
209     protected:
210         RouteImplementation(module::Module & module, Event & source, 
211                             connector::ActiveOutput & target);
212     };
213
214 #   endif
215
216 }}}
217
218 ///////////////////////////////ih.e////////////////////////////////////////
219 #endif
220
221 \f
222 // Local Variables:
223 // mode: c++
224 // fill-column: 100
225 // comment-column: 40
226 // c-file-style: "senf"
227 // indent-tabs-mode: nil
228 // ispell-local-dictionary: "american"
229 // compile-command: "scons -u test"
230 // End: