PPI: Allow to change the IOEvent handle/event mask
[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         explicit ActiveInputJack(ActiveInputJack & input);
102         explicit ActiveInputJack(ActiveInputJack<> & input);
103     };
104
105 #ifndef DOXYGEN
106
107     template <>
108     class ActiveInputJack<Packet>
109         : public GenericActiveInputJack
110     {
111     public:
112         explicit ActiveInputJack(ActiveInput<> & input);
113         explicit ActiveInputJack(ActiveInputJack & input);
114     };
115
116 #endif
117
118     template <class PacketType=Packet>
119     class ActiveOutputJack
120         : public GenericActiveOutputJack
121     {
122     public:
123         explicit ActiveOutputJack(ActiveOutput<PacketType> & output);
124         explicit ActiveOutputJack(ActiveOutput<> & output);
125
126         explicit ActiveOutputJack(ActiveOutputJack & output);
127         explicit ActiveOutputJack(ActiveOutputJack<> & output);
128     };
129
130 #ifndef DOXYGEN
131
132     template <>
133     class ActiveOutputJack<Packet>
134         : public GenericActiveOutputJack
135     {
136     public:
137         explicit ActiveOutputJack(ActiveOutput<> & output);
138         explicit ActiveOutputJack(ActiveOutputJack & output);
139     };
140
141 #endif
142
143     template <class PacketType=Packet>
144     class PassiveInputJack
145         : public GenericPassiveInputJack
146     {
147     public:
148         explicit PassiveInputJack(PassiveInput<PacketType> & input);
149         explicit PassiveInputJack(PassiveInput<> & input);
150
151         explicit PassiveInputJack(PassiveInputJack & input);
152         explicit PassiveInputJack(PassiveInputJack<> & input);
153     };
154
155 #ifndef DOXYGEN
156
157     template <>
158     class PassiveInputJack<Packet>
159         : public GenericPassiveInputJack
160     {
161     public:
162         explicit PassiveInputJack(PassiveInput<> & input);
163         explicit PassiveInputJack(PassiveInputJack & input);
164     };
165
166 #endif
167
168     template <class PacketType=Packet>
169     class PassiveOutputJack
170         : public GenericPassiveOutputJack
171     {
172     public:
173         explicit PassiveOutputJack(PassiveOutput<PacketType> & output);
174         explicit PassiveOutputJack(PassiveOutput<> & output);
175
176         explicit PassiveOutputJack(PassiveOutputJack & output);
177         explicit PassiveOutputJack(PassiveOutputJack<> & output);
178     };
179
180 #ifndef DOXYGEN
181
182     template <>
183     class PassiveOutputJack<Packet>
184         : public GenericPassiveOutputJack
185     {
186     public:
187         explicit PassiveOutputJack(PassiveOutput<> & output);
188         explicit PassiveOutputJack(PassiveOutputJack & output);
189     };
190
191 #endif
192 }
193
194 #ifndef DOXYGEN
195
196     template <class T>
197     void connect(connector::GenericActiveOutputJack & source, T & target,
198                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
199     template <class T>
200     void connect(connector::GenericPassiveOutputJack & source, T & target,
201                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
202
203     template <class T>
204     void connect(T & source, connector::GenericActiveInputJack & target,
205                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
206     template <class T>
207     void connect(T & source, connector::GenericPassiveInputJack & target,
208                  typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
209
210     void connect(connector::GenericActiveOutputJack & source, 
211                  connector::GenericPassiveInputJack & target);
212     void connect(connector::GenericPassiveOutputJack & source, 
213                  connector::GenericActiveInputJack & target);
214
215     void connect(connector::GenericActiveOutputJack & source, 
216                  connector::GenericPassiveInput & target);
217     void connect(connector::GenericPassiveOutputJack & source, 
218                  connector::GenericActiveInput & target);
219
220     void connect(connector::GenericActiveOutput & source, 
221                  connector::GenericPassiveInputJack & target);
222     void connect(connector::GenericPassiveOutput & source, 
223                  connector::GenericActiveInputJack & target);
224
225 #endif
226 }}
227
228 ///////////////////////////////hh.e////////////////////////////////////////
229 #include "Jack.cci"
230 //#include "Jack.ct"
231 #include "Jack.cti"
232 #endif
233
234 \f
235 // Local Variables:
236 // mode: c++
237 // fill-column: 100
238 // comment-column: 40
239 // c-file-style: "senf"
240 // indent-tabs-mode: nil
241 // ispell-local-dictionary: "american"
242 // compile-command: "scons -u test"
243 // End: