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
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
15 \brief InterfaceDecorator inline template implementation */
17 //#include "InterfaceDecorator.ih"
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::emu::ReceiverDecorator
27 template <class Connector>
28 prefix_ senf::emu::ReceiverDecorator::ReceiverDecorator(Connector & connector)
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33 // senf::emu::TransmitterDecorator
35 template <class Connector>
36 prefix_ senf::emu::TransmitterDecorator::TransmitterDecorator(Connector & connector)
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
41 // senf::emu::TypedInterfaceDecorator<InterfaceType,Base>
43 template <class InterfaceType, class Base>
44 prefix_ InterfaceType & senf::emu::TypedInterfaceDecorator<InterfaceType,Base>::interface()
46 return dynamic_cast<InterfaceType &>(Base::interface());
49 template <class InterfaceType, class Base>
50 prefix_ InterfaceType const &
51 senf::emu::TypedInterfaceDecorator<InterfaceType,Base>::interface()
54 return dynamic_cast<InterfaceType const &>(Base::interface());
57 template <class InterfaceType, class Base>
58 prefix_ senf::emu::TypedInterfaceDecorator<InterfaceType,Base>::
59 TypedInterfaceDecorator(InterfaceType & interface)
63 //-/////////////////////////////////////////////////////////////////////////////////////////////////
64 // senf::emu::ReceiverDecoratorImplementation<DecoratorType,ReceiveModule>
66 template <class ReceiveModule>
67 template <class Interface>
69 senf::emu::ReceiverDecoratorImplementation<ReceiveModule>::
70 ReceiverDecoratorImplementation(Interface & interface)
71 : ModuleMember (boost::ref(interface)), ReceiverDecorator (ModuleMember::member.output)
73 ppi::connect(interface, ModuleMember::member);
76 template <class ReceiveModule>
77 prefix_ ReceiveModule &
78 senf::emu::ReceiverDecoratorImplementation<ReceiveModule>::receiveModule()
80 return ModuleMember::member;
83 template <class ReceiveModule>
84 prefix_ ReceiveModule const &
85 senf::emu::ReceiverDecoratorImplementation<ReceiveModule>::receiveModule()
88 return ModuleMember::member;
91 //-/////////////////////////////////////////////////////////////////////////////////////////////////
92 // senf::emu::ReceiverDecoratorImplementation<DecoratorType, senf::mpl::nil>
94 template <class Interface>
96 senf::emu::ReceiverDecoratorImplementation<senf::mpl::nil>::
97 ReceiverDecoratorImplementation(Interface & interface)
98 : ReceiverDecorator (interface.output)
101 //-/////////////////////////////////////////////////////////////////////////////////////////////////
102 // senf::emu::TransmitterDecoratorImplementation<DecoratorType,TransmitModule>
104 template <class TransmitModule>
105 template <class Interface>
107 senf::emu::TransmitterDecoratorImplementation<TransmitModule>::
108 TransmitterDecoratorImplementation(Interface & interface)
109 : ModuleMember (boost::ref(interface)), TransmitterDecorator (ModuleMember::member.input)
111 ppi::connect(ModuleMember::member, interface);
114 template <class TransmitModule>
115 prefix_ TransmitModule &
116 senf::emu::TransmitterDecoratorImplementation<TransmitModule>::transmitModule()
118 return ModuleMember::member;
121 template <class TransmitModule>
122 prefix_ TransmitModule const &
123 senf::emu::TransmitterDecoratorImplementation<TransmitModule>::transmitModule()
126 return ModuleMember::member;
129 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130 // senf::emu::TransmitterDecoratorImplementation<DecoratorType, senf::mpl::nil>
132 template <class Interface>
134 senf::emu::TransmitterDecoratorImplementation<senf::mpl::nil>::
135 TransmitterDecoratorImplementation(Interface & interface)
136 : TransmitterDecorator(interface.input)
139 //-/////////////////////////////////////////////////////////////////////////////////////////////////
140 // senf::emu::detail::NoDecorator
142 template <class Interface>
143 prefix_ senf::emu::detail::NoDecorator::NoDecorator(Interface & interface)
146 //-/////////////////////////////////////////////////////////////////////////////////////////////////
147 // senf::emu::InterfaceDecoratorImplementation<InterfaceType,ReceiveModule,TransmitModule>
149 template <class InterfaceType, class ReceiveModule, class TransmitModule>
151 senf::emu::InterfaceDecoratorImplementation<InterfaceType,ReceiveModule,TransmitModule>::
152 InterfaceDecoratorImplementation()
153 : InterfaceType::Decorator (InterfaceBase::member),
154 ReceiverDecoratorBase (InterfaceBase::member),
155 TransmitterDecoratorBase (InterfaceBase::member)
158 template <class InterfaceType, class ReceiveModule, class TransmitModule>
161 senf::emu::InterfaceDecoratorImplementation<InterfaceType,ReceiveModule,TransmitModule>::
162 InterfaceDecoratorImplementation(A1 const & a1)
164 InterfaceType::Decorator (InterfaceBase::member),
165 ReceiverDecoratorBase (InterfaceBase::member),
166 TransmitterDecoratorBase (InterfaceBase::member)
169 template <class InterfaceType, class ReceiveModule, class TransmitModule>
170 template <class A1, class A2>
172 senf::emu::InterfaceDecoratorImplementation<InterfaceType,ReceiveModule,TransmitModule>::
173 InterfaceDecoratorImplementation(A1 const & a1, A2 const & a2)
174 : InterfaceBase(a1, a2),
175 InterfaceType::Decorator (InterfaceBase::member),
176 ReceiverDecoratorBase (InterfaceBase::member),
177 TransmitterDecoratorBase (InterfaceBase::member)
180 //-/////////////////////////////////////////////////////////////////////////////////////////////////
181 // senf::emu::ApplyInterfaceDecorator<ReceiveModule,TransmitModule>
183 template <class ReceiveModule, class TransmitModule>
184 prefix_ ReceiveModule &
185 senf::emu::ApplyInterfaceDecorator<ReceiveModule,TransmitModule>::
186 receiveModule(InterfaceDecorator & interface)
189 return dynamic_cast<ReceiverDecoratorImplementation<ReceiveModule>&>(
190 interface.receiverDecorator()).receiveModule();
192 SENF_WRAP_EXC_MSG(std::bad_cast, "in (ReceiveModule &). Type is " + senf::prettyName(typeid(const_cast<InterfaceDecorator &>(interface))))
195 template <class ReceiveModule, class TransmitModule>
196 prefix_ ReceiveModule const &
197 senf::emu::ApplyInterfaceDecorator<ReceiveModule,TransmitModule>::
198 receiveModule(InterfaceDecorator const & interface)
201 return dynamic_cast<ReceiverDecoratorImplementation<ReceiveModule> const &>(
202 interface.receiverDecorator()).receiveModule();
204 SENF_WRAP_EXC_MSG(std::bad_cast, "in (ReceiveModule const &). Type is " + senf::prettyName(typeid(const_cast<InterfaceDecorator &>(interface))))
207 template <class ReceiveModule, class TransmitModule>
208 prefix_ TransmitModule &
209 senf::emu::ApplyInterfaceDecorator<ReceiveModule,TransmitModule>::
210 transmitModule(InterfaceDecorator & interface)
213 return dynamic_cast<TransmitterDecoratorImplementation<TransmitModule> &>(
214 interface.transmitterDecorator()).transmitModule();
216 SENF_WRAP_EXC_MSG(std::bad_cast, "in (TransmitModule &). Type is " + senf::prettyName(typeid(const_cast<InterfaceDecorator &>(interface))))
219 template <class ReceiveModule, class TransmitModule>
220 prefix_ TransmitModule const &
221 senf::emu::ApplyInterfaceDecorator<ReceiveModule,TransmitModule>::
222 transmitModule(InterfaceDecorator const & interface)
225 return dynamic_cast<TransmitterDecoratorImplementation<TransmitModule> const &>(
226 interface.transmitterDecorator()).transmitModule();
228 SENF_WRAP_EXC_MSG(std::bad_cast, "in (TransmitModule const &). Type is " + senf::prettyName(typeid(const_cast<InterfaceDecorator &>(interface))))
231 //-/////////////////////////////////////////////////////////////////////////////////////////////////
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"