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