--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Connectors non-inline non-template implementation */
+
+#include "Connectors.hh"
+//#include "Connectors.ih"
+
+// Custom includes
+
+//#include "Connectors.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::connector::Connector::~Connector()
+{}
+
+prefix_ void senf::ppi::connector::Connector::connect(Connector & target)
+{
+ peer_ = & target;
+ target.peer_ = this;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::InputConnector
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::ppi::connector::InputConnector::v_enqueueEvent()
+{}
+
+prefix_ void senf::ppi::connector::InputConnector::v_dequeueEvent()
+{}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::PassiveInput
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::ppi::connector::PassiveInput::v_enqueueEvent()
+{
+ ///\fixme Emit notifications when qstate_ changes
+ qstate_ = qdisc_->update(*this, QueueingDiscipline::ENQUEUE);
+ emit();
+}
+
+prefix_ void senf::ppi::connector::PassiveInput::v_dequeueEvent()
+{
+ ///\fixme Emit notifications when qstate_ changes
+ qstate_ = qdisc_->update(*this, QueueingDiscipline::DEQUEUE);
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "Connectors.mpp"
+
+\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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Connectors inline non-template implementation */
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::Connector
+
+prefix_ senf::ppi::connector::Connector & senf::ppi::connector::Connector::peer()
+{
+ BOOST_ASSERT(peer_);
+ return *peer_;
+}
+
+prefix_ senf::ppi::module::Module & senf::ppi::connector::Connector::module()
+{
+ BOOST_ASSERT(module_);
+ return *module_;
+}
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::connector::Connector::Connector()
+ : peer_(), module_()
+{}
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::ppi::connector::Connector::setModule(module::Module & module)
+{
+ module_ = &module;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::ActiveConnector
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::connector::ActiveConnector::ActiveConnector()
+{}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::PassiveConnector
+
+prefix_ senf::ppi::connector::ActiveConnector & senf::ppi::connector::PassiveConnector::peer()
+{
+ return dynamic_cast<ActiveConnector&>(Connector::peer());
+}
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::connector::PassiveConnector::PassiveConnector()
+ : callback_()
+{}
+
+prefix_ void senf::ppi::connector::PassiveConnector::emit()
+{
+ BOOST_ASSERT(callback_);
+ callback_();
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::InputConnector
+
+prefix_ senf::Packet senf::ppi::connector::InputConnector::operator()()
+{
+ Packet p (queue_.back());
+ queue_.pop_back();
+ v_dequeueEvent();
+ return p;
+}
+
+prefix_ bool senf::ppi::connector::InputConnector::boolean_test()
+{
+ ///\fixme Add additional active/passive throttle/unthrottle conditions (make virtual ?)
+ return ! empty();
+}
+
+prefix_ senf::ppi::connector::OutputConnector & senf::ppi::connector::InputConnector::peer()
+{
+ return dynamic_cast<OutputConnector &>(Connector::peer());
+}
+
+prefix_ senf::ppi::connector::InputConnector::queue_iterator
+senf::ppi::connector::InputConnector::begin()
+{
+ return queue_.begin();
+}
+
+prefix_ senf::ppi::connector::InputConnector::queue_iterator
+senf::ppi::connector::InputConnector::end()
+{
+ return queue_.end();
+}
+
+prefix_ senf::Packet senf::ppi::connector::InputConnector::peek()
+{
+ return queue_.back();
+}
+
+prefix_ senf::ppi::connector::InputConnector::size_type
+senf::ppi::connector::InputConnector::queueSize()
+{
+ return queue_.size();
+}
+
+prefix_ bool senf::ppi::connector::InputConnector::empty()
+{
+ return queue_.empty();
+}
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::connector::InputConnector::InputConnector()
+{}
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::ppi::connector::InputConnector::enqueue(Packet p)
+{
+ queue_.push_front(p);
+ v_enqueueEvent();
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::OutputConnector
+
+prefix_ void senf::ppi::connector::OutputConnector::operator()(Packet p)
+{
+ peer().enqueue(p);
+}
+
+prefix_ senf::ppi::connector::InputConnector & senf::ppi::connector::OutputConnector::peer()
+{
+ return dynamic_cast<InputConnector&>(Connector::peer());
+}
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::connector::OutputConnector::OutputConnector()
+{}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::PassiveInput
+
+prefix_ senf::ppi::connector::PassiveInput::PassiveInput()
+ : qdisc_(), qstate_(QueueingDiscipline::UNTHROTTLED)
+{}
+
+prefix_ senf::ppi::connector::ActiveOutput & senf::ppi::connector::PassiveInput::peer()
+{
+ return dynamic_cast<ActiveOutput&>(Connector::peer());
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::ActiveOutput
+
+prefix_ senf::ppi::connector::ActiveInput & senf::ppi::connector::ActiveOutput::peer()
+{
+ return dynamic_cast<ActiveInput&>(Connector::peer());
+}
+
+prefix_ void senf::ppi::connector::ActiveOutput::connect(PassiveInput & target)
+{
+ Connector::connect(target);
+}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Connectors inline template implementation */
+
+//#include "Connectors.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::PassiveConnector
+
+template <class Handler>
+prefix_ void senf::ppi::connector::PassiveConnector::onRequest(Handler handler)
+{
+ callback_ = detail::Callback<>::make(handler, module());
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::connector::PassiveInput
+
+template <class QDisc>
+prefix_ void senf::ppi::connector::PassiveInput::qdisc(QDisc const & disc)
+{
+ qdisc_ = boost::scoped_ptr<QueueingDiscipline>(new QDisc(disc));
+}
+
+///////////////////////////////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:
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief Conenctors public header */
+ \brief Connectors public header */
/** \defgroup connectors Connector classes
senf::ppi::PassiveInput and senf::ppi::PassiveOutput.
*/
-#ifndef HH_Conenctors_
-#define HH_Conenctors_ 1
+#ifndef HH_Connectors_
+#define HH_Connectors_ 1
// Custom includes
+#include <deque>
#include <boost/utility.hpp>
-
-//#include "Conenctors.mpp"
+#include <boost/scoped_ptr.hpp>
+#include "Utils/SafeBool.hh"
+#include "Packets/Packets.hh"
+#include "predecl.hh"
+#include "detail/Callback.hh"
+#include "Queueing.hh"
+
+//#include "Connectors.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
{
public:
Connector & peer(); ///< Get peer connected to this connector
- Module & module(); ///< Get this connectors containing module
+ module::Module & module(); ///< Get this connectors containing module
protected:
- // here to protect
Connector();
- ~Connector();
+ virtual ~Connector();
+
+ void connect(Connector & target);
+
+ private:
+ void setModule(module::Module & module);
+
+ Connector * peer_;
+ module::Module * module_;
+
+ friend class module::Module;
};
/** \brief Passive connector baseclass
ActiveConnector & peer();
protected:
- // here to protect
PassiveConnector();
- ~PassiveConnector();
+
+ void emit();
+
+ private:
+
+ typedef detail::Callback<>::type Callback;
+ Callback callback_;
};
/** \brief Active connector baseclass
PassiveConnector & peer();
protected:
- // here to protect
- PassiveConnector();
- ~PassiveConnector();
+ ActiveConnector();
};
/** \brief Input connector baseclass
be added to the queue before it can be processed.
*/
class InputConnector
- : public virtual Connector
+ : public virtual Connector,
+ public SafeBool<InputConnector>
{
+ typedef std::deque<Packet> Queue;
public:
- typedef unspecified queue_iterator; ///< Iterator type of the embedded queue
- typedef unspecified size_type; ///< Unsigned type representing the number of queue elements
+ typedef Queue::const_iterator queue_iterator; ///< Iterator type of the embedded queue
+ typedef Queue::size_type size_type; ///< Unsigned type for counting queue elements
- Packet::ptr operator(); ///< Get a packet
+ Packet operator()(); ///< Get a packet
/**< This member is the primary method to access received
data. On passive connectors, this operator will just
dequeue a packet from the packet queue. If the
request cannot be fulfilled, this is considered to be a
logic error in the module implementation and an
exception is raised. */
- operator unspecified_boolean_type (); ///< Check packet availability
+ bool boolean_test (); ///< Check packet availability
/**< Using any input connector in a boolean context will
check, whether an input request can be fulfilled. This
is always possible if the queue is non-empty. If the
\returns \c true if operator() can be called, \c false
otherwise */
- operator ! (); ///< Check packet availability
- /**< Inverse of the boolean conversion operator
- \returns \c false if operator() can be called, \c true
- otherwise */
OutputConnector & peer();
queue_iterator begin(); ///< Access queue begin (head)
queue_iterator end(); ///< Access queue past-the-end (tail)
- Packet::ptr head(); ///< Return head element from the queue
+ Packet peek(); ///< Return head element from the queue
size_type queueSize(); ///< Return number of elements in the queue
bool empty(); ///< Return queueSize() == 0
protected:
- // here to protect
- PassiveConnector();
- ~PassiveConnector();
+ InputConnector();
+
+ private:
+ void enqueue(Packet p);
+
+ virtual void v_enqueueEvent();
+ virtual void v_dequeueEvent();
+
+ Queue queue_;
+
+ friend class OutputConnector;
};
/** \brief Output connector baseclass
: public virtual Connector
{
public:
- void operator(Packet::ptr); ///< Send out a packet
+ void operator()(Packet p); ///< Send out a packet
InputConnector & peer();
protected:
- // here to protect
- PassiveConnector();
- ~PassiveConnector();
+ OutputConnector();
};
///@{
: public PassiveConnector, public InputConnector
{
public:
+ PassiveInput();
+
ActiveOutput & peer();
- template <class QueueingDiscipline>
- void qdisc(QueueingDiscipline const & disc); ///< Change the queueing discipline
+ template <class QDisc>
+ void qdisc(QDisc const & disc); ///< Change the queueing discipline
/**< The queueing discipline is a class which provides the
QueueingDiscipline interface.
\param[in] disc New queueing discipline */
+
+ private:
+ void v_enqueueEvent();
+ void v_dequeueEvent();
+
+ boost::scoped_ptr<QueueingDiscipline> qdisc_;
+ QueueingDiscipline::State qstate_;
};
/** \brief Combination of PassiveConnector and OutputConnector
{
public:
ActiveInput & peer();
+
+ void connect(ActiveInput & target);
};
/** \brief Combination of ActiveConnector and InputConnector
{
public:
ActiveInput & peer();
+
+ void connect(PassiveInput & target);
};
///@}
}}}
///////////////////////////////hh.e////////////////////////////////////////
-//#include "Conenctors.cci"
-//#include "Conenctors.ct"
-//#include "Conenctors.cti"
+#include "Connectors.cci"
+//#include "Connectors.ct"
+#include "Connectors.cti"
#endif
\f
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Connectors.test unit tests */
+
+//#include "Connectors.test.hh"
+//#include "Connectors.test.ih"
+
+// Custom includes
+#include "Connectors.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(connectors)
+{}
+
+///////////////////////////////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:
PROJECT_NAME = libPPI
GENERATE_TAGFILE = doc/ppi.tag
+RECURSIVE = Yes
+SHOW_DIRECTORIES = Yes
TAGFILES = "$(TOPDIR)/Packets/doc/Packets.tag" "$(TOPDIR)/Socket/doc/Socket.tag"
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 EventManager inline non-template implementation */
+
+//#include "EventManager.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::EventManager
+
+prefix_ senf::ppi::EventManager & senf::ppi::EventManager::instance()
+{
+ static EventManager manager;
+ return manager;
+}
+
+prefix_ boost::posix_time::ptime senf::ppi::EventManager::eventTime()
+{
+ return eventTime_;
+}
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::ppi::EventManager::eventTime(boost::posix_time::ptime time)
+{
+ eventTime_ = time;
+}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 EventManager non-inline template implementation */
+
+//#include "EventManager.ih"
+
+// Custom includes
+#include <boost/ptr_container/ptr_vector.hpp>
+
+#define prefix_
+///////////////////////////////ct.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::EventManager
+
+template <class Descriptor>
+prefix_ void
+senf::ppi::EventManager::registerEvent(module::Module & module,
+ typename Callback<Descriptor>::type callback,
+ Descriptor & descriptor)
+{
+ registrations_.push_back(
+ new detail::EventBinding<typename Descriptor::Event>(*this, module, callback, descriptor));
+ descriptor.setBinding(
+ static_cast< detail::EventBinding<typename Descriptor::Event> & >(registrations_.back()));
+}
+
+///////////////////////////////ct.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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 EventManager public header */
+
+#ifndef HH_EventManager_
+#define HH_EventManager_ 1
+
+// Custom includes
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include "predecl.hh"
+#include "detail/Callback.hh"
+#include "detail/EventBinding.hh"
+
+//#include "EventManager.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+
+ /** \brief
+ */
+ class EventManager
+ {
+ public:
+ ///////////////////////////////////////////////////////////////////////////
+ // Types
+
+ template <class Descriptor>
+#ifndef DOXYGEN
+ struct Callback
+#else
+ // This is SO stupid but doxygen must have some scoping problems if the
+ // struct is called 'Callback' and will hang in an endless loop somewhere
+ struct Callback_
+#endif
+ : public detail::Callback<typename Descriptor::Event const &>
+ {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ ///\name Structors and default members
+ ///@{
+
+ static EventManager & instance();
+
+ // default default constructor
+ // default copy constructor
+ // default copy assignment
+ // default destructor
+
+ // no conversion constructors
+
+ ///@}
+ ///////////////////////////////////////////////////////////////////////////
+
+ template <class Descriptor>
+ void registerEvent(module::Module & module,
+ typename Callback<Descriptor>::type callback,
+ Descriptor & descriptor);
+
+ boost::posix_time::ptime eventTime();
+
+ protected:
+
+ private:
+ typedef boost::ptr_vector<detail::EventBindingBase> EventRegistrations;
+ EventRegistrations registrations_;
+
+ void eventTime(boost::posix_time::ptime time);
+
+ boost::posix_time::ptime eventTime_;
+
+ friend class detail::EventBindingBase;
+ };
+
+}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+#include "EventManager.cci"
+#include "EventManager.ct"
+//#include "EventManager.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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 EventManager.test unit tests */
+
+//#include "EventManager.test.hh"
+//#include "EventManager.test.ih"
+
+// Custom includes
+#include "EventManager.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(eventManager)
+{}
+
+///////////////////////////////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:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Events inline non-template implementation */
+
+// Custom includes
+#include <boost/assert.hpp>
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::EventDescriptor
+
+prefix_ senf::ppi::EventDescriptor::~EventDescriptor()
+{}
+
+prefix_ bool senf::ppi::EventDescriptor::enabled()
+{
+ return enabled_;
+}
+
+prefix_ void senf::ppi::EventDescriptor::enabled(bool v)
+{
+ BOOST_ASSERT(v_isRegistered());
+ if (v && ! enabled_)
+ v_enable();
+ else if (! v && enabled_)
+ v_disable();
+ enabled_ = v;
+}
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::EventDescriptor::EventDescriptor()
+ : enabled_(false)
+{}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Events inline template implementation */
+
+#include "Events.ih"
+
+// Custom includes
+#include "detail/EventBinding.hh"
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::EventImplementation<EventType>
+
+////////////////////////////////////////
+// protected members
+
+template <class EventType>
+prefix_ senf::ppi::EventImplementation<EventType>::EventImplementation()
+ : binding_(0)
+{}
+
+template <class EventType>
+prefix_ void senf::ppi::EventImplementation<EventType>::callback(EventArg event,
+ boost::posix_time::ptime time)
+{
+ BOOST_ASSERT(binding_);
+ binding_->callback(event,time);
+}
+
+template <class EventType>
+prefix_ void senf::ppi::EventImplementation<EventType>::callback(EventArg event)
+{
+ BOOST_ASSERT(binding_);
+ binding_->callback(event);
+}
+
+////////////////////////////////////////
+// private members
+
+template <class EventType>
+prefix_ bool senf::ppi::EventImplementation<EventType>::v_isRegistered()
+{
+ return binding_;
+}
+
+template <class EventType>
+prefix_ void
+senf::ppi::EventImplementation<EventType>::setBinding(detail::EventBinding<Event> & binding)
+{
+ binding_ = & binding;
+}
+
+///////////////////////////////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:
#define HH_Events_ 1
// Custom includes
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include "predecl.hh"
//#include "Events.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
namespace ppi {
+ // Implementation: The concrete EventDescriptor implementation will need to set things up so
+ // some callback (within the EventDescriptor implementation) will be called when the event
+ // happens. This setup happens in 'v_enable()'. This internal handler sets up an EventType
+ // instance if needed and calls 'callback()'.
+ //
+ // 'callback()' will access the EventBinding wrapper to find the user-callback to signal. It
+ // will do any needed internal processing, call that user callback and clean up afterwards.
+
/** \brief Generic event interface baseclass
The EventDescriptor baseclass provides an interface to manipulate events in a generic
class EventDescriptor
{
public:
+ virtual ~EventDescriptor();
+
bool enabled(); ///< Check, whether the event is currently enabled
- void enabled(bool); ///< Enable or disable the event
+ void enabled(bool v); ///< Enable or disable the event
protected:
- typedef unspecified CallbackType; ///< Fixed type of the (internal) event handler.
-
- void register(CallbackType handler); ///< Register the event
- void unregister(); ///< Unregister the event
+ EventDescriptor();
private:
- virtual void v_register(CallbackType handler) = 0; ///< Called to register the event
- virtual void v_unregister() = 0; ///< Called to unregister the event
virtual void v_enable() = 0; ///< Called to enable the event delivery
virtual void v_disable() = 0; ///< Called to disable the event delivery
- virtual void v_process() = 0; ///< Called whenever the event is signaled
- /**< This virtual method is called \e after every call to
- the event handler to provide a hook for further
- processing (example: calculate the next time, an
- interval timer expires) */
+
+ virtual bool v_isRegistered() = 0;
bool enabled_;
};
+ template <class EventType>
+ class EventImplementation
+ : public EventDescriptor
+ {
+ public:
+ typedef EventType Event;
+ typedef typename detail::EventArgType<EventType>::type EventArg;
+
+ protected:
+ EventImplementation();
+
+ void callback(EventArg event, boost::posix_time::ptime time);
+ void callback(EventArg event);
+
+ private:
+ virtual bool v_isRegistered();
+ void setBinding(detail::EventBinding<Event> & binding);
+
+ detail::EventBinding<Event> * binding_;
+
+ friend class EventManager;
+ };
+
}}
///////////////////////////////hh.e////////////////////////////////////////
-//#include "Events.cci"
+#include "Events.cci"
//#include "Events.ct"
-//#include "Events.cti"
+#include "Events.cti"
#endif
\f
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Events internal header */
+
+#ifndef IH_Events_
+#define IH_Events_ 1
+
+// Custom includes
+
+///////////////////////////////ih.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+namespace detail {
+
+ template <class EventType>
+ struct EventArgType
+ {
+ typedef EventType const & type;
+ };
+
+ template <>
+ struct EventArgType<void>
+ {
+ typedef void type;
+ };
+
+}}}
+
+///////////////////////////////ih.e////////////////////////////////////////
+#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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Events.test unit tests */
+
+//#include "Events.test.hh"
+//#include "Events.test.ih"
+
+// Custom includes
+#include "Events.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(events)
+{}
+
+///////////////////////////////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:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 IOEvent non-inline non-template implementation */
+
+#include "IOEvent.hh"
+//#include "IOEvent.ih"
+
+// Custom includes
+#include <boost/bind.hpp>
+
+//#include "IOEvent.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::IOEvent
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::ppi::IOEvent::v_enable()
+{
+ Scheduler::instance().add(fd_, boost::bind(&IOEvent::cb,this,_1,_2),
+ Scheduler::EventId(events_));
+}
+
+prefix_ void senf::ppi::IOEvent::v_disable()
+{
+ Scheduler::instance().remove(fd_, Scheduler::EventId(events_));
+}
+
+prefix_ void senf::ppi::IOEvent::cb(int, Scheduler::EventId event)
+{
+ IOEventInfo info = { event };
+ callback(info);
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "IOEvent.mpp"
+
+\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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 IOEvent inline template implementation */
+
+//#include "IOEvent.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::IOEvent
+
+template <class Handle>
+prefix_ senf::ppi::IOEvent::IOEvent(Handle handle, unsigned events)
+ : fd_(retrieve_filehandle(handle)), events_(events)
+{}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 IOEvent public header */
+
+#ifndef HH_IOEvent_
+#define HH_IOEvent_ 1
+
+// Custom includes
+#include "Events.hh"
+#include "Scheduler/Scheduler.hh"
+
+//#include "IOEvent.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+
+ struct IOEventInfo
+ {
+ unsigned events;
+ };
+
+ /** \brief
+ */
+ class IOEvent
+ : public EventImplementation<IOEventInfo>
+ {
+ public:
+ ///////////////////////////////////////////////////////////////////////////
+ // Types
+
+ enum EventFlags { Read = Scheduler::EV_READ,
+ Write = Scheduler::EV_WRITE };
+
+ ///////////////////////////////////////////////////////////////////////////
+ ///\name Structors and default members
+ ///@{
+
+ template <class Handle>
+ IOEvent(Handle handle, unsigned events);
+
+ ///@}
+ ///////////////////////////////////////////////////////////////////////////
+
+ protected:
+
+ private:
+ virtual void v_enable();
+ virtual void v_disable();
+
+ void cb(int, Scheduler::EventId event);
+
+ int fd_;
+ unsigned events_;
+ };
+
+
+}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "IOEvent.cci"
+//#include "IOEvent.ct"
+#include "IOEvent.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:
handler has finished processing. Forward throttling notifications are not generated
automatically within the connector. However, the Passive-Passive adaptor will generate
Forward-throttling notifications whenever the input queue is empty.
+
+ \section class_diagram Class Diagram
+
+ \image html classes.png
*/
\f
--- /dev/null
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Module non-inline non-template implementation */
+
+#include "Module.hh"
+#include "Module.ih"
+
+// Custom includes
+
+//#include "Module.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "Module.mpp"
+
+\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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Module inline non-template implementation */
+
+// Custom includes
+#include "Route.hh"
+#include "Connectors.hh"
+#include "EventManager.hh"
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::Module
+
+prefix_ void senf::ppi::module::Module::noroute(connector::Connector & connector)
+{
+ registerConnector(connector);
+ connector.setModule(*this);
+}
+
+prefix_ boost::posix_time::ptime senf::ppi::module::Module::eventTime()
+{
+ return eventManager().eventTime();
+}
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::module::Module::Module()
+{}
+
+////////////////////////////////////////
+// private members
+
+prefix_ senf::ppi::EventManager & senf::ppi::module::Module::eventManager()
+{
+ return EventManager::instance();
+}
+
+prefix_ void senf::ppi::module::Module::registerConnector(connector::Connector & connector)
+{
+ connectorRegistry_.push_back(&connector);
+ connector.setModule(*this);
+}
+
+prefix_ senf::ppi::RouteBase &
+senf::ppi::module::Module::addRoute(std::auto_ptr<RouteBase> route)
+{
+ routes_.push_back(route.release());
+ return routes_.back();
+}
+
+///////////////////////////////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
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Module non-inline template implementation */
+
+#include "Module.ih"
+
+// Custom includes
+
+#define prefix_
+///////////////////////////////ct.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::Module
+
+template <class Source, class Target>
+prefix_ senf::ppi::Route<Source, Target> &
+senf::ppi::module::Module::route(Source & source, Target & target)
+{
+ detail::RouteHelper<Source,Target>::route(*this, source, target, source, target);
+ return static_cast< Route<Source,Target> & >(
+ addRoute(std::auto_ptr< RouteBase >(
+ new Route<Source,Target>(*this, source, target))));
+}
+
+template <class Target, class Descriptor>
+prefix_ void senf::ppi::module::Module::registerEvent(Target target, Descriptor & descriptor)
+{
+ eventManager().registerEvent(
+ *this,
+ EventManager::Callback<Descriptor>::make(target,*this),
+ descriptor);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::detail namespace members
+
+template <class Source, class Target>
+prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
+route(Module & module, Source & source, Target & target,
+ connector::InputConnector &, connector::OutputConnector &)
+{
+ module.registerConnector(source);
+ module.registerConnector(target);
+}
+
+template <class Source, class Target>
+prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
+route(Module & module, Source & source, Target & target,
+ connector::InputConnector &, EventDescriptor &)
+{
+ module.registerConnector(source);
+}
+
+template <class Source, class Target>
+prefix_ void senf::ppi::module::detail::RouteHelper<Source,Target>::
+route(Module & module, Source & source, Target & target,
+ EventDescriptor &, connector::OutputConnector &)
+{
+ module.registerConnector(target);
+}
+
+///////////////////////////////ct.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:
#define HH_Module_ 1
// Custom includes
+#include <vector>
#include <boost/utility.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include "predecl.hh"
//#include "Module.mpp"
///////////////////////////////hh.p////////////////////////////////////////
{
protected:
Module();
- ~Module();
template <class Source, class Target>
- Route<Source, Target> & route(Source const & source, Target const & target);
+ Route<Source, Target> & route(Source & source, Target & target);
///< Define flow information
/**< Using the route() and noroute() members, the
information flow within the module is defined. Routing
outgoing data
\returns Route instance describing this route */
- template <class Connector>
- void noroute(Connector const & connector); ///< Define terminal connectors
+ void noroute(connector::Connector & connector); ///< Define terminal connectors
/**< The noroute() member explicitly declares, that a
connector is terminal and does not directly
receive/forward data from/to some other
\param[in] connector Terminal connector to declare */
template <class Target, class Descriptor>
- void registerEvent(Target target, Descriptor const & descriptor);
+ void registerEvent(Target target, Descriptor & descriptor);
///< Register an external event
/**< The \a target argument may be either an arbitrary
callable object or it may be a member function pointer
information on the event delivered.
The \a descriptor describes the event to signal. This
+
may be a timer event or some type of I/O event on a
file descriptor or socket.
boost::posix_time::ptime eventTime(); ///< Return timestamp of the currently processing
///< event
+
+ private:
+ EventManager & eventManager();
+
+ void registerConnector(connector::Connector & connector);
+ RouteBase & addRoute(std::auto_ptr<RouteBase> route);
+
+ typedef std::vector<connector::Connector *> ConnectorRegistry;
+ ConnectorRegistry connectorRegistry_;
+
+ typedef boost::ptr_vector<RouteBase> RouteInfoBase;
+ RouteInfoBase routes_;
+
+ template <class Source, class Target>
+ friend class detail::RouteHelper;
};
/** \brief Connect compatible connectors
}}}
///////////////////////////////hh.e////////////////////////////////////////
-//#include "Module.cci"
-//#include "Module.ct"
+#include "Module.cci"
+#include "Module.ct"
//#include "Module.cti"
#endif
--- /dev/null
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Module internal header */
+
+#ifndef IH_Module_
+#define IH_Module_ 1
+
+// Custom includes
+
+///////////////////////////////ih.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+namespace module {
+namespace detail {
+
+ // Placing these into a class simplifies the friend declaration
+ template <class Source, class Target>
+ struct RouteHelper
+ {
+ static void route(Module & module, Source & source, Target & target,
+ connector::InputConnector &,
+ connector::OutputConnector &);
+
+
+ static void route(Module & module, Source & source, Target & target,
+ connector::InputConnector &,
+ EventDescriptor &);
+
+ static void route(Module & module, Source & source, Target & target,
+ EventDescriptor &,
+ connector::OutputConnector &);
+ };
+
+}}}}
+
+///////////////////////////////ih.e////////////////////////////////////////
+#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
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Module.test unit tests */
+
+//#include "Module.test.hh"
+//#include "Module.test.ih"
+
+// Custom includes
+#include "Module.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+#include <boost/type_traits.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(module)
+{}
+
+///////////////////////////////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:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Queueing non-inline non-template implementation */
+
+#include "Queueing.hh"
+//#include "Queueing.ih"
+
+// Custom includes
+
+//#include "Queueing.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::QueueingDiscipline
+
+prefix_ senf::ppi::QueueingDiscipline::~QueueingDiscipline()
+{}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "Queueing.mpp"
+
+\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:
#define HH_Queueing_ 1
// Custom includes
+#include "predecl.hh"
//#include "Queueing.mpp"
///////////////////////////////hh.p////////////////////////////////////////
class QueueingDiscipline
{
public:
+ virtual ~QueueingDiscipline();
+
enum Event { ENQUEUE, DEQUEUE }; ///< Possible queueing events
enum State { THROTTLED, UNTHROTTLED }; ///< Possible queueing states
-
- State update(PassiveInput & input, Event event) = 0; ///< Calculate new queueing state
+
+ virtual State update(connector::PassiveInput & input, Event event) = 0;
+ ///< Calculate new queueing state
/**< Whenever the queue is manipulated, this member is
called to calculate the new throttling state.
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Route inline non-template implementation */
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::RouteBase
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::RouteBase::RouteBase(module::Module & module)
+ : module_(&module)
+{}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Route inline template implementation */
+
+#include "Route.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::Route<Source,Target>
+
+////////////////////////////////////////
+// protected members
+
+template <class Source, class Target>
+prefix_ senf::ppi::Route<Source,Target>::Route(module::Module & module, Source & source,
+ Target & target)
+ : Implementation(module, source, target)
+{}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::detail::RouteImplementation<Source,Target,srcEvent,trgEvent>
+
+////////////////////////////////////////
+// protected members
+
+template <bool srcEvent, bool trgEvent>
+prefix_ senf::ppi::detail::RouteImplementation<srcEvent,trgEvent>::
+RouteImplementation(module::Module & module, connector::InputConnector & source,
+ connector::OutputConnector & target)
+ : RouteBase(module), source_(&source), target_(&target)
+{}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::detail::RouteImplementation<true,false>
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::detail::RouteImplementation<true,false>::
+RouteImplementation(module::Module & module, EventDescriptor & source,
+ connector::OutputConnector & target)
+ : RouteBase(module), source_(&source), target_(&target)
+{}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::detail::RouteImplementation<false,true>
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::detail::RouteImplementation<false,true>::
+RouteImplementation(module::Module & module, connector::InputConnector & source,
+ EventDescriptor & target)
+: RouteBase(module), source_(&source), target_(&target)
+{}
+
+///////////////////////////////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:
#define HH_Route_ 1
// Custom includes
+#include <boost/type_traits.hpp>
+#include "predecl.hh"
//#include "Route.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
namespace ppi {
- /** \brief Route descriptor
-
- Route instances are created by Module::route statements. The Route class provides an
- interface to manipulate the flow processing.
- */
- template <class Source, class Target>
- class Route
+ class RouteBase
{
public:
void autoThrottling(bool state); ///< Change automatic throttle notification forwarding
specializations. However, this is an implementation
detail which does not affect the exposed
interface. */
+
+ protected:
+ RouteBase(module::Module & module);
+
+ private:
+ module::Module * module_;
+ };
+
+}}
+
+#include "Route.ih"
+
+namespace senf {
+namespace ppi {
+
+ /** \brief Route descriptor
+
+ Route instances are created by Module::route statements. The Route class provides an
+ interface to manipulate the flow processing.
+ */
+ template <class Source, class Target>
+ class Route
+ : public detail::RouteImplementation< boost::is_base_of<EventDescriptor,Source>::value,
+ boost::is_base_of<EventDescriptor,Target>::value >
+ {
+ private:
+ typedef detail::RouteImplementation<
+ boost::is_base_of<EventDescriptor,Source>::value,
+ boost::is_base_of<EventDescriptor,Target>::value > Implementation;
+
+ Route(module::Module & module, Source & source, Target & target);
+
+ friend class module::Module;
};
}}
///////////////////////////////hh.e////////////////////////////////////////
-//#include "Route.cci"
+#include "Route.cci"
//#include "Route.ct"
-//#include "Route.cti"
+#include "Route.cti"
#endif
\f
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Route internal header */
+
+#ifndef IH_Route_
+#define IH_Route_ 1
+
+// Custom includes
+
+///////////////////////////////ih.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+namespace detail {
+
+ template <bool srcEvent, bool trgEvent>
+ class RouteImplementation
+ : public RouteBase
+ {
+ protected:
+ RouteImplementation(module::Module & module,
+ connector::InputConnector & source,
+ connector::OutputConnector & target);
+
+ private:
+ connector::InputConnector * source_;
+ connector::OutputConnector * target_;
+ };
+
+ template <>
+ class RouteImplementation<true,false>
+ : public RouteBase
+ {
+ protected:
+ RouteImplementation(module::Module & module,
+ EventDescriptor & source,
+ connector::OutputConnector & target);
+
+ private:
+ EventDescriptor * source_;
+ connector::OutputConnector * target_;
+ };
+
+ template<>
+ class RouteImplementation<false,true>
+ : public RouteBase
+ {
+ protected:
+ RouteImplementation(module::Module & module,
+ connector::InputConnector & source,
+ EventDescriptor & target);
+
+ private:
+ connector::InputConnector * source_;
+ EventDescriptor * target_;
+ };
+
+}}}
+
+///////////////////////////////ih.e////////////////////////////////////////
+#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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Route.test unit tests */
+
+//#include "Route.test.hh"
+//#include "Route.test.ih"
+
+// Custom includes
+#include "Route.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(route)
+{}
+
+///////////////////////////////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:
Import('env')
-import SENFSCons
+import SENFSCons, glob
###########################################################################
+SConscript(glob.glob("*/SConscript"))
+
+sources = SENFSCons.GlobSources(subdirs=[ 'detail' ])
+
SENFSCons.StandardTargets(env)
+SENFSCons.Lib(env,
+ library = 'PPI',
+ sources = sources,
+ LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ])
+
SENFSCons.Doxygen(env, extra_sources=[
env.Dia2Png('scenario.dia'),
+ env.Dia2Png('classes.dia'),
])
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Setup inline non-template implementation */
+
+// Custom includes
+#include "Connectors.hh"
+#include "Scheduler/Scheduler.hh"
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+prefix_ void senf::ppi::connect(connector::ActiveOutput & source,
+ connector::PassiveInput & target)
+{
+ source.connect(target);
+}
+
+prefix_ void senf::ppi::connect(connector::PassiveOutput & source,
+ connector::ActiveInput & target)
+{
+ source.connect(target);
+}
+
+prefix_ void senf::ppi::run()
+{
+ Scheduler::instance().process();
+}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Setup public header */
+
+#ifndef HH_Setup_
+#define HH_Setup_ 1
+
+// Custom includes
+#include "predecl.hh"
+
+//#include "Setup.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+
+ void connect(connector::ActiveOutput & source, connector::PassiveInput & target);
+ void connect(connector::PassiveOutput & source, connector::ActiveInput & target);
+
+ void run();
+
+}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+#include "Setup.cci"
+//#include "Setup.ct"
+//#include "Setup.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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 SocketReader non-inline template implementation */
+
+//#include "SocketReader.ih"
+
+// Custom includes
+
+#define prefix_
+///////////////////////////////ct.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::PacketReader<Packet>
+
+template <class Packet>
+prefix_ Packet senf::ppi::PacketReader<Packet>::operator()(Handle handle)
+{
+ Packet packet (Packet::create(Packet::noinit));
+ handle.read(packet.data(),0u);
+ return packet;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::ActiveSocketReader<Reader>
+
+template <class Reader>
+prefix_ senf::ppi::module::ActiveSocketReader<Reader>::ActiveSocketReader(Handle handle)
+ : handle_(handle), event_(handle_, IOEvent::Read), reader_()
+{
+ registerEvent( &ActiveSocketReader::read, event_ );
+ route(event_, output);
+}
+
+////////////////////////////////////////
+// private members
+
+template <class Reader>
+prefix_ void senf::ppi::module::ActiveSocketReader<Reader>::read()
+{
+ output(reader_(handle_));
+}
+
+///////////////////////////////ct.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:
#define HH_SocketReader_ 1
// Custom includes
-#include "Packets/Packet.hh"
-#include "Packets/DataPacket.hh"
+#include "Packets/Packets.hh"
+#include "Socket/ClientSocketHandle.hh"
+#include "Socket/SocketPolicy.hh"
+#include "Socket/ReadWritePolicy.hh"
+#include "Socket/FramingPolicy.hh"
#include "Module.hh"
-#include "Connector.hh"
+#include "Connectors.hh"
+#include "IOEvent.hh"
//#include "SocketReader.mpp"
///////////////////////////////hh.p////////////////////////////////////////
public:
typedef senf::ClientSocketHandle<
senf::MakeSocketPolicy< senf::ReadablePolicy,
- senf::DatagramFramingPolicy > > Handle;
+ senf::DatagramFramingPolicy >::policy > Handle;
///< Handle type supported by this reader
- Packet::ptr operator()(Handle handle);
+ Packet operator()(Handle handle);
///< Read packet from \a handle
/**< Read a datagram from \a handle and interpret is as
packet of type \c Packet.
/**< Data will be read from \a handle and be parsed by \a
Reader.
\param[in] handle Handle to read data from */
+
+ private:
+ void read();
+
+ Handle handle_;
+ IOEvent event_;
+ Reader reader_;
};
}}}
///////////////////////////////hh.e////////////////////////////////////////
//#include "SocketReader.cci"
-//#include "SocketReader.ct"
+#include "SocketReader.ct"
//#include "SocketReader.cti"
#endif
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 SocketReader.test unit tests */
+
+//#include "SocketReader.test.hh"
+//#include "SocketReader.test.ih"
+
+// Custom includes
+#include "SocketReader.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(socketReader)
+{}
+
+///////////////////////////////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:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 SocketWriter inline non-template implementation */
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::PacketWriter
+
+prefix_ void senf::ppi::PacketWriter::operator()(Handle handle, Packet packet)
+{
+ handle.write(packet.data());
+}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 SocketWriter non-inline template implementation */
+
+//#include "SocketWriter.ih"
+
+// Custom includes
+
+#define prefix_
+///////////////////////////////ct.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::PassiveSocketWriter<Writer>
+
+template <class Writer>
+prefix_ senf::ppi::module::PassiveSocketWriter<Writer>::PassiveSocketWriter(Handle handle)
+ : handle_(handle), writer_()
+{
+ noroute(input);
+ input.onRequest(&PassiveSocketWriter::write);
+}
+
+////////////////////////////////////////
+// private members
+
+template <class Writer>
+prefix_ void senf::ppi::module::PassiveSocketWriter<Writer>::write()
+{
+ writer_(handle_,input());
+}
+
+///////////////////////////////ct.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:
#define HH_SocketWriter_ 1
// Custom includes
-#include "Packets/Packet.hh"
+#include "Packets/Packets.hh"
+#include "Socket/ClientSocketHandle.hh"
+#include "Socket/SocketPolicy.hh"
+#include "Socket/ReadWritePolicy.hh"
+#include "Socket/FramingPolicy.hh"
+#include "Socket/CommunicationPolicy.hh"
#include "Module.hh"
-#include "Connector.hh"
+#include "Connectors.hh"
//#include "SocketWriter.mpp"
///////////////////////////////hh.p////////////////////////////////////////
public:
typedef senf::ClientSocketHandle<
senf::MakeSocketPolicy< senf::WriteablePolicy,
- senf::DatagramFramingPolicy > > Handle;
+ senf::DatagramFramingPolicy,
+ senf::ConnectedCommunicationPolicy>::policy > Handle;
///< Handle type supported by this writer
- void operator()(Handle handle, Packet::ptr packet);
+ void operator()(Handle handle, Packet packet);
///< Write \a packet to \a handle
/**< Write the complete \a packet as a datagram to \a
handle.
public:
typedef unspecified Handle; // type of handle requested
SomeWriter(); // default constructible
- void operator()(Handle handle, Packet::ptr packet); // insertion function
+ void operator()(Handle handle, Packet packet); // insertion function
};
\endcode
*/
class ActiveSocketWriter : public Module
{
public:
- typedef typename Writer:Handle Handle; ///< Handle type requested by writer
+ typedef typename Writer::Handle Handle; ///< Handle type requested by writer
connector::ActiveInput input; ///< Input connector from which data is received
public:
typedef unspecified Handle; // type of handle requested
SomeWriter(); // default constructible
- void operator()(Handle handle, Packet::ptr packet); // insertion function
+ void operator()(Handle handle, Packet packet); // insertion function
};
\endcode
*/
class PassiveSocketWriter : public Module
{
public:
- typedef typename Writer:Handle Handle; ///< Handle type requested by writer
+ typedef typename Writer::Handle Handle; ///< Handle type requested by writer
connector::PassiveInput input; ///< Input connector from which data is received
- ActiveSocketWriter(Handle handle); ///< Create new writer for the given handle
+ PassiveSocketWriter(Handle handle); ///< Create new writer for the given handle
/**< Data will be written to \a handle using \a Writer.
\param[in] handle Handle to write data to */
+
+ private:
+ void write();
+
+ Handle handle_;
+ Writer writer_;
};
}}}
///////////////////////////////hh.e////////////////////////////////////////
-//#include "SocketWriter.cci"
-//#include "SocketWriter.ct"
+#include "SocketWriter.cci"
+#include "SocketWriter.ct"
//#include "SocketWriter.cti"
#endif
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 SocketWriter.test unit tests */
+
+//#include "SocketWriter.test.hh"
+//#include "SocketWriter.test.ih"
+
+// Custom includes
+#include "SocketWriter.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(socketWriter)
+{}
+
+///////////////////////////////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:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Callback inline template implementation */
+
+//#include "Callback.ih"
+
+// Custom includes
+#include <boost/bind.hpp>
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::detail::Callback<Arg>
+
+template <class Arg>
+template <class Owner, class FnClass>
+prefix_ typename senf::ppi::detail::Callback<Arg>::type
+senf::ppi::detail::Callback<Arg>::make(void (FnClass::* memfn )(), Owner & owner)
+{
+ return boost::bind(memfn,static_cast<FnClass *>(&owner));
+}
+
+template <class Arg>
+template <class Owner, class FnClass, class FnArg>
+prefix_ typename senf::ppi::detail::Callback<Arg>::type
+senf::ppi::detail::Callback<Arg>::make(void (FnClass::* memfn )(FnArg arg), Owner & owner)
+{
+ return boost::bind(memfn,static_cast<FnClass *>(&owner),1);
+}
+
+template <class Arg>
+template <class Owner>
+prefix_ typename senf::ppi::detail::Callback<Arg>::type
+senf::ppi::detail::Callback<Arg>::make(type callable, Owner &)
+{
+ return callable;
+}
+
+template <class Arg>
+template <class Owner>
+prefix_ typename senf::ppi::detail::Callback<Arg>::type
+senf::ppi::detail::Callback<Arg>::make(boost::function<void()> callable, Owner &)
+{
+ return boost::bind(callable);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::detail::Callback<void>
+
+template <class Owner, class FnClass>
+prefix_ typename senf::ppi::detail::Callback<void>::type
+senf::ppi::detail::Callback<void>::make(void (FnClass::* memfn )(), Owner & owner)
+{
+ return boost::bind(memfn,static_cast<FnClass *>(&owner));
+}
+
+template <class Owner>
+prefix_ typename senf::ppi::detail::Callback<void>::type
+senf::ppi::detail::Callback<void>::make(type callable, Owner &)
+{
+ return callable;
+}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 Callback public header */
+
+#ifndef HH_Callback_
+#define HH_Callback_ 1
+
+// Custom includes
+#include <boost/function.hpp>
+
+//#include "Callback.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+namespace detail {
+
+ /** \brief Provide callbacks with a single optional argument
+
+ This helper implements callbacks with an optional single argument. In addition to
+ boost::function, this helper provides the following functionality:
+
+ \li It allows the callback to ignore the argument: A callable with no argument may be used
+ as callback.
+ \li It allows to use member function pointers as callbacks. These will be automatically
+ bound to the \a owner argument of \ref make().
+
+ The callbacks follow the same restrictions as <a href="">Boost.Function</a>: They must be
+ either function, member function pointers or callable objects defining the appropriate
+ typedef members.
+ */
+ template <class Arg=void>
+ struct Callback
+ {
+ typedef boost::function<void (Arg)> type;
+
+ template <class Owner, class FnClass>
+ static type make(void (FnClass::* memfn )(), Owner & owner);
+ template <class Owner, class FnClass, class FnArg>
+ static type make(void (FnClass::* memfn )(FnArg arg), Owner & owner);
+ template <class Owner>
+ static type make(type callable, Owner &);
+ template <class Owner>
+ static type make(boost::function<void()> callable, Owner &);
+ };
+
+ template <>
+ struct Callback<void>
+ {
+ typedef boost::function<void ()> type;
+
+ template <class Owner, class FnClass>
+ static type make(void (FnClass::* memfn )(), Owner & owner);
+ template <class Owner>
+ static type make(type callable, Owner &);
+ };
+
+}}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "Callback.cci"
+//#include "Callback.ct"
+#include "Callback.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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 EventBinding non-inline non-template implementation */
+
+#include "EventBinding.hh"
+//#include "EventBinding.ih"
+
+// Custom includes
+#include "../EventManager.hh"
+
+//#include "EventBinding.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+prefix_ void senf::ppi::detail::EventBindingBase::eventTime(boost::posix_time::ptime time)
+{
+ // It's hard to make this inline because of a circular header dependency ...
+ manager_->eventTime(time);
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "EventBinding.mpp"
+
+\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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 EventBinding inline non-template implementation */
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::detail::EventBindingBase
+
+////////////////////////////////////////
+// protected members
+
+prefix_ senf::ppi::detail::EventBindingBase::EventBindingBase(EventManager & manager,
+ module::Module & module,
+ EventDescriptor & descriptor)
+ : manager_(&manager), module_(&module), descriptor_(&descriptor)
+{}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 EventBinding inline template implementation */
+
+//#include "EventBinding.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::detail::EventBinding<EvImpl>
+
+template <class EventType>
+prefix_ senf::ppi::detail::EventBinding<EventType>::EventBinding(EventManager & manager,
+ module::Module & module,
+ Callback callback,
+ EventDescriptor & descriptor)
+ : EventBindingBase(manager, module, descriptor), callback_(callback)
+{}
+
+template <class EvImpl>
+prefix_ void senf::ppi::detail::EventBinding<EvImpl>::callback(EventArg event,
+ boost::posix_time::ptime time)
+{
+ eventTime(time);
+ callback_(event);
+}
+
+template <class EvImpl>
+prefix_ void senf::ppi::detail::EventBinding<EvImpl>::callback(EventArg event)
+{
+ callback(event, boost::posix_time::microsec_clock::universal_time());
+}
+
+///////////////////////////////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) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 EventBinding public header */
+
+#ifndef HH_EventBinding_
+#define HH_EventBinding_ 1
+
+// Custom includes
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include "../predecl.hh"
+#include "Callback.hh"
+
+//#include "EventBinding.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+namespace detail {
+
+ class EventBindingBase
+ {
+ protected:
+ EventBindingBase(EventManager & manager, module::Module & module,
+ EventDescriptor & descriptor);
+
+ void eventTime(boost::posix_time::ptime time);
+
+ private:
+ EventManager * manager_;
+ module::Module * module_;
+ EventDescriptor * descriptor_;
+ };
+
+ template <class EventType>
+ class EventBinding
+ : public EventBindingBase
+ {
+ public:
+ typedef EventType Event;
+ typedef typename detail::EventArgType<Event>::type EventArg;
+ typedef typename detail::Callback<Event const &>::type Callback;
+
+ EventBinding(EventManager & manager, module::Module & module, Callback callback,
+ EventDescriptor & descriptor);
+
+ void callback(EventArg event, boost::posix_time::ptime time);
+ void callback(EventArg event);
+
+ private:
+ Callback callback_;
+ };
+
+}}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+#include "EventBinding.cci"
+//#include "EventBinding.ct"
+#include "EventBinding.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: main.test.cc 296 2007-07-10 20:39:34Z g0dil $
+//
+// Copyright (C) 2006
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <stefan.bund@fokus.fraunhofer.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.
+
+// Definition of non-inline non-template functions
+
+//#include "test.hh"
+//#include "test.ih"
+
+// Custom includes
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
+// End:
--- /dev/null
+Import('env')
+import SENFSCons
+
+###########################################################################
+
+SENFSCons.Binary( env, 'ppitest', SENFSCons.GlobSources(),
+ LIBS = [ 'PPI', 'Scheduler', 'Packets', 'Socket', 'Utils' ] );
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 ppitest non-inline non-template implementation */
+
+//#include "ppitest.hh"
+//#include "ppitest.ih"
+
+// Custom includes
+#include "Socket/Protocols/INet/UDPSocketHandle.hh"
+#include "Socket/Protocols/INet/ConnectedUDPSocketHandle.hh"
+#include "PPI/SocketReader.hh"
+#include "PPI/SocketWriter.hh"
+#include "PPI/Setup.hh"
+
+//#include "ppitest.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+int main(int argc, char * argv[])
+{
+ namespace module = senf::ppi::module;
+ namespace ppi = senf::ppi;
+
+ senf::UDPv4ClientSocketHandle inputSocket;
+ module::ActiveSocketReader<> udpReader (inputSocket);
+
+ senf::ConnectedUDPv4ClientSocketHandle outputSocket;
+ module::PassiveSocketWriter<> udpWriter (outputSocket);
+
+ ppi::connect(udpReader.output, udpWriter.input);
+
+ ppi::run();
+
+ return 0;
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "ppitest.mpp"
+
+\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"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// 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 predecl public header */
+
+#ifndef HH_predecl_
+#define HH_predecl_ 1
+
+// Custom includes
+#include <boost/type_traits.hpp>
+
+//#include "predecl.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace ppi {
+
+ class EventDescriptor;
+ template <class EventType=void> class EventImplementation;
+ class EventManager;
+ class RouteBase;
+ template <class Source, class Target> class Route;
+ class QueueingDiscipline;
+
+ namespace detail {
+ class EventBindingBase;
+ template <class EvImpl> class EventBinding;
+ template <class EventType> struct EventArgType;
+ template <bool srcEvent, bool trgEvent> class RouteImplementation;
+ }
+
+ namespace module {
+ class Module;
+ namespace detail {
+ template <class Source, class Target> class RouteHelper;
+ }
+ }
+
+ namespace connector {
+ class Connector;
+ class ActiveConnector;
+ class PassiveConnector;
+ class InputConnector;
+ class OutputConnector;
+ class ActiveInput;
+ class ActiveOutput;
+ class PassiveInput;
+ class PassiveOutput;
+ }
+
+}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "predecl.cci"
+//#include "predecl.ct"
+//#include "predecl.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:
-(set (make-local-variable 'ccide-all-includes-guard) "SENF_PACKETS_DECL_ONLY")
+(set (make-local-variable 'ccide-all-includes) "Packets.hh")
--- /dev/null
+// $Id: ConnectedUDPSocketHandle.cc 357 2007-07-26 22:48:39Z g0dil $
+//
+// Copyright (C) 2006
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <stefan.bund@fokus.fraunhofer.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 ConnectedUDPv4SocketHandle and ConnectedUDPv6SocketHandle non-inline non-template implementation
+ */
+
+#include "ConnectedUDPSocketHandle.hh"
+//#include "ConnectedUDPSocketHandle.ih"
+
+// Custom includes
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+#include "Utils/Exception.hh"
+
+//#include "ConnectedUDPSocketHandle.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ConnectedUDPv4SocketProtocol
+
+prefix_ void senf::ConnectedUDPv4SocketProtocol::init_client()
+ const
+{
+ int sock = ::socket(PF_INET,SOCK_DGRAM,0);
+ if (sock < 0)
+ throw SystemException(errno);
+ body().fd(sock);
+}
+
+prefix_ void
+senf::ConnectedUDPv4SocketProtocol::init_client(INet4SocketAddress const & address)
+ const
+{
+ init_client();
+ connect(address);
+}
+
+prefix_ std::auto_ptr<senf::SocketProtocol> senf::ConnectedUDPv4SocketProtocol::clone()
+ const
+{
+ return std::auto_ptr<SocketProtocol>(new ConnectedUDPv4SocketProtocol());
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ConnectedUDPv6SocketProtocol::
+
+prefix_ void senf::ConnectedUDPv6SocketProtocol::init_client()
+ const
+{
+ int sock = ::socket(PF_INET6,SOCK_DGRAM,0);
+ if (sock < 0)
+ throw SystemException(errno);
+ body().fd(sock);
+}
+
+prefix_ void
+senf::ConnectedUDPv6SocketProtocol::init_client(INet6SocketAddress const & address)
+ const
+{
+ init_client();
+ connect(address);
+}
+
+prefix_ std::auto_ptr<senf::SocketProtocol> senf::ConnectedUDPv6SocketProtocol::clone()
+ const
+{
+ return std::auto_ptr<SocketProtocol>(new ConnectedUDPv6SocketProtocol());
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "ConnectedUDPSocketHandle.mpp"
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
+// End:
--- /dev/null
+// $Id: ConnectedUDPSocketHandle.hh 357 2007-07-26 22:48:39Z g0dil $
+//
+// Copyright (C) 2006
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <stefan.bund@fokus.fraunhofer.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 UDPv4SocketHandle and UDPv6SocketHandle public header
+
+ \todo Implement possibly non-blocking connect and SO_ERROR in the
+ protocol interface
+ */
+
+#ifndef HH_ConnectedUDPSocketHandle_
+#define HH_ConnectedUDPSocketHandle_ 1
+
+// Custom includes
+#include "INetProtocol.hh"
+#include "UDPProtocol.hh"
+#include "Socket/Protocols/BSDSocketProtocol.hh"
+#include "Socket/FramingPolicy.hh"
+#include "Socket/CommunicationPolicy.hh"
+#include "Socket/ReadWritePolicy.hh"
+#include "Socket/BufferingPolicy.hh"
+#include "Socket/ProtocolClientSocketHandle.hh"
+
+//#include "ConnectedUDPSocketHandle.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+
+ /// \addtogroup concrete_protocol_group
+ /// @{
+
+ typedef MakeSocketPolicy<
+ INet4AddressingPolicy,
+ DatagramFramingPolicy,
+ ConnectedCommunicationPolicy,
+ ReadablePolicy,
+ WriteablePolicy,
+ SocketBufferingPolicy
+ >::policy ConnectedUDPv4Socket_Policy; ///< Socket Policy of the UDPv4 Protocol
+
+ /** \brief IPv4 UDP Socket Protocol, connected
+
+ \par Socket Handle typedefs:
+ \ref ConnectedUDPv4ClientSocketHandle (ProtocolClientSocketHandle)
+
+ \par Policy Interface:
+ ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
+ ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
+ ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
+
+ \par Address Type:
+ INet4Address
+
+ ConnectedUDPv4SocketProtocol provides an internet protocol stream socket based on the UDP
+ protocol and IPv4 addressing.
+
+ This class is utilized as the protocol class of the ProtocolClientSocketHandle
+ via the Socket Handle typedefs above.
+
+ \see ConnectedUDPv6SocketProtocol
+ */
+ class ConnectedUDPv4SocketProtocol
+ : public ConcreteSocketProtocol<ConnectedUDPv4Socket_Policy>,
+ public IPv4Protocol,
+ public UDPProtocol,
+ public BSDSocketProtocol,
+ public AddressableBSDSocketProtocol,
+ public senf::pool_alloc_mixin<ConnectedUDPv4SocketProtocol>
+ {
+ public:
+ ///////////////////////////////////////////////////////////////////////////
+ // internal interface
+
+ ///\name Constructors
+ ///@{
+
+ void init_client() const; ///< Create unconnected client socket
+ /**< \note This member is implicitly called from the
+ ProtocolClientSocketHandle::ProtocolClientSocketHandle()
+ constructor */
+ void init_client(INet4SocketAddress const & address) const;
+ ///< Create client socket and connect
+ /**< Creates a new client socket and connects to the given
+ address.
+
+ \param[in] address remote address to connect to */
+ /**< \note This member is implicitly called from the
+ ProtocolClientSocketHandle::ProtocolClientSocketHandle()
+ constructor */
+
+ ///@}
+ ///\name Abstract Interface Implementation
+
+ std::auto_ptr<SocketProtocol> clone() const;
+
+ ///@}
+ };
+
+ typedef ProtocolClientSocketHandle<
+ ConnectedUDPv4SocketProtocol> ConnectedUDPv4ClientSocketHandle;
+
+ typedef MakeSocketPolicy<
+ ConnectedUDPv4Socket_Policy,
+ INet6AddressingPolicy
+ >::policy ConnectedUDPv6Socket_Policy;
+
+ /** \brief IPv6 UDP Socket Protocol, connected
+
+ \par Socket Handle typedefs:
+ \ref ConnectedUDPv6ClientSocketHandle (ProtocolClientSocketHandle)
+
+ \par Policy Interface:
+ ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
+ ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
+ ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
+
+ \par Address Type:
+ INet6Address
+
+ ConnectedUDPv6SocketProtocol provides an internet protocol stream socket based on the UDP
+ protocol and IPv6 addressing.
+
+ This class is utilized as the protocol class of the ProtocolClientSocketHandle
+ via the Socket Handle typedefs above.
+
+ \see ConnectedUDPv4SocketProtocol
+ */
+ class ConnectedUDPv6SocketProtocol
+ : public ConcreteSocketProtocol<ConnectedUDPv6Socket_Policy>,
+ public IPv6Protocol,
+ public UDPProtocol,
+ public BSDSocketProtocol,
+ public AddressableBSDSocketProtocol,
+ public senf::pool_alloc_mixin<ConnectedUDPv6SocketProtocol>
+ {
+ public:
+ ///////////////////////////////////////////////////////////////////////////
+ // internal interface
+
+ ///\name Constructors
+ ///@{
+
+ void init_client() const; ///< Create unconnected client socket
+ /**< \note This member is implicitly called from the
+ ProtocolClientSocketHandle::ProtocolClientSocketHandle()
+ constructor */
+ void init_client(INet6SocketAddress const & address) const;
+ ///< Create client socket and connect
+ /**< Creates a new client socket and connects to the given
+ address.
+
+ \param[in] address remote address to connect to */
+ /**< \note This member is implicitly called from the
+ ProtocolClientSocketHandle::ProtocolClientSocketHandle()
+ constructor */
+
+ ///@}
+ ///\name Abstract Interface Implementation
+
+ std::auto_ptr<SocketProtocol> clone() const;
+
+ ///@}
+ };
+
+ typedef ProtocolClientSocketHandle<
+ ConnectedUDPv6SocketProtocol> ConnectedUDPv6ClientSocketHandle;
+
+ /// @}
+
+}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "ConnectedUDPSocketHandle.cci"
+//#include "ConnectedUDPSocketHandle.ct"
+//#include "ConnectedUDPSocketHandle.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
+// End:
{
using boost::lambda::_1;
using boost::lambda::_2;
- using boost::lambda::_3;
using boost::lambda::var;
using boost::lambda::ret;
INet6Address addr (address());
prefix_ void senf::detail::apply_mask(unsigned bits, ForwardIterator b, ForwardIterator e,
Function fn)
{
- for(; b != e; ++b) {
- boost::uint8_t mask (0);
- if (bits > 8) {
- mask = 0xFFu;
- bits -= 8;
- } else if (bits > 0) {
- mask = ~ low_bits_mask(8-bits);
- bits = 0;
- }
- fn(*b,mask);
- }
+ for(; bits>8 && b != e; bits -= 8, ++b)
+ fn(*b, boost::lambda::make_const(0xFFu));
+ if (bits > 0 && b != e)
+ fn( *(b++), boost::lambda::make_const(~ low_bits_mask(8-bits)));
+ for(; b != e; ++b)
+ fn(*b, boost::lambda::make_const(0u));
}
template <class ForwardIterator1, class ForwardIterator2, class Function>
ForwardIterator1 e1, ForwardIterator2 b2,
Function fn)
{
- for(; b1 != e1; ++b1, ++b2) {
- boost::uint8_t mask (0);
- if (bits > 8) {
- mask = 0xFFu;
- bits -= 8;
- } else if (bits > 0) {
- mask = ~ low_bits_mask(8-bits);
- bits = 0;
- }
- if (fn(*b1,*b2,mask))
+ for(; bits>8 && b1 != e1; bits -= 8, ++b1, ++b2)
+ if (fn(*b1, *b2, boost::lambda::make_const(0xFFu)))
+ return b1;
+ if (bits > 0 && b1 != e1)
+ if (fn( *(b1++), *(b2++), boost::lambda::make_const(~ low_bits_mask(8-bits))))
+ return b1;
+ for(; b1 != e1; ++b1, ++b2)
+ if (fn(*b1, *b2, boost::lambda::make_const(0u)))
return b1;
- }
return e1;
}
/** \brief IPv4 UDP Socket Protocol
\par Socket Handle typedefs:
- \ref UDPv4ClientSocketHandle (ProtocolClientSocketHandle)
+ \ref UDPv4ClientSocketHandle (ProtocolClientSocketHandle)
\par Policy Interface:
- ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
- ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
- ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
+ ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
+ ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
+ ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
\par Address Type:
- INet4Address
+ INet4Address
UDPv4SocketProtocol provides an internet protocol stream socket based on the UDP protocol
and IPv4 addressing.
\par Socket Handle typedefs:
\ref UDPv6ClientSocketHandle (ProtocolClientSocketHandle)
- \par Policy Interface:
- ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
- ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
- ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
+ \par Policy Interface:
+ ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
+ ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
+ ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
\par Address Type:
- INet6Address
+ INet6Address
UDPv6SocketProtocol provides an internet protocol stream socket based on the UDP protocol
and IPv6 addressing.
SENFSCons.Doxygen(env, extra_sources = [
env.Dia2Png('SocketLibrary-classes.dia'),
env.Dia2Png('FhHierarchy.dia'),
- env.Command('doc/html/SocketPolicy.png', env.Dia2Png('SocketPolicy.dia'),
- Copy('$TARGET','$SOURCE')),
- env.Command('doc/html/Protocols.png', env.Dia2Png('Protocols.dia'),
- Copy('$TARGET','$SOURCE')),
+ env.Dia2Png('SocketPolicy.dia'),
+ env.Dia2Png('Protocols.dia'),
env.Dia2Png('Handle.dia'),
])
//#include "hexdump.ih"
// Custom includes
+#include <boost/io/ios_state.hpp>
#include <iomanip>
//#include "hexdump.mpp"
///////////////////////////////cc.p////////////////////////////////////////
template <class Iterator>
-prefix_ void senf::hexdump(Iterator i, Iterator const & i_end, std::ostream& stream, unsigned block_size=16)
+prefix_ void senf::hexdump(Iterator i, Iterator i_end, std::ostream & stream,
+ unsigned block_size)
{
+ boost::io::ios_all_saver ias (stream);
unsigned offset (0);
std::string ascii;
for (; i != i_end; ++i, ++offset) {
ascii = "";
}
stream << " "
- << std::hex << std::setw(4) << std::setfill('0')
- << offset << ' ';
+ << std::hex << std::setw(4) << std::setfill('0')
+ << offset << ' ';
} else if ((offset % block_size) == block_size/2) {
stream << " ";
ascii += ' ';
}
stream << ' ' << std::hex << std::setw(2) << std::setfill('0')
- << unsigned(*i);
+ << unsigned(*i);
ascii += (*i >= ' ' && *i < 126) ? *i : '.';
}
if (!ascii.empty()) {
}
stream << " " << ascii << "\n";
}
- stream << std::dec;
}
///////////////////////////////cc.e////////////////////////////////////////
/** \brief write the contents from Iterator i to i_end to the output stream in hexadecimal format.
*/
template <class Iterator>
- void hexdump(Iterator i, Iterator const & i_end, std::ostream& stream, unsigned block_size=16);
+ void hexdump(Iterator i, Iterator i_end, std::ostream & stream, unsigned block_size=16);
}
///////////////////////////////hh.e////////////////////////////////////////
--- /dev/null
+## \file
+# \brief CopyToDir builder
+
+## \package senfscons.CopyToDir
+# \brief Copy source file(s) to a given directory
+#
+# \ingroup builder
+
+import os.path
+import SCons.Builder, SCons.Defaults
+
+def emitter(source, target, env):
+ return ([ os.path.join(str(target[0]),source[0].name) ], source)
+
+CopyToDir = SCons.Builder.Builder(emitter = emitter,
+ action = SCons.Defaults.Copy("$TARGET","$SOURCE"),
+ single_source = True)
+
+def generate(env):
+ env['BUILDERS']['CopyToDir'] = CopyToDir
+
+def exists(env):
+ return 1
SCONS_TOOLS = [
"Doxygen",
"Dia2Png",
+ "CopyToDir",
]
opts = None
# in the current directory. The sources will be returned as a tuple of
# sources, test-sources. The target helpers all accept such a tuple as
# their source argument.
-def GlobSources(exclude=[]):
+def GlobSources(exclude=[], subdirs=[]):
testSources = glob.glob("*.test.cc")
sources = [ x for x in glob.glob("*.cc") if x not in testSources and x not in exclude ]
+ for subdir in subdirs:
+ testSources += glob.glob(os.path.join(subdir,"*.test.cc"))
+ sources += [ x for x in glob.glob(os.path.join(subdir,"*.cc"))
+ if x not in testSources and x not in exclude ]
return (sources, testSources)
## \brief Add generic standard targets for every module
xrefs.extend(xref_pp)
docs.extend(xrefs)
- env.Depends(docs, extra_sources)
+ if extra_sources and htmlnode:
+ env.Depends(docs,
+ [ env.CopyToDir( source=source, target=htmlnode.dir )
+ for source in extra_sources ])
+
+ if extra_sources and xmlnode:
+ env.Depends(docs,
+ [ env.CopyToDir( source=source, target=xmlnode.dir )
+ for source in extra_sources ])
+
+ if not htmlnode and not xmlnode:
+ env.Depends(docs, extra_sources)
+
for doc in docs :
env.Alias('all_docs', doc)
env.Clean('all_docs', doc)