5 #ifndef LODESTAR_SWITCHBLOCK_HPP
6 #define LODESTAR_SWITCHBLOCK_HPP
8 #include "Lodestar/blocks/Block.hpp"
13 enum class SwitchBlockParameter {
18 template<
typename TType,
19 SwitchBlockParameter TPar = SwitchBlockParameter::Parametric>
21 static_assert(::std::is_same<TType, TType>::value,
22 "SwitchBlock not defined for this type.");
25 template<
typename TType>
28 ::std::tuple<TType, TType>,
35 ::std::tuple<TType, TType>,
54 bool &state(
bool setting)
56 this->
template p<0>() = setting;
57 return this->
template p<0>();
62 return this->
template p<0>();
67 return this->
template p<0>();
78 this->equation = ::std::bind(
79 &type::triggerFunction,
81 ::std::placeholders::_1
85 void triggerFunction(
Base &b)
88 this->
template o<0>() = this->
template i<1>();
90 this->
template o<0>() = this->
template i<0>();
94 template<
typename TType>
97 ::std::tuple<TType, TType, bool>,
104 ::std::tuple<TType, TType, bool>,
125 this->
template i<2>() = setting;
126 return this->
template i<2>();
131 this->
template i<2>() = setting;
132 return this->
template i<2>();
137 return this->
template i<2>();
142 return this->
template i<2>();
147 state(!state().
object);
153 this->equation = ::std::bind(
154 &type::triggerFunction,
156 ::std::placeholders::_1
160 void triggerFunction(
Base &b)
163 this->
template o<0>() = this->
template i<1>();
165 this->
template o<0>() = this->
template i<0>();
171 template<
typename TType>
176 directFeedthrough =
true
180 using Base =
typename type::Base;
188 static const ::std::array<::std::string, kIns> inTypes;
189 static const ::std::array<::std::string, kOuts> outTypes;
190 static const ::std::array<::std::string, kPars> parTypes;
192 static const ::std::array<::std::string, 2> templateTypes;
195 template<
typename TType>
197 {demangle(
typeid(TType).name())};
199 template<
typename TType>
200 const ::std::array<::std::string, BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::AdditionalInput>>::kOuts> BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::AdditionalInput>>::outTypes =
201 {demangle(
typeid(TType).name())};
203 template<
typename TType>
204 const ::std::array<::std::string, BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::AdditionalInput>>::kPars> BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::AdditionalInput>>::parTypes =
207 template<
typename TType>
208 const ::std::array<::std::string, 2> BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::AdditionalInput>>::templateTypes =
209 {demangle(
typeid(TType).name()), demangle(
typeid(std::SwitchBlockParameter::AdditionalInput).name())};
211 template<
typename TType>
220 using Base =
typename type::Base;
228 static const ::std::array<::std::string, kIns>
inTypes;
229 static const ::std::array<::std::string, kOuts>
outTypes;
230 static const ::std::array<::std::string, kPars>
parTypes;
235 template<
typename TType>
237 {demangle(
typeid(TType).name())};
239 template<
typename TType>
240 const ::std::array<::std::string, BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::Parametric>>::kOuts> BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::Parametric>>::outTypes =
241 {demangle(
typeid(TType).name())};
243 template<
typename TType>
244 const ::std::array<::std::string, BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::Parametric>>::kPars> BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::Parametric>>::parTypes =
247 template<
typename TType>
248 const ::std::array<::std::string, 2> BlockTraits<std::SwitchBlock<TType, std::SwitchBlockParameter::Parametric>>::templateTypes =
249 {demangle(
typeid(TType).name()), demangle(
typeid(std::SwitchBlockParameter::Parametric).name())};
256 #endif //LODESTAR_SWITCHBLOCK_HPP