{}
prefix_ senf::ppi::connector::Connector::~Connector()
-{}
+{
+ if (peer_)
+ peer_->peer_ = 0;
+}
prefix_ void senf::ppi::connector::Connector::connect(Connector & target)
{
class PassiveInputTest
: public ppi::module::Module
{
+ SENF_PPI_MODULE(PassiveInputTest);
+
public:
ppi::connector::PassiveInput input;
: public Module,
public SafeBool<ActivePacketSource>
{
+ SENF_PPI_MODULE(ActivePacketSource);
+
public:
connector::ActiveOutput output;
class PassivePacketSource
: public Module
{
+ SENF_PPI_MODULE(PassivePacketSource);
+
typedef std::deque<Packet> Queue;
public:
: public Module,
public SafeBool<ActivePacketSink>
{
+ SENF_PPI_MODULE(ActivePacketSink);
+
public:
connector::ActiveInput input;
class PassivePacketSink
: public Module
{
+ SENF_PPI_MODULE(PassivePacketSink);
+
typedef std::deque<Packet> Queue;
public:
--- /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 non-template implementation */
+
+#include "EventManager.hh"
+//#include "EventManager.ih"
+
+// Custom includes
+#include <boost/lambda/lambda.hpp>
+
+//#include "EventManager.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::EventManager
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::ppi::EventManager::destroyModule(module::Module & module)
+{
+ using boost::lambda::_1;
+
+ // boost::ptr_vector::erase(f,l) asserts !empty() .. why ??
+ if (!registrations_.empty())
+ registrations_.erase(
+ std::remove_if(registrations_.begin(), registrations_.end(),
+ ((&_1) ->* & detail::EventBindingBase::module_) == & module),
+ registrations_.end());
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "EventManager.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:
protected:
private:
+ void destroyModule(module::Module & module);
+
typedef boost::ptr_vector<detail::EventBindingBase> EventRegistrations;
EventRegistrations registrations_;
boost::posix_time::ptime eventTime_;
friend class detail::EventBindingBase;
+ friend class module::Module;
};
}}
connector.setModule(*this);
}
+prefix_ void senf::ppi::module::Module::destroy()
+{
+ eventManager().destroyModule(*this);
+}
+
////////////////////////////////////////
// private members
boost::posix_time::ptime eventTime(); ///< Return timestamp of the currently processing
///< event
+ void destroy();
+
+ virtual void macro_SENF_PPI_MODULE_missing() = 0;
+
private:
virtual void init();
friend class senf::ppi::ModuleManager;
};
- /** \brief Connect compatible connectors
-
- connect() will connect two compatible connectors: One connector must be active, the other
- passive.
- */
- template <class Source, class Target>
- void connect(Source const & source, Target const & target);
+# define SENF_PPI_MODULE(name) \
+ public: \
+ ~ name() { destroy(); } \
+ void macro_SENF_PPI_MODULE_missing() {} \
+ private:
}}}
namespace {
class TestModule : public ppi::module::Module
{
+ SENF_PPI_MODULE(TestModule);
+
public:
connector::ActiveOutput output;
namespace {
class RouteTester : public module::Module
{
+ SENF_PPI_MODULE(RouteTester);
+
public:
connector::ActiveInput activeIn;
connector::PassiveInput passiveIn;
class ActiveSocketReader
: public Module
{
+ SENF_PPI_MODULE(ActiveSocketReader);
+
public:
typedef typename Reader::Handle Handle; ///< Handle type requested by the reader
template <class Writer=PacketWriter>
class ActiveSocketWriter : public Module
{
+ SENF_PPI_MODULE(ActiveSocketWriter);
+
public:
typedef typename Writer::Handle Handle; ///< Handle type requested by writer
template <class Writer=PacketWriter>
class PassiveSocketWriter : public Module
{
+ SENF_PPI_MODULE(PassiveSocketWriter);
+
public:
typedef typename Writer::Handle Handle; ///< Handle type requested by writer
senf::UDPv4ClientSocketHandle inputSocket;
inputSocket.bind(senf::INet4SocketAddress("localhost:44344"));
- inputSocket.blocking(false);
senf::ppi::init();
source.submit(p);
senf::UDPv4ClientSocketHandle inputSocket;
inputSocket.bind(senf::INet4SocketAddress("localhost:44344"));
- inputSocket.blocking(false);
- senf::Scheduler::instance().timeout(1000, &timeout);
+ senf::Scheduler::instance().timeout(100, &timeout);
source.submit(p);
senf::ppi::run();
\brief EventBinding inline non-template implementation */
// Custom includes
+#include "../Events.hh"
#define prefix_ inline
///////////////////////////////cci.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// senf::ppi::detail::EventBindingBase
+prefix_ senf::ppi::detail::EventBindingBase::~EventBindingBase()
+{
+ descriptor_->enabled(false);
+}
+
////////////////////////////////////////
// protected members
// c-file-style: "senf"
// indent-tabs-mode: nil
// ispell-local-dictionary: "american"
-// compile-command: "scons -u test"
+// compile-command: "scons -u ../test"
// End:
class EventBindingBase
{
+ public:
+ ~EventBindingBase();
+
protected:
EventBindingBase(EventManager & manager, module::Module & module,
EventDescriptor & descriptor);
EventManager * manager_;
module::Module * module_;
EventDescriptor * descriptor_;
+
+ friend class senf::ppi::EventManager;
};
template <class EventType, class Self>