PPI: Fix (generic) 'Packet' Jack constructors
[senf.git] / 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
34 //#include "Jack.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
36
37 namespace senf {
38 namespace ppi {
39 namespace connector {
40
41     /** \brief Connector Jack base class
42         \see \ref ppi_jacks */
43     class Jack
44         : private boost::noncopyable
45     {};
46
47     /** \brief Jack referencing an ActiveInput 
48         \see \ref ppi_jacks */
49     class GenericActiveInputJack
50         : public Jack
51     {
52     public:
53         explicit GenericActiveInputJack(GenericActiveInput & input);
54
55         GenericActiveInput & connector(); ///< Get referenced connector
56
57     private:
58         GenericActiveInput & input_;
59     };
60
61     /** \brief Jack referencing an ActiveOutput
62         \see \ref ppi_jacks */
63     class GenericActiveOutputJack
64         : public Jack
65     {
66     public:
67         explicit GenericActiveOutputJack(GenericActiveOutput & output);
68
69         GenericActiveOutput & connector(); ///< Get referenced connector
70
71     private:
72         GenericActiveOutput & output_;
73     };
74
75     /** \brief Jack referencing a PassiveInput
76         \see \ref ppi_jacks */
77     class GenericPassiveInputJack
78         : public Jack
79     {
80     public:
81         explicit GenericPassiveInputJack(GenericPassiveInput & input);
82
83         GenericPassiveInput & connector(); ///< Get referenced connector
84
85     private:
86         GenericPassiveInput & input_;
87     };
88     
89     /** \brief Jack referencing a PassiveOutput
90         \see \ref ppi_jacks */
91     class GenericPassiveOutputJack
92         : public Jack
93     {
94     public:
95         explicit GenericPassiveOutputJack(GenericPassiveOutput & output);
96
97         GenericPassiveOutput & connector(); ///< Get referenced connector
98
99     private:
100         GenericPassiveOutput & output_;
101     };
102
103     /** \brief Jack with packet type referencing an ActiveInput
104         \see \ref ppi_jacks */
105     template <class PacketType=Packet>
106     class ActiveInputJack
107         : public GenericActiveInputJack
108     {
109     public:
110         explicit ActiveInputJack(ActiveInput<PacketType> & input);
111         explicit ActiveInputJack(ActiveInput<> & input);
112         
113         explicit ActiveInputJack(ActiveInputJack & input);
114         explicit ActiveInputJack(ActiveInputJack<> & input);
115     };
116
117 #ifndef DOXYGEN
118
119     template <>
120     class ActiveInputJack<Packet>
121         : public GenericActiveInputJack
122     {
123     public:
124         explicit ActiveInputJack(GenericActiveInput & input);
125         explicit ActiveInputJack(GenericActiveInputJack input);
126     };
127
128 #endif
129
130     /** \brief Jack with packet type referencing an ActiveOutput
131         \see \ref ppi_jacks */
132     template <class PacketType=Packet>
133     class ActiveOutputJack
134         : public GenericActiveOutputJack
135     {
136     public:
137         explicit ActiveOutputJack(ActiveOutput<PacketType> & output);
138         explicit ActiveOutputJack(ActiveOutput<> & output);
139
140         explicit ActiveOutputJack(ActiveOutputJack & output);
141         explicit ActiveOutputJack(ActiveOutputJack<> & output);
142     };
143
144 #ifndef DOXYGEN
145
146     template <>
147     class ActiveOutputJack<Packet>
148         : public GenericActiveOutputJack
149     {
150     public:
151         explicit ActiveOutputJack(GenericActiveOutput & output);
152         explicit ActiveOutputJack(GenericActiveOutputJack & output);
153     };
154
155 #endif
156
157     /** \brief Jack with packet type referencing a PassiveInput
158         \see \ref ppi_jacks */
159     template <class PacketType=Packet>
160     class PassiveInputJack
161         : public GenericPassiveInputJack
162     {
163     public:
164         explicit PassiveInputJack(PassiveInput<PacketType> & input);
165         explicit PassiveInputJack(PassiveInput<> & input);
166
167         explicit PassiveInputJack(PassiveInputJack & input);
168         explicit PassiveInputJack(PassiveInputJack<> & input);
169     };
170
171 #ifndef DOXYGEN
172
173     template <>
174     class PassiveInputJack<Packet>
175         : public GenericPassiveInputJack
176     {
177     public:
178         explicit PassiveInputJack(GenericPassiveInput & input);
179         explicit PassiveInputJack(GenericPassiveInputJack & input);
180     };
181
182 #endif
183
184     /** \brief Jack with packet type referencing a PassiveOutput
185         \see \ref ppi_jacks */
186     template <class PacketType=Packet>
187     class PassiveOutputJack
188         : public GenericPassiveOutputJack
189     {
190     public:
191         explicit PassiveOutputJack(PassiveOutput<PacketType> & output);
192         explicit PassiveOutputJack(PassiveOutput<> & output);
193
194         explicit PassiveOutputJack(PassiveOutputJack & output);
195         explicit PassiveOutputJack(PassiveOutputJack<> & output);
196     };
197
198 #ifndef DOXYGEN
199
200     template <>
201     class PassiveOutputJack<Packet>
202         : public GenericPassiveOutputJack
203     {
204     public:
205         explicit PassiveOutputJack(GenericPassiveOutput & output);
206         explicit PassiveOutputJack(GenericPassiveOutputJack & output);
207     };
208
209 #endif
210 }
211
212 #ifndef DOXYGEN
213
214     template <class T>
215     void connect(connector::GenericActiveOutputJack & source, T & target,
216                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
217     template <class T>
218     void connect(connector::GenericPassiveOutputJack & source, T & target,
219                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
220
221     template <class T>
222     void connect(T & source, connector::GenericActiveInputJack & target,
223                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
224     template <class T>
225     void connect(T & source, connector::GenericPassiveInputJack & target,
226                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
227
228     void connect(connector::GenericActiveOutputJack & source, 
229                  connector::GenericPassiveInputJack & target);
230     void connect(connector::GenericPassiveOutputJack & source, 
231                  connector::GenericActiveInputJack & target);
232
233     void connect(connector::GenericActiveOutputJack & source, 
234                  connector::GenericPassiveInput & target);
235     void connect(connector::GenericPassiveOutputJack & source, 
236                  connector::GenericActiveInput & target);
237
238     void connect(connector::GenericActiveOutput & source, 
239                  connector::GenericPassiveInputJack & target);
240     void connect(connector::GenericPassiveOutput & source, 
241                  connector::GenericActiveInputJack & target);
242
243 #endif
244 }}
245
246 ///////////////////////////////hh.e////////////////////////////////////////
247 #include "Jack.cci"
248 //#include "Jack.ct"
249 #include "Jack.cti"
250 #endif
251
252 \f
253 // Local Variables:
254 // mode: c++
255 // fill-column: 100
256 // comment-column: 40
257 // c-file-style: "senf"
258 // indent-tabs-mode: nil
259 // ispell-local-dictionary: "american"
260 // compile-command: "scons -u test"
261 // End: