073943167cf99f7348334262a4600b32bb76d0af
[senf.git] / senf / PPI / MultiConnectorMixin.ih
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 MultiConnectorMixin internal header */
25
26 #ifndef IH_SENF_PPI_MultiConnectorMixin_
27 #define IH_SENF_PPI_MultiConnectorMixin_ 1
28
29 // Custom includes
30 #include "Setup.hh"
31
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33
34 namespace senf {
35 namespace ppi {
36 namespace module {
37 namespace detail {
38
39     struct MultiConnectorMixinAccess
40     {
41 #       define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
42             0, \
43             SENF_MULTI_CONNECTOR_MAX_ARGS,                              \
44             SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp),    \
45             8 ))
46 #       include BOOST_PP_ITERATE()
47     };
48
49     template <class KeyType, class ConnectorType>
50     struct MultiConnectorDefaultContainer
51     {
52         typedef boost::ptr_map<KeyType, ConnectorType> type;
53     };
54
55     template <class Module, class Connector>
56     class MultiConnectorWrapper
57         : public Connector
58     {
59     private:
60         virtual void v_disconnected();
61     };
62
63 #ifndef DOXYGEN
64
65     template <class ConnectorType>
66     struct MultiConnectorDefaultContainer<void,ConnectorType>
67     {
68         typedef boost::ptr_vector<ConnectorType> type;
69     };
70
71 #endif
72
73     template <class ConnectorType>
74     struct MultiConnectorSelectBase
75         : public boost::mpl::if_<
76               boost::is_base_of<connector::InputConnector, ConnectorType>,
77               ppi::detail::DisableStandardInput, ppi::detail::DisableStandardOutput >
78     {};
79
80     template <class T> senf::mpl::rv<0> isMulticonnector(...);
81     template <class T> senf::mpl::rv<1> isMulticonnector(
82         typename boost::enable_if<boost::is_base_of<connector::OutputConnector,
83                                                     typename T::ConnectorType>,
84                                   int>::type);
85     template <class T> senf::mpl::rv<2> isMulticonnector(
86         typename boost::enable_if<boost::is_base_of<connector::InputConnector,
87                                                     typename T::ConnectorType>,
88                                   int>::type);
89
90     template <class T, unsigned N>
91     struct IsMulticonnectorSource_
92         : public boost::false_type
93     {};
94
95     template <class T>
96     struct IsMulticonnectorSource_<T, 1u>
97         : public boost::true_type
98     {};
99
100     template <class T>
101     struct IsMulticonnectorSource
102         : public IsMulticonnectorSource_<T, SENF_MPL_RV(isMulticonnector<T>(0))>
103     {};
104
105     template <class T, unsigned N>
106     struct IsMulticonnectorTarget_
107         : public boost::false_type
108     {};
109
110     template <class T>
111     struct IsMulticonnectorTarget_<T, 2u>
112         : public boost::true_type
113     {};
114
115     template <class T>
116     struct IsMulticonnectorTarget
117         : public IsMulticonnectorTarget_<T, SENF_MPL_RV(isMulticonnector<T>(0))>
118     {};
119
120
121
122 }}}}
123
124 //-/////////////////////////////////////////////////////////////////////////////////////////////////
125 #endif
126
127 \f
128 // Local Variables:
129 // mode: c++
130 // fill-column: 100
131 // comment-column: 40
132 // c-file-style: "senf"
133 // indent-tabs-mode: nil
134 // ispell-local-dictionary: "american"
135 // compile-command: "scons -u test"
136 // End: