deda179105099f63888379bf5e2bdaa6d9273609
[senf.git] / senf / PPI / Jack.hh
1 // $Id$
2 //
3 // Copyright (C) 2009
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 Jack public header */
25
26 #ifndef HH_SENF_PPI_Jack_
27 #define HH_SENF_PPI_Jack_ 1
28
29 // Custom includes
30 #include <boost/utility.hpp>
31 #include <boost/type_traits.hpp>
32 #include "Connectors.hh"
33 #include "Setup.hh"
34
35 //#include "Jack.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 namespace senf {
39 namespace ppi {
40 namespace connector {
41
42     /** \brief Connector Jack base class
43         \see \ref ppi_jacks */
44     class Jack
45         : private boost::noncopyable, private ppi::detail::DisableStandardConnect
46     {};
47
48     /** \brief Jack referencing an ActiveInput
49         \see \ref ppi_jacks */
50     class GenericActiveInputJack
51         : public Jack
52     {
53     public:
54         explicit GenericActiveInputJack(GenericActiveInput & input);
55
56         GenericActiveInput & connector(); ///< Get referenced connector
57
58         void reset(GenericActiveInput & input); ///< Change connector
59                                         /**< Will update any existing connection accordingly */
60
61     private:
62         GenericActiveInput * input_;
63     };
64
65     /** \brief Jack referencing an ActiveOutput
66         \see \ref ppi_jacks */
67     class GenericActiveOutputJack
68         : public Jack
69     {
70     public:
71         explicit GenericActiveOutputJack(GenericActiveOutput & output);
72
73         GenericActiveOutput & connector(); ///< Get referenced connector
74
75         void reset(GenericActiveOutput & output); ///< Change connector
76                                         /**< Will update any existing connection accordingly */
77
78     private:
79         GenericActiveOutput * output_;
80     };
81
82     /** \brief Jack referencing a PassiveInput
83         \see \ref ppi_jacks */
84     class GenericPassiveInputJack
85         : public Jack
86     {
87     public:
88         explicit GenericPassiveInputJack(GenericPassiveInput & input);
89
90         GenericPassiveInput & connector(); ///< Get referenced connector
91
92         void reset(GenericPassiveInput & input); ///< Change connector
93                                         /**< Will update any existing connection accordingly */
94
95     private:
96         GenericPassiveInput * input_;
97     };
98
99     /** \brief Jack referencing a PassiveOutput
100         \see \ref ppi_jacks */
101     class GenericPassiveOutputJack
102         : public Jack
103     {
104     public:
105         explicit GenericPassiveOutputJack(GenericPassiveOutput & output);
106
107         GenericPassiveOutput & connector(); ///< Get referenced connector
108
109         void reset(GenericPassiveOutput & output); ///< Change connector
110                                         /**< Will update any existing connection accordingly */
111
112     private:
113         GenericPassiveOutput * output_;
114     };
115
116     /** \brief Jack with packet type referencing an ActiveInput
117         \see \ref ppi_jacks */
118     template <class PacketType=Packet>
119     class ActiveInputJack
120         : public GenericActiveInputJack
121     {
122     public:
123         explicit ActiveInputJack(ActiveInput<PacketType> & input);
124         explicit ActiveInputJack(ActiveInput<> & input);
125
126         explicit ActiveInputJack(ActiveInputJack & input);
127         explicit ActiveInputJack(ActiveInputJack<> & input);
128
129         void reset(ActiveInput<PacketType> & input);
130         void reset(ActiveInput<> & input);
131
132         void reset(ActiveInputJack & input);
133         void reset(ActiveInputJack<> & input);
134     };
135
136 #ifndef DOXYGEN
137
138     template <>
139     class ActiveInputJack<Packet>
140         : public GenericActiveInputJack
141     {
142     public:
143         explicit ActiveInputJack(GenericActiveInput & input);
144         explicit ActiveInputJack(GenericActiveInputJack input);
145
146         void reset(GenericActiveInput & input);
147         void reset(GenericActiveInputJack input);
148     };
149
150 #endif
151
152     /** \brief Jack with packet type referencing an ActiveOutput
153         \see \ref ppi_jacks */
154     template <class PacketType=Packet>
155     class ActiveOutputJack
156         : public GenericActiveOutputJack
157     {
158     public:
159         explicit ActiveOutputJack(ActiveOutput<PacketType> & output);
160         explicit ActiveOutputJack(ActiveOutput<> & output);
161
162         explicit ActiveOutputJack(ActiveOutputJack & output);
163         explicit ActiveOutputJack(ActiveOutputJack<> & output);
164
165         void reset(ActiveOutput<PacketType> & output);
166         void reset(ActiveOutput<> & output);
167
168         void reset(ActiveOutputJack & output);
169         void reset(ActiveOutputJack<> & output);
170     };
171
172 #ifndef DOXYGEN
173
174     template <>
175     class ActiveOutputJack<Packet>
176         : public GenericActiveOutputJack
177     {
178     public:
179         explicit ActiveOutputJack(GenericActiveOutput & output);
180         explicit ActiveOutputJack(GenericActiveOutputJack & output);
181
182         void reset(GenericActiveOutput & output);
183         void reset(GenericActiveOutputJack & output);
184     };
185
186 #endif
187
188     /** \brief Jack with packet type referencing a PassiveInput
189         \see \ref ppi_jacks */
190     template <class PacketType=Packet>
191     class PassiveInputJack
192         : public GenericPassiveInputJack
193     {
194     public:
195         explicit PassiveInputJack(PassiveInput<PacketType> & input);
196         explicit PassiveInputJack(PassiveInput<> & input);
197
198         explicit PassiveInputJack(PassiveInputJack & input);
199         explicit PassiveInputJack(PassiveInputJack<> & input);
200
201         void reset(PassiveInput<PacketType> & input);
202         void reset(PassiveInput<> & input);
203
204         void reset(PassiveInputJack & input);
205         void reset(PassiveInputJack<> & input);
206     };
207
208 #ifndef DOXYGEN
209
210     template <>
211     class PassiveInputJack<Packet>
212         : public GenericPassiveInputJack
213     {
214     public:
215         explicit PassiveInputJack(GenericPassiveInput & input);
216         explicit PassiveInputJack(GenericPassiveInputJack & input);
217
218         void reset(GenericPassiveInput & input);
219         void reset(GenericPassiveInputJack & input);
220     };
221
222 #endif
223
224     /** \brief Jack with packet type referencing a PassiveOutput
225         \see \ref ppi_jacks */
226     template <class PacketType=Packet>
227     class PassiveOutputJack
228         : public GenericPassiveOutputJack
229     {
230     public:
231         explicit PassiveOutputJack(PassiveOutput<PacketType> & output);
232         explicit PassiveOutputJack(PassiveOutput<> & output);
233
234         explicit PassiveOutputJack(PassiveOutputJack & output);
235         explicit PassiveOutputJack(PassiveOutputJack<> & output);
236
237         void reset(PassiveOutput<PacketType> & output);
238         void reset(PassiveOutput<> & output);
239
240         void reset(PassiveOutputJack & output);
241         void reset(PassiveOutputJack<> & output);
242     };
243
244 #ifndef DOXYGEN
245
246     template <>
247     class PassiveOutputJack<Packet>
248         : public GenericPassiveOutputJack
249     {
250     public:
251         explicit PassiveOutputJack(GenericPassiveOutput & output);
252         explicit PassiveOutputJack(GenericPassiveOutputJack & output);
253
254         void reset(GenericPassiveOutput & output);
255         void reset(GenericPassiveOutputJack & output);
256     };
257
258 #endif
259 }
260
261 #ifndef DOXYGEN
262
263     template <class T>
264     void connect(connector::GenericActiveOutputJack & source, T & target,
265                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
266     template <class T>
267     void connect(connector::GenericPassiveOutputJack & source, T & target,
268                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
269
270     template <class T>
271     void connect(T & source, connector::GenericActiveInputJack & target,
272                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
273     template <class T>
274     void connect(T & source, connector::GenericPassiveInputJack & target,
275                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
276
277     void connect(connector::GenericActiveOutputJack & source,
278                  connector::GenericPassiveInputJack & target);
279     void connect(connector::GenericPassiveOutputJack & source,
280                  connector::GenericActiveInputJack & target);
281
282     void connect(connector::GenericActiveOutputJack & source,
283                  connector::GenericPassiveInput & target);
284     void connect(connector::GenericPassiveOutputJack & source,
285                  connector::GenericActiveInput & target);
286
287     void connect(connector::GenericActiveOutput & source,
288                  connector::GenericPassiveInputJack & target);
289     void connect(connector::GenericPassiveOutput & source,
290                  connector::GenericActiveInputJack & target);
291
292 #endif
293 }}
294
295 ///////////////////////////////hh.e////////////////////////////////////////
296 #include "Jack.cci"
297 //#include "Jack.ct"
298 #include "Jack.cti"
299 #endif
300
301 \f
302 // Local Variables:
303 // mode: c++
304 // fill-column: 100
305 // comment-column: 40
306 // c-file-style: "senf"
307 // indent-tabs-mode: nil
308 // ispell-local-dictionary: "american"
309 // compile-command: "scons -u test"
310 // End: