prefix_ senf::ppi::connector::GenericActiveInputJack::
GenericActiveInputJack(GenericActiveInput & input)
- : input_ (input)
+ : input_ (&input)
{}
prefix_ senf::ppi::connector::GenericActiveInput &
senf::ppi::connector::GenericActiveInputJack::connector()
{
- return input_;
+ return *input_;
+}
+
+prefix_ void senf::ppi::connector::GenericActiveInputJack::reset(GenericActiveInput & input)
+{
+ if (input_->connected()) {
+ GenericPassiveOutput & peer (input_->peer());
+ input_->disconnect();
+ connect(peer, input);
+ }
+ input_ = & input;
}
prefix_ senf::ppi::connector::GenericActiveOutputJack::
GenericActiveOutputJack(GenericActiveOutput & output)
- : output_ (output)
+ : output_ (&output)
{}
prefix_ senf::ppi::connector::GenericActiveOutput &
senf::ppi::connector::GenericActiveOutputJack::connector()
{
- return output_;
+ return *output_;
+}
+
+prefix_ void senf::ppi::connector::GenericActiveOutputJack::reset(GenericActiveOutput & output)
+{
+ if (output_->connected()) {
+ GenericPassiveInput & peer (output_->peer());
+ output_->disconnect();
+ connect(output, peer);
+ }
+ output_ = & output;
}
prefix_ senf::ppi::connector::GenericPassiveInputJack::
GenericPassiveInputJack(GenericPassiveInput & input)
- : input_ (input)
+ : input_ (&input)
{}
prefix_ senf::ppi::connector::GenericPassiveInput &
senf::ppi::connector::GenericPassiveInputJack::connector()
{
- return input_;
+ return *input_;
+}
+
+prefix_ void senf::ppi::connector::GenericPassiveInputJack::reset(GenericPassiveInput & input)
+{
+ if (input_->connected()) {
+ GenericActiveOutput & peer (input_->peer());
+ input_->disconnect();
+ connect(peer, input);
+ }
+ input_ = & input;
}
prefix_ senf::ppi::connector::GenericPassiveOutputJack::
GenericPassiveOutputJack(GenericPassiveOutput & output)
- : output_ (output)
+ : output_ (&output)
{}
prefix_ senf::ppi::connector::GenericPassiveOutput &
senf::ppi::connector::GenericPassiveOutputJack::connector()
{
- return output_;
+ return *output_;
+}
+
+prefix_ void
+senf::ppi::connector::GenericPassiveOutputJack::reset(GenericPassiveOutput & output)
+{
+ if (output_->connected()) {
+ GenericActiveInput & peer (output_->peer());
+ output_->disconnect();
+ connect(output, peer);
+ }
+ output_ = & output;
}
prefix_ senf::ppi::connector::ActiveInputJack<senf::Packet>::
: GenericActiveInputJack (input.connector())
{}
+prefix_ void senf::ppi::connector::ActiveInputJack<senf::Packet>::reset(GenericActiveInput & input)
+{
+ GenericActiveInputJack::reset(input);
+}
+
+prefix_ void senf::ppi::connector::ActiveInputJack<senf::Packet>::reset(GenericActiveInputJack input)
+{
+ GenericActiveInputJack::reset(input.connector());
+}
+
prefix_ senf::ppi::connector::ActiveOutputJack<senf::Packet>::
ActiveOutputJack(GenericActiveOutput & output)
: GenericActiveOutputJack (output)
: GenericActiveOutputJack (output.connector())
{}
+prefix_ void senf::ppi::connector::ActiveOutputJack<senf::Packet>::reset(GenericActiveOutput & output)
+{
+ GenericActiveOutputJack::reset(output);
+}
+
+prefix_ void
+senf::ppi::connector::ActiveOutputJack<senf::Packet>::reset(GenericActiveOutputJack & output)
+{
+ GenericActiveOutputJack::reset(output.connector());
+}
+
prefix_ senf::ppi::connector::PassiveInputJack<senf::Packet>::
PassiveInputJack(GenericPassiveInput & input)
: GenericPassiveInputJack (input)
: GenericPassiveInputJack (input.connector())
{}
+prefix_ void senf::ppi::connector::PassiveInputJack<senf::Packet>::reset(GenericPassiveInput & input)
+{
+ GenericPassiveInputJack::reset(input);
+}
+
+prefix_ void
+senf::ppi::connector::PassiveInputJack<senf::Packet>::reset(GenericPassiveInputJack & input)
+{
+ GenericPassiveInputJack::reset(input.connector());
+}
+
prefix_ senf::ppi::connector::PassiveOutputJack<senf::Packet>::
PassiveOutputJack(GenericPassiveOutput & output)
: GenericPassiveOutputJack (output)
: GenericPassiveOutputJack (output.connector())
{}
+prefix_ void
+senf::ppi::connector::PassiveOutputJack<senf::Packet>::reset(GenericPassiveOutput & output)
+{
+ GenericPassiveOutputJack::reset(output);
+}
+
+prefix_ void
+senf::ppi::connector::PassiveOutputJack<senf::Packet>::reset(GenericPassiveOutputJack & output)
+{
+ GenericPassiveOutputJack::reset(output.connector());
+}
+
prefix_ void senf::ppi::connect(connector::GenericActiveOutputJack & source,
connector::GenericPassiveInputJack & target)
{
{}
template <class PacketType>
+prefix_ void
+senf::ppi::connector::ActiveInputJack<PacketType>::reset(ActiveInput<PacketType> & input)
+{
+ GenericActiveInputJack::reset(input);
+}
+
+template <class PacketType>
+prefix_ void senf::ppi::connector::ActiveInputJack<PacketType>::reset(ActiveInput<> & input)
+{
+ GenericActiveInputJack::reset(input);
+}
+
+template <class PacketType>
+prefix_ void senf::ppi::connector::ActiveInputJack<PacketType>::reset(ActiveInputJack & input)
+{
+ GenericActiveInputJack::reset(input);
+}
+
+template <class PacketType>
+prefix_ void senf::ppi::connector::ActiveInputJack<PacketType>::reset(ActiveInputJack<> & input)
+{
+ GenericActiveInputJack::reset(input);
+}
+
+template <class PacketType>
prefix_ senf::ppi::connector::ActiveOutputJack<PacketType>::
ActiveOutputJack(ActiveOutput<PacketType> & output)
: GenericActiveOutputJack (output)
{}
template <class PacketType>
+prefix_ void
+senf::ppi::connector::ActiveOutputJack<PacketType>::reset(ActiveOutput<PacketType> & output)
+{
+ GenericActiveOutputJack::reset(output);
+}
+
+template <class PacketType>
+prefix_ void senf::ppi::connector::ActiveOutputJack<PacketType>::reset(ActiveOutput<> & output)
+{
+ GenericActiveOutputJack::reset(output);
+}
+
+template <class PacketType>
+prefix_ void
+senf::ppi::connector::ActiveOutputJack<PacketType>::reset(ActiveOutputJack & output)
+{
+ GenericActiveOutputJack::reset(output);
+}
+
+template <class PacketType>
+prefix_ void
+senf::ppi::connector::ActiveOutputJack<PacketType>::reset(ActiveOutputJack<> & output)
+{
+ GenericActiveOutputJack::reset(output);
+}
+
+template <class PacketType>
prefix_ senf::ppi::connector::PassiveInputJack<PacketType>::
PassiveInputJack(PassiveInput<PacketType> & input)
: GenericPassiveInputJack (input)
{}
template <class PacketType>
+prefix_ void
+senf::ppi::connector::PassiveInputJack<PacketType>::reset(PassiveInput<PacketType> & input)
+{
+ GenericPassiveInputJack::reset(input);
+}
+
+template <class PacketType>
+prefix_ void senf::ppi::connector::PassiveInputJack<PacketType>::reset(PassiveInput<> & input)
+{
+ GenericPassiveInputJack::reset(input);
+}
+
+template <class PacketType>
+prefix_ void senf::ppi::connector::PassiveInputJack<PacketType>::reset(PassiveInputJack & input)
+{
+ GenericPassiveInputJack::reset(input);
+}
+
+template <class PacketType>
+prefix_ void
+senf::ppi::connector::PassiveInputJack<PacketType>::reset(PassiveInputJack<> & input)
+{
+ GenericPassiveInputJack::reset(input);
+}
+
+template <class PacketType>
prefix_ senf::ppi::connector::PassiveOutputJack<PacketType>::
PassiveOutputJack(PassiveOutput<PacketType> & output)
: GenericPassiveOutputJack (output)
: GenericPassiveOutputJack (output.connector())
{}
+template <class PacketType>
+prefix_ void
+senf::ppi::connector::PassiveOutputJack<PacketType>::reset(PassiveOutput<PacketType> & output)
+{
+ GenericPassiveOutputJack::reset(output);
+}
+
+template <class PacketType>
+prefix_ void
+senf::ppi::connector::PassiveOutputJack<PacketType>::reset(PassiveOutput<> & output)
+{
+ GenericPassiveOutputJack::reset(output);
+}
+
+template <class PacketType>
+prefix_ void
+senf::ppi::connector::PassiveOutputJack<PacketType>::reset(PassiveOutputJack & output)
+{
+ GenericPassiveOutputJack::reset(output);
+}
+
+template <class PacketType>
+prefix_ void
+senf::ppi::connector::PassiveOutputJack<PacketType>::reset(PassiveOutputJack<> & output)
+{
+ GenericPassiveOutputJack::reset(output);
+}
+
template <class T>
prefix_ void
senf::ppi::connect(connector::GenericActiveOutputJack & source, T & target,
GenericActiveInput & connector(); ///< Get referenced connector
+ void reset(GenericActiveInput & input); ///< Change connector
+ /**< Will update any existing connection accordingly */
+
private:
- GenericActiveInput & input_;
+ GenericActiveInput * input_;
};
/** \brief Jack referencing an ActiveOutput
GenericActiveOutput & connector(); ///< Get referenced connector
+ void reset(GenericActiveOutput & output); ///< Change connector
+ /**< Will update any existing connection accordingly */
+
private:
- GenericActiveOutput & output_;
+ GenericActiveOutput * output_;
};
/** \brief Jack referencing a PassiveInput
GenericPassiveInput & connector(); ///< Get referenced connector
+ void reset(GenericPassiveInput & input); ///< Change connector
+ /**< Will update any existing connection accordingly */
+
private:
- GenericPassiveInput & input_;
+ GenericPassiveInput * input_;
};
/** \brief Jack referencing a PassiveOutput
GenericPassiveOutput & connector(); ///< Get referenced connector
+ void reset(GenericPassiveOutput & output); ///< Change connector
+ /**< Will update any existing connection accordingly */
+
private:
- GenericPassiveOutput & output_;
+ GenericPassiveOutput * output_;
};
/** \brief Jack with packet type referencing an ActiveInput
explicit ActiveInputJack(ActiveInputJack & input);
explicit ActiveInputJack(ActiveInputJack<> & input);
+
+ void reset(ActiveInput<PacketType> & input);
+ void reset(ActiveInput<> & input);
+
+ void reset(ActiveInputJack & input);
+ void reset(ActiveInputJack<> & input);
};
#ifndef DOXYGEN
public:
explicit ActiveInputJack(GenericActiveInput & input);
explicit ActiveInputJack(GenericActiveInputJack input);
+
+ void reset(GenericActiveInput & input);
+ void reset(GenericActiveInputJack input);
};
#endif
explicit ActiveOutputJack(ActiveOutputJack & output);
explicit ActiveOutputJack(ActiveOutputJack<> & output);
+
+ void reset(ActiveOutput<PacketType> & output);
+ void reset(ActiveOutput<> & output);
+
+ void reset(ActiveOutputJack & output);
+ void reset(ActiveOutputJack<> & output);
};
#ifndef DOXYGEN
public:
explicit ActiveOutputJack(GenericActiveOutput & output);
explicit ActiveOutputJack(GenericActiveOutputJack & output);
+
+ void reset(GenericActiveOutput & output);
+ void reset(GenericActiveOutputJack & output);
};
#endif
explicit PassiveInputJack(PassiveInputJack & input);
explicit PassiveInputJack(PassiveInputJack<> & input);
+
+ void reset(PassiveInput<PacketType> & input);
+ void reset(PassiveInput<> & input);
+
+ void reset(PassiveInputJack & input);
+ void reset(PassiveInputJack<> & input);
};
#ifndef DOXYGEN
public:
explicit PassiveInputJack(GenericPassiveInput & input);
explicit PassiveInputJack(GenericPassiveInputJack & input);
+
+ void reset(GenericPassiveInput & input);
+ void reset(GenericPassiveInputJack & input);
};
#endif
explicit PassiveOutputJack(PassiveOutputJack & output);
explicit PassiveOutputJack(PassiveOutputJack<> & output);
+
+ void reset(PassiveOutput<PacketType> & output);
+ void reset(PassiveOutput<> & output);
+
+ void reset(PassiveOutputJack & output);
+ void reset(PassiveOutputJack<> & output);
};
#ifndef DOXYGEN
public:
explicit PassiveOutputJack(GenericPassiveOutput & output);
explicit PassiveOutputJack(GenericPassiveOutputJack & output);
+
+ void reset(GenericPassiveOutput & output);
+ void reset(GenericPassiveOutputJack & output);
};
#endif
senf::ppi::connector::ActiveInput<> input;
senf::ppi::connector::PassiveOutput<> output;
- ActiveDummyForward()
+ ActiveDummyForward() : n (0)
{ route(input, output); output.onRequest(&ActiveDummyForward::request); }
+ unsigned n;
+
private:
void request()
- { output(input()); }
+ { ++n; output(input()); }
};
class PassiveDummyForward
senf::ppi::connector::PassiveInput<> input;
senf::ppi::connector::ActiveOutput<> output;
- PassiveDummyForward()
+ PassiveDummyForward() : n (0)
{ route(input, output); input.onRequest(&PassiveDummyForward::request); }
+ unsigned n;
+
private:
void request()
- { output(input()); }
+ { ++n; output(input()); }
};
- class ActiveGroup
+ struct ActiveGroup
{
- public:
senf::ppi::connector::ActiveInputJack<> input;
senf::ppi::connector::PassiveOutputJack<> output;
ActiveGroup()
- : input (forward.input), output (forward.output) {}
+ : input (forward1.input), output (forward1.output) {}
- private:
- ActiveDummyForward forward;
+ void flip()
+ {
+ input.reset(forward2.input);
+ output.reset(forward2.output);
+ }
+
+ ActiveDummyForward forward1;
+ ActiveDummyForward forward2;
};
- class PassiveGroup
+ struct PassiveGroup
{
- public:
senf::ppi::connector::PassiveInputJack<> input;
senf::ppi::connector::ActiveOutputJack<> output;
PassiveGroup()
- : input (forward.input), output (forward.output) {}
+ : input (forward1.input), output (forward1.output) {}
- private:
- PassiveDummyForward forward;
+ void flip()
+ {
+ input.reset(forward2.input);
+ output.reset(forward2.output);
+ }
+
+ PassiveDummyForward forward1;
+ PassiveDummyForward forward2;
};
}
senf::ppi::init();
- senf::Packet p (senf::DataPacket::create());
- source.submit(p);
+ {
+ senf::Packet p (senf::DataPacket::create());
+ source.submit(p);
+
+ BOOST_CHECK(p == sink.request());
+ }
+
+ group.flip();
+ senf::ppi::init();
- BOOST_CHECK(p == sink.request());
+ {
+ senf::Packet p (senf::DataPacket::create());
+ source.submit(p);
+
+ BOOST_CHECK(p == sink.request());
+ }
+
+ BOOST_CHECK_EQUAL( group.forward1.n, 1u );
+ BOOST_CHECK_EQUAL( group.forward2.n, 1u );
}
{
senf::ppi::init();
- senf::Packet p (senf::DataPacket::create());
- source.submit(p);
+ {
+ senf::Packet p (senf::DataPacket::create());
+ source.submit(p);
+
+ BOOST_CHECK(p == sink.pop_front());
+ }
+
+ group.flip();
+ senf::ppi::init();
+
+ {
+ senf::Packet p (senf::DataPacket::create());
+ source.submit(p);
+
+ BOOST_CHECK(p == sink.pop_front());
+ }
- BOOST_CHECK(p == sink.front());
+ BOOST_CHECK_EQUAL( group.forward1.n, 1u );
+ BOOST_CHECK_EQUAL( group.forward2.n, 1u );
}
}