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