MultiConnectorMixin.ih
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief MultiConnectorMixin internal header */
16 
17 #ifndef IH_SENF_PPI_MultiConnectorMixin_
18 #define IH_SENF_PPI_MultiConnectorMixin_ 1
19 
20 // Custom includes
21 #include <boost/ptr_container/ptr_unordered_map.hpp>
22 #include "Setup.hh"
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 namespace ppi {
28 namespace module {
29 namespace detail {
30 
31  struct MultiConnectorMixinAccess
32  {
33 # define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
34  0, \
35  SENF_MULTI_CONNECTOR_MAX_ARGS, \
36  SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \
37  8 ))
38 # include BOOST_PP_ITERATE()
39  };
40 
41  template <class KeyType, class ConnectorType>
42  struct MultiConnectorDefaultContainer
43  {
44  typedef boost::ptr_unordered_map<KeyType, ConnectorType> type;
45  };
46 
47  template <class Module, class Connector>
48  class MultiConnectorWrapper
49  : public Connector
50  {
51  private:
52  virtual void v_disconnected();
53  };
54 
55 #ifndef DOXYGEN
56 
57  template <class ConnectorType>
58  struct MultiConnectorDefaultContainer<void,ConnectorType>
59  {
60  typedef boost::ptr_vector<ConnectorType> type;
61  };
62 
63 #endif
64 
65  template <class ConnectorType>
66  struct MultiConnectorSelectBase
67  : public boost::mpl::if_<
68  boost::is_base_of<connector::InputConnector, ConnectorType>,
69  ppi::detail::DisableStandardInput, ppi::detail::DisableStandardOutput >
70  {};
71 
72  template <class T> senf::mpl::rv<0> isMulticonnector(...);
73  template <class T> senf::mpl::rv<1> isMulticonnector(
74  typename boost::enable_if<boost::is_base_of<connector::OutputConnector,
75  typename T::ConnectorType>,
76  int>::type);
77  template <class T> senf::mpl::rv<2> isMulticonnector(
78  typename boost::enable_if<boost::is_base_of<connector::InputConnector,
79  typename T::ConnectorType>,
80  int>::type);
81 
82  template <class T, unsigned N>
83  struct IsMulticonnectorSource_
84  : public boost::false_type
85  {};
86 
87  template <class T>
88  struct IsMulticonnectorSource_<T, 1u>
89  : public boost::true_type
90  {};
91 
92  template <class T>
93  struct IsMulticonnectorSource
94  : public IsMulticonnectorSource_<T, SENF_MPL_RV(isMulticonnector<T>(0))>
95  {};
96 
97  template <class T, unsigned N>
98  struct IsMulticonnectorTarget_
99  : public boost::false_type
100  {};
101 
102  template <class T>
103  struct IsMulticonnectorTarget_<T, 2u>
104  : public boost::true_type
105  {};
106 
107  template <class T>
108  struct IsMulticonnectorTarget
109  : public IsMulticonnectorTarget_<T, SENF_MPL_RV(isMulticonnector<T>(0))>
110  {};
111 
112 
113 
114 }}}}
115 
116 //-/////////////////////////////////////////////////////////////////////////////////////////////////
117 #endif
118 
119 
120 // Local Variables:
121 // mode: c++
122 // fill-column: 100
123 // comment-column: 40
124 // c-file-style: "senf"
125 // indent-tabs-mode: nil
126 // ispell-local-dictionary: "american"
127 // compile-command: "scons -u test"
128 // End: