--- /dev/null
+// $Id$
+//
+// Copyright (C) 2009
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief Jack inline non-template implementation */
+
+//#include "Jack.ih"
+
+// Custom includes
+#include "Setup.hh"
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+prefix_ senf::ppi::connector::GenericActiveInputJack::
+GenericActiveInputJack(GenericActiveInput & input)
+ : input_ (input)
+{}
+
+prefix_ senf::ppi::connector::GenericActiveInput &
+senf::ppi::connector::GenericActiveInputJack::connector()
+{
+ return input_;
+}
+
+prefix_ senf::ppi::connector::GenericActiveOutputJack::
+GenericActiveOutputJack(GenericActiveOutput & output)
+ : output_ (output)
+{}
+
+prefix_ senf::ppi::connector::GenericActiveOutput &
+senf::ppi::connector::GenericActiveOutputJack::connector()
+{
+ return output_;
+}
+
+prefix_ senf::ppi::connector::GenericPassiveInputJack::
+GenericPassiveInputJack(GenericPassiveInput & input)
+ : input_ (input)
+{}
+
+prefix_ senf::ppi::connector::GenericPassiveInput &
+senf::ppi::connector::GenericPassiveInputJack::connector()
+{
+ return input_;
+}
+
+prefix_ senf::ppi::connector::GenericPassiveOutputJack::
+GenericPassiveOutputJack(GenericPassiveOutput & output)
+ : output_ (output)
+{}
+
+prefix_ senf::ppi::connector::GenericPassiveOutput &
+senf::ppi::connector::GenericPassiveOutputJack::connector()
+{
+ return output_;
+}
+
+prefix_ void senf::ppi::connect(connector::GenericActiveOutputJack & source,
+ connector::GenericPassiveInputJack & target)
+{
+ connect(source.connector(), target.connector());
+}
+
+prefix_ void senf::ppi::connect(connector::GenericPassiveOutputJack & source,
+ connector::GenericActiveInputJack & target)
+{
+ connect(source.connector(), target.connector());
+}
+
+prefix_ void senf::ppi::connect(connector::GenericActiveOutputJack & source,
+ connector::GenericPassiveInput & target)
+{
+ connect(source.connector(), target);
+}
+
+prefix_ void senf::ppi::connect(connector::GenericPassiveOutputJack & source,
+ connector::GenericActiveInput & target)
+{
+ connect(source.connector(), target);
+}
+
+prefix_ void senf::ppi::connect(connector::GenericActiveOutput & source,
+ connector::GenericPassiveInputJack & target)
+{
+ connect(source, target.connector());
+}
+
+prefix_ void senf::ppi::connect(connector::GenericPassiveOutput & source,
+ connector::GenericActiveInputJack & target)
+{
+ connect(source, target.connector());
+}
+
+///////////////////////////////cci.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2009
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief Jack inline template implementation */
+
+//#include "Jack.ih"
+
+// Custom includes
+#include "Setup.hh"
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+template <class PacketType>
+prefix_ senf::ppi::connector::ActiveInputJack<PacketType>::
+ActiveInputJack(ActiveInput<PacketType> & input)
+ : GenericActiveInputJack (input)
+{}
+
+template <class PacketType>
+prefix_
+senf::ppi::connector::ActiveInputJack<PacketType>::ActiveInputJack(ActiveInput<> & input)
+ : GenericActiveInputJack (input)
+{}
+
+prefix_ senf::ppi::connector::ActiveInputJack<senf::Packet>::ActiveInputJack(ActiveInput<> & input)
+ : GenericActiveInputJack (input)
+{}
+
+template <class PacketType>
+prefix_ senf::ppi::connector::ActiveOutputJack<PacketType>::
+ActiveOutputJack(ActiveOutput<PacketType> & output)
+ : GenericActiveOutputJack (output)
+{}
+
+template <class PacketType>
+prefix_
+senf::ppi::connector::ActiveOutputJack<PacketType>::ActiveOutputJack(ActiveOutput<> & output)
+ : GenericActiveOutputJack (output)
+{}
+
+prefix_
+senf::ppi::connector::ActiveOutputJack<senf::Packet>::ActiveOutputJack(ActiveOutput<> & output)
+ : GenericActiveOutputJack (output)
+{}
+
+template <class PacketType>
+prefix_ senf::ppi::connector::PassiveInputJack<PacketType>::
+PassiveInputJack(PassiveInput<PacketType> & input)
+ : GenericPassiveInputJack (input)
+{}
+
+template <class PacketType>
+prefix_
+senf::ppi::connector::PassiveInputJack<PacketType>::PassiveInputJack(PassiveInput<> & input)
+ : GenericPassiveInputJack (input)
+{}
+
+prefix_
+senf::ppi::connector::PassiveInputJack<senf::Packet>::PassiveInputJack(PassiveInput<> & input)
+ : GenericPassiveInputJack (input)
+{}
+
+template <class PacketType>
+prefix_ senf::ppi::connector::PassiveOutputJack<PacketType>::
+PassiveOutputJack(PassiveOutput<PacketType> & output)
+ : GenericPassiveOutputJack (output)
+{}
+
+template <class PacketType>
+prefix_ senf::ppi::connector::PassiveOutputJack<PacketType>::
+PassiveOutputJack(PassiveOutput<> & output)
+ : GenericPassiveOutputJack (output)
+{}
+
+prefix_
+senf::ppi::connector::PassiveOutputJack<senf::Packet>::PassiveOutputJack(PassiveOutput<> & output)
+ : GenericPassiveOutputJack (output)
+{}
+
+template <class T>
+prefix_ void
+senf::ppi::connect(connector::GenericActiveOutputJack & source, T & target,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type *)
+{
+ connect(source.connector(), target);
+}
+
+template <class T>
+prefix_ void
+senf::ppi::connect(connector::GenericPassiveOutputJack & source, T & target,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type *)
+{
+ connect(source.connector(), target);
+}
+
+template <class T>
+prefix_ void
+senf::ppi::connect(T & source, connector::GenericActiveInputJack & target,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type *)
+{
+ connect(source, target.connector());
+}
+
+template <class T>
+prefix_ void
+senf::ppi::connect(T & source, connector::GenericPassiveInputJack & target,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type *)
+{
+ connect(source, target.connector());
+}
+
+///////////////////////////////cti.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2009
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief Jack public header */
+
+#ifndef HH_SENF_PPI_Jack_
+#define HH_SENF_PPI_Jack_ 1
+
+// Custom includes
+#include <boost/utility.hpp>
+#include <boost/type_traits.hpp>
+#include "Connectors.hh"
+
+//#include "Jack.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+namespace connector {
+
+ class Jack
+ : private boost::noncopyable
+ {};
+
+ class GenericActiveInputJack
+ : public Jack
+ {
+ public:
+ explicit GenericActiveInputJack(GenericActiveInput & input);
+
+ GenericActiveInput & connector();
+
+ private:
+ GenericActiveInput & input_;
+ };
+
+ class GenericActiveOutputJack
+ : public Jack
+ {
+ public:
+ explicit GenericActiveOutputJack(GenericActiveOutput & output);
+
+ GenericActiveOutput & connector();
+
+ private:
+ GenericActiveOutput & output_;
+ };
+
+ class GenericPassiveInputJack
+ : public Jack
+ {
+ public:
+ explicit GenericPassiveInputJack(GenericPassiveInput & input);
+
+ GenericPassiveInput & connector();
+
+ private:
+ GenericPassiveInput & input_;
+ };
+
+ class GenericPassiveOutputJack
+ : public Jack
+ {
+ public:
+ explicit GenericPassiveOutputJack(GenericPassiveOutput & output);
+
+ GenericPassiveOutput & connector();
+
+ private:
+ GenericPassiveOutput & output_;
+ };
+
+ template <class PacketType=Packet>
+ class ActiveInputJack
+ : public GenericActiveInputJack
+ {
+ public:
+ explicit ActiveInputJack(ActiveInput<PacketType> & input);
+ explicit ActiveInputJack(ActiveInput<> & input);
+ };
+
+#ifndef DOXYGEN
+
+ template <>
+ class ActiveInputJack<Packet>
+ : public GenericActiveInputJack
+ {
+ public:
+ explicit ActiveInputJack(ActiveInput<> & input);
+ };
+
+#endif
+
+ template <class PacketType=Packet>
+ class ActiveOutputJack
+ : public GenericActiveOutputJack
+ {
+ public:
+ explicit ActiveOutputJack(ActiveOutput<PacketType> & output);
+ explicit ActiveOutputJack(ActiveOutput<> & output);
+ };
+
+#ifndef DOXYGEN
+
+ template <>
+ class ActiveOutputJack<Packet>
+ : public GenericActiveOutputJack
+ {
+ public:
+ explicit ActiveOutputJack(ActiveOutput<> & output);
+ };
+
+#endif
+
+ template <class PacketType=Packet>
+ class PassiveInputJack
+ : public GenericPassiveInputJack
+ {
+ public:
+ explicit PassiveInputJack(PassiveInput<PacketType> & input);
+ explicit PassiveInputJack(PassiveInput<> & input);
+ };
+
+#ifndef DOXYGEN
+
+ template <>
+ class PassiveInputJack<Packet>
+ : public GenericPassiveInputJack
+ {
+ public:
+ explicit PassiveInputJack(PassiveInput<> & input);
+ };
+
+#endif
+
+ template <class PacketType=Packet>
+ class PassiveOutputJack
+ : public GenericPassiveOutputJack
+ {
+ public:
+ explicit PassiveOutputJack(PassiveOutput<PacketType> & output);
+ explicit PassiveOutputJack(PassiveOutput<> & output);
+ };
+
+#ifndef DOXYGEN
+
+ template <>
+ class PassiveOutputJack<Packet>
+ : public GenericPassiveOutputJack
+ {
+ public:
+ explicit PassiveOutputJack(PassiveOutput<> & output);
+ };
+
+#endif
+}
+
+#ifndef DOXYGEN
+
+ template <class T>
+ void connect(connector::GenericActiveOutputJack & source, T & target,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
+ template <class T>
+ void connect(connector::GenericPassiveOutputJack & source, T & target,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
+
+ template <class T>
+ void connect(T & source, connector::GenericActiveInputJack & target,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
+ template <class T>
+ void connect(T & source, connector::GenericPassiveInputJack & target,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type * = 0);
+
+ void connect(connector::GenericActiveOutputJack & source,
+ connector::GenericPassiveInputJack & target);
+ void connect(connector::GenericPassiveOutputJack & source,
+ connector::GenericActiveInputJack & target);
+
+ void connect(connector::GenericActiveOutputJack & source,
+ connector::GenericPassiveInput & target);
+ void connect(connector::GenericPassiveOutputJack & source,
+ connector::GenericActiveInput & target);
+
+ void connect(connector::GenericActiveOutput & source,
+ connector::GenericPassiveInputJack & target);
+ void connect(connector::GenericPassiveOutput & source,
+ connector::GenericActiveInputJack & target);
+
+#endif
+}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+#include "Jack.cci"
+//#include "Jack.ct"
+#include "Jack.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2009
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief Jack.test unit tests */
+
+//#include "Jack.test.hh"
+//#include "Jack.test.ih"
+
+// Custom includes
+#include "PPI.hh"
+
+#include "../Utils/auto_unit_test.hh"
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+namespace {
+
+ class ActiveDummyForward
+ : public senf::ppi::module::Module
+ {
+ SENF_PPI_MODULE(ActiveDummyForward);
+ public:
+ senf::ppi::connector::ActiveInput<> input;
+ senf::ppi::connector::PassiveOutput<> output;
+
+ ActiveDummyForward()
+ { route(input, output); output.onRequest(&ActiveDummyForward::request); }
+
+ private:
+ void request()
+ { output(input()); }
+ };
+
+ class PassiveDummyForward
+ : public senf::ppi::module::Module
+ {
+ SENF_PPI_MODULE(PassiveDummyForward);
+ public:
+ senf::ppi::connector::PassiveInput<> input;
+ senf::ppi::connector::ActiveOutput<> output;
+
+ PassiveDummyForward()
+ { route(input, output); input.onRequest(&PassiveDummyForward::request); }
+
+ private:
+ void request()
+ { output(input()); }
+ };
+
+ class ActiveGroup
+ {
+ public:
+ senf::ppi::connector::ActiveInputJack<> input;
+ senf::ppi::connector::PassiveOutputJack<> output;
+
+ ActiveGroup()
+ : input (forward.input), output (forward.output) {}
+
+ private:
+ ActiveDummyForward forward;
+ };
+
+ class PassiveGroup
+ {
+ public:
+ senf::ppi::connector::PassiveInputJack<> input;
+ senf::ppi::connector::ActiveOutputJack<> output;
+
+ PassiveGroup()
+ : input (forward.input), output (forward.output) {}
+
+ private:
+ PassiveDummyForward forward;
+ };
+
+}
+
+BOOST_AUTO_UNIT_TEST(jacks)
+{
+ {
+ ActiveGroup group;
+ senf::ppi::module::debug::PassiveSource source;
+ senf::ppi::module::debug::ActiveSink sink;
+
+ senf::ppi::connect(source, group);
+ senf::ppi::connect(group, sink);
+
+ senf::ppi::init();
+
+ senf::Packet p (senf::DataPacket::create());
+ source.submit(p);
+
+ BOOST_CHECK(p == sink.request());
+ }
+
+ {
+ PassiveGroup group;
+ senf::ppi::module::debug::ActiveSource source;
+ senf::ppi::module::debug::PassiveSink sink;
+
+ senf::ppi::connect(source, group);
+ senf::ppi::connect(group, sink);
+
+ senf::ppi::init();
+
+ senf::Packet p (senf::DataPacket::create());
+ source.submit(p);
+
+ BOOST_CHECK(p == sink.front());
+ }
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
prefix_ void senf::ppi::
connect(T & source, C & target,
typename boost::disable_if< boost::is_base_of<connector::Connector, T> >::type *,
- typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *)
+ typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >:: type *)
{
connect(source.output, target);
}
prefix_ void senf::ppi::
connect(C & source, T & target,
typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *,
- typename boost::disable_if< boost::is_base_of<connector::Connector,T> >::type *)
+ typename boost::disable_if< boost::is_base_of<connector::Connector,T> >::type *,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >:: type *)
{
connect(source, target.input);
}
prefix_ void senf::ppi::
connect(T1 & source, T2 & target,
typename boost::disable_if< boost::is_base_of<connector::Connector, T1> >::type *,
- typename boost::disable_if< boost::is_base_of<connector::Connector, T2> >::type *)
+ typename boost::disable_if< boost::is_base_of<connector::Connector, T2> >::type *,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T1> >:: type *,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T2> >:: type *)
{
connect(source.output, target.input);
}
template <class T, class C>
void connect(T & source, C & target,
typename boost::disable_if< boost::is_base_of<connector::Connector, T> >::type * = 0,
- typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type * = 0);
+ typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type * = 0,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >:: type * = 0);
template <class C, class T>
void connect(C & source, T & target,
typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type * = 0,
- typename boost::disable_if< boost::is_base_of<connector::Connector,T> >::type * = 0);
+ typename boost::disable_if< boost::is_base_of<connector::Connector,T> >::type * = 0,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T> >:: type * = 0);
template <class T1, class T2>
void connect(T1 & source, T2 & target,
typename boost::disable_if< boost::is_base_of<connector::Connector, T1> >::type * = 0,
- typename boost::disable_if< boost::is_base_of<connector::Connector, T2> >::type * = 0);
+ typename boost::disable_if< boost::is_base_of<connector::Connector, T2> >::type * = 0,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T1> >:: type * = 0,
+ typename boost::disable_if< boost::is_base_of<connector::Jack, T2> >:: type * = 0);
#endif
template <class PacketType=Packet> class ActiveInput;
template <class PacketType=Packet> class ActiveOutput;
+ class Jack;
+
#ifndef DOXYGEN
namespace detail {