switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / PPI / MultiConnectorMixin.ih
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief MultiConnectorMixin internal header */
30
31 #ifndef IH_SENF_PPI_MultiConnectorMixin_
32 #define IH_SENF_PPI_MultiConnectorMixin_ 1
33
34 // Custom includes
35 #include "Setup.hh"
36
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38
39 namespace senf {
40 namespace ppi {
41 namespace module {
42 namespace detail {
43
44     struct MultiConnectorMixinAccess
45     {
46 #       define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
47             0, \
48             SENF_MULTI_CONNECTOR_MAX_ARGS,                              \
49             SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp),    \
50             8 ))
51 #       include BOOST_PP_ITERATE()
52     };
53
54     template <class KeyType, class ConnectorType>
55     struct MultiConnectorDefaultContainer
56     {
57         typedef boost::ptr_map<KeyType, ConnectorType> type;
58     };
59
60     template <class Module, class Connector>
61     class MultiConnectorWrapper
62         : public Connector
63     {
64     private:
65         virtual void v_disconnected();
66     };
67
68 #ifndef DOXYGEN
69
70     template <class ConnectorType>
71     struct MultiConnectorDefaultContainer<void,ConnectorType>
72     {
73         typedef boost::ptr_vector<ConnectorType> type;
74     };
75
76 #endif
77
78     template <class ConnectorType>
79     struct MultiConnectorSelectBase
80         : public boost::mpl::if_<
81               boost::is_base_of<connector::InputConnector, ConnectorType>,
82               ppi::detail::DisableStandardInput, ppi::detail::DisableStandardOutput >
83     {};
84
85     template <class T> senf::mpl::rv<0> isMulticonnector(...);
86     template <class T> senf::mpl::rv<1> isMulticonnector(
87         typename boost::enable_if<boost::is_base_of<connector::OutputConnector,
88                                                     typename T::ConnectorType>,
89                                   int>::type);
90     template <class T> senf::mpl::rv<2> isMulticonnector(
91         typename boost::enable_if<boost::is_base_of<connector::InputConnector,
92                                                     typename T::ConnectorType>,
93                                   int>::type);
94
95     template <class T, unsigned N>
96     struct IsMulticonnectorSource_
97         : public boost::false_type
98     {};
99
100     template <class T>
101     struct IsMulticonnectorSource_<T, 1u>
102         : public boost::true_type
103     {};
104
105     template <class T>
106     struct IsMulticonnectorSource
107         : public IsMulticonnectorSource_<T, SENF_MPL_RV(isMulticonnector<T>(0))>
108     {};
109
110     template <class T, unsigned N>
111     struct IsMulticonnectorTarget_
112         : public boost::false_type
113     {};
114
115     template <class T>
116     struct IsMulticonnectorTarget_<T, 2u>
117         : public boost::true_type
118     {};
119
120     template <class T>
121     struct IsMulticonnectorTarget
122         : public IsMulticonnectorTarget_<T, SENF_MPL_RV(isMulticonnector<T>(0))>
123     {};
124
125
126
127 }}}}
128
129 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130 #endif
131
132 \f
133 // Local Variables:
134 // mode: c++
135 // fill-column: 100
136 // comment-column: 40
137 // c-file-style: "senf"
138 // indent-tabs-mode: nil
139 // ispell-local-dictionary: "american"
140 // compile-command: "scons -u test"
141 // End: