switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / PPI / Jack.hh
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief Jack public header */
30
31 #ifndef HH_SENF_PPI_Jack_
32 #define HH_SENF_PPI_Jack_ 1
33
34 // Custom includes
35 #include <boost/utility.hpp>
36 #include <boost/type_traits.hpp>
37 #include "Connectors.hh"
38 #include "Setup.hh"
39
40 //#include "Jack.mpp"
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42
43 namespace senf {
44 namespace ppi {
45 namespace connector {
46
47     /** \brief Connector Jack base class
48         \see \ref ppi_jacks */
49     class Jack
50         : private boost::noncopyable, private ppi::detail::DisableStandardConnect
51     {};
52
53     /** \brief Jack referencing an ActiveInput
54         \see \ref ppi_jacks */
55     class GenericActiveInputJack
56         : public Jack
57     {
58     public:
59         explicit GenericActiveInputJack(GenericActiveInput & input);
60
61         GenericActiveInput & connector(); ///< Get referenced connector
62
63         void reset(GenericActiveInput & input); ///< Change connector
64                                         /**< Will update any existing connection accordingly */
65
66     private:
67         GenericActiveInput * input_;
68     };
69
70     /** \brief Jack referencing an ActiveOutput
71         \see \ref ppi_jacks */
72     class GenericActiveOutputJack
73         : public Jack
74     {
75     public:
76         explicit GenericActiveOutputJack(GenericActiveOutput & output);
77
78         GenericActiveOutput & connector(); ///< Get referenced connector
79
80         void reset(GenericActiveOutput & output); ///< Change connector
81                                         /**< Will update any existing connection accordingly */
82
83     private:
84         GenericActiveOutput * output_;
85     };
86
87     /** \brief Jack referencing a PassiveInput
88         \see \ref ppi_jacks */
89     class GenericPassiveInputJack
90         : public Jack
91     {
92     public:
93         explicit GenericPassiveInputJack(GenericPassiveInput & input);
94
95         GenericPassiveInput & connector(); ///< Get referenced connector
96
97         void reset(GenericPassiveInput & input); ///< Change connector
98                                         /**< Will update any existing connection accordingly */
99
100     private:
101         GenericPassiveInput * input_;
102     };
103
104     /** \brief Jack referencing a PassiveOutput
105         \see \ref ppi_jacks */
106     class GenericPassiveOutputJack
107         : public Jack
108     {
109     public:
110         explicit GenericPassiveOutputJack(GenericPassiveOutput & output);
111
112         GenericPassiveOutput & connector(); ///< Get referenced connector
113
114         void reset(GenericPassiveOutput & output); ///< Change connector
115                                         /**< Will update any existing connection accordingly */
116
117     private:
118         GenericPassiveOutput * output_;
119     };
120
121     /** \brief Jack with packet type referencing an ActiveInput
122         \see \ref ppi_jacks */
123     template <class PacketType=Packet>
124     class ActiveInputJack
125         : public GenericActiveInputJack
126     {
127     public:
128         explicit ActiveInputJack(ActiveInput<PacketType> & input);
129         explicit ActiveInputJack(ActiveInput<> & input);
130
131         explicit ActiveInputJack(ActiveInputJack & input);
132         explicit ActiveInputJack(ActiveInputJack<> & input);
133
134         void reset(ActiveInput<PacketType> & input);
135         void reset(ActiveInput<> & input);
136
137         void reset(ActiveInputJack & input);
138         void reset(ActiveInputJack<> & input);
139     };
140
141 #ifndef DOXYGEN
142
143     template <>
144     class ActiveInputJack<Packet>
145         : public GenericActiveInputJack
146     {
147     public:
148         explicit ActiveInputJack(GenericActiveInput & input);
149         explicit ActiveInputJack(GenericActiveInputJack input);
150
151         void reset(GenericActiveInput & input);
152         void reset(GenericActiveInputJack input);
153     };
154
155 #endif
156
157     /** \brief Jack with packet type referencing an ActiveOutput
158         \see \ref ppi_jacks */
159     template <class PacketType=Packet>
160     class ActiveOutputJack
161         : public GenericActiveOutputJack
162     {
163     public:
164         explicit ActiveOutputJack(ActiveOutput<PacketType> & output);
165         explicit ActiveOutputJack(ActiveOutput<> & output);
166
167         explicit ActiveOutputJack(ActiveOutputJack & output);
168         explicit ActiveOutputJack(ActiveOutputJack<> & output);
169
170         void reset(ActiveOutput<PacketType> & output);
171         void reset(ActiveOutput<> & output);
172
173         void reset(ActiveOutputJack & output);
174         void reset(ActiveOutputJack<> & output);
175     };
176
177 #ifndef DOXYGEN
178
179     template <>
180     class ActiveOutputJack<Packet>
181         : public GenericActiveOutputJack
182     {
183     public:
184         explicit ActiveOutputJack(GenericActiveOutput & output);
185         explicit ActiveOutputJack(GenericActiveOutputJack & output);
186
187         void reset(GenericActiveOutput & output);
188         void reset(GenericActiveOutputJack & output);
189     };
190
191 #endif
192
193     /** \brief Jack with packet type referencing a PassiveInput
194         \see \ref ppi_jacks */
195     template <class PacketType=Packet>
196     class PassiveInputJack
197         : public GenericPassiveInputJack
198     {
199     public:
200         explicit PassiveInputJack(PassiveInput<PacketType> & input);
201         explicit PassiveInputJack(PassiveInput<> & input);
202
203         explicit PassiveInputJack(PassiveInputJack & input);
204         explicit PassiveInputJack(PassiveInputJack<> & input);
205
206         void reset(PassiveInput<PacketType> & input);
207         void reset(PassiveInput<> & input);
208
209         void reset(PassiveInputJack & input);
210         void reset(PassiveInputJack<> & input);
211     };
212
213 #ifndef DOXYGEN
214
215     template <>
216     class PassiveInputJack<Packet>
217         : public GenericPassiveInputJack
218     {
219     public:
220         explicit PassiveInputJack(GenericPassiveInput & input);
221         explicit PassiveInputJack(GenericPassiveInputJack & input);
222
223         void reset(GenericPassiveInput & input);
224         void reset(GenericPassiveInputJack & input);
225     };
226
227 #endif
228
229     /** \brief Jack with packet type referencing a PassiveOutput
230         \see \ref ppi_jacks */
231     template <class PacketType=Packet>
232     class PassiveOutputJack
233         : public GenericPassiveOutputJack
234     {
235     public:
236         explicit PassiveOutputJack(PassiveOutput<PacketType> & output);
237         explicit PassiveOutputJack(PassiveOutput<> & output);
238
239         explicit PassiveOutputJack(PassiveOutputJack & output);
240         explicit PassiveOutputJack(PassiveOutputJack<> & output);
241
242         void reset(PassiveOutput<PacketType> & output);
243         void reset(PassiveOutput<> & output);
244
245         void reset(PassiveOutputJack & output);
246         void reset(PassiveOutputJack<> & output);
247     };
248
249 #ifndef DOXYGEN
250
251     template <>
252     class PassiveOutputJack<Packet>
253         : public GenericPassiveOutputJack
254     {
255     public:
256         explicit PassiveOutputJack(GenericPassiveOutput & output);
257         explicit PassiveOutputJack(GenericPassiveOutputJack & output);
258
259         void reset(GenericPassiveOutput & output);
260         void reset(GenericPassiveOutputJack & output);
261     };
262
263 #endif
264 }
265
266 #ifndef DOXYGEN
267
268     template <class T>
269     void connect(connector::GenericActiveOutputJack & source, T & target,
270                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
271     template <class T>
272     void connect(connector::GenericPassiveOutputJack & source, T & target,
273                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
274
275     template <class T>
276     void connect(T & source, connector::GenericActiveInputJack & target,
277                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
278     template <class T>
279     void connect(T & source, connector::GenericPassiveInputJack & target,
280                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
281
282     void connect(connector::GenericActiveOutputJack & source,
283                  connector::GenericPassiveInputJack & target);
284     void connect(connector::GenericPassiveOutputJack & source,
285                  connector::GenericActiveInputJack & target);
286
287     void connect(connector::GenericActiveOutputJack & source,
288                  connector::GenericPassiveInput & target);
289     void connect(connector::GenericPassiveOutputJack & source,
290                  connector::GenericActiveInput & target);
291
292     void connect(connector::GenericActiveOutput & source,
293                  connector::GenericPassiveInputJack & target);
294     void connect(connector::GenericPassiveOutput & source,
295                  connector::GenericActiveInputJack & target);
296
297 #endif
298 }}
299
300 //-/////////////////////////////////////////////////////////////////////////////////////////////////
301 #include "Jack.cci"
302 //#include "Jack.ct"
303 #include "Jack.cti"
304 #endif
305
306 \f
307 // Local Variables:
308 // mode: c++
309 // fill-column: 100
310 // comment-column: 40
311 // c-file-style: "senf"
312 // indent-tabs-mode: nil
313 // ispell-local-dictionary: "american"
314 // compile-command: "scons -u test"
315 // End: