7 #include <ChimeraTK/NDRegisterAccessor.h>
16 template<
typename UserType>
18 std::list<std::pair<boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>>,
VariableNetworkNode>>;
26 virtual void removeSlave(
const boost::shared_ptr<ChimeraTK::TransferElement>& slave) = 0;
41 template<
typename UserType>
42 class FanOut :
public FanOutBase {
44 explicit FanOut(boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>> feedingImpl)
45 :
_impl(std::move(feedingImpl)) {}
53 void removeSlave(
const boost::shared_ptr<ChimeraTK::TransferElement>& slave)
override;
59 boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>>
_impl;
61 std::list<boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>>>
_slaves;
67 template<
typename UserType>
70 if(!slave->isWriteable()) {
71 throw ChimeraTK::logic_error(
"FanOut::addSlave() has been called with a "
72 "receiving implementation!");
76 if(slave->getNumberOfSamples() != 0 &&
77 (slave->getNumberOfChannels() != _impl->getNumberOfChannels() ||
78 slave->getNumberOfSamples() != _impl->getNumberOfSamples())) {
79 std::string what =
"FanOut::addSlave(): Trying to add a slave '";
80 what += slave->getName();
81 what +=
"' with incompatible array shape! Name of master: ";
82 what += _impl->getName();
83 what +=
" Length of master: " + std::to_string(_impl->getNumberOfChannels()) +
" x " +
84 std::to_string(_impl->getNumberOfSamples());
85 what +=
" Length of slave: " + std::to_string(slave->getNumberOfChannels()) +
" x " +
86 std::to_string(slave->getNumberOfSamples());
87 throw ChimeraTK::logic_error(what);
89 _slaves.push_back(slave);
94 template<
typename UserType>
97 boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>> slave_typed;
98 for(
auto& s : _slaves) {
104 assert(slave_typed !=
nullptr);
106 [[maybe_unused]]
size_t nOld = _slaves.size();
107 _slaves.remove(slave_typed);
108 assert(_slaves.size() == nOld - 1);
113 template<
typename UserType>
118 for(
auto& slave : _slaves) {