From: g0dil Date: Tue, 17 Mar 2009 18:00:32 +0000 (+0000) Subject: PPI: Allow to change the IOEvent handle/event mask X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=42a8e0da20196d7e74d701c1fb448a9946014686;p=senf.git PPI: Allow to change the IOEvent handle/event mask PPI: Allow initialization of jacks from another jack PPI: Allow changing the associated handle of an ActiveSocketSource git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1157 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/IOEvent.cc b/PPI/IOEvent.cc index f63288d..ea70efc 100644 --- a/PPI/IOEvent.cc +++ b/PPI/IOEvent.cc @@ -41,12 +41,14 @@ prefix_ void senf::ppi::IOEvent::v_enable() { - event_.enable(); + if (fd_ != -1) + event_.enable(); } prefix_ void senf::ppi::IOEvent::v_disable() { - event_.disable(); + if (fd_ != -1) + event_.disable(); } prefix_ void senf::ppi::IOEvent::cb(int event) diff --git a/PPI/IOEvent.cci b/PPI/IOEvent.cci new file mode 100644 index 0000000..54b1c86 --- /dev/null +++ b/PPI/IOEvent.cci @@ -0,0 +1,50 @@ +// $Id$ +// +// Copyright (C) 2009 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// 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 non-template implementation */ + +//#include "IOEvent.ih" + +// Custom includes + +#define prefix_ inline +///////////////////////////////cci.p/////////////////////////////////////// + +prefix_ senf::ppi::IOEvent::IOEvent() + : fd_ (-1), + event_ ("senf::ppi::IOEvent", boost::bind(&IOEvent::cb,this,_1)) +{} + +///////////////////////////////cci.e/////////////////////////////////////// +#undef prefix_ + + +// 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: diff --git a/PPI/IOEvent.cti b/PPI/IOEvent.cti index 7372e36..5f36a06 100644 --- a/PPI/IOEvent.cti +++ b/PPI/IOEvent.cti @@ -40,6 +40,19 @@ prefix_ senf::ppi::IOEvent::IOEvent(Handle handle, unsigned events) event_ ("senf::ppi::IOEvent", boost::bind(&IOEvent::cb,this,_1), fd_, events, false) {} +template +prefix_ void senf::ppi::IOEvent::set(Handle handle, unsigned events) +{ + if (handle) { + fd_ = senf::scheduler::get_descriptor(handle); + event_.events(events).handle(fd_); + } + else { + event_.disable(); + fd_ = -1; + } +} + ///////////////////////////////cti.e/////////////////////////////////////// #undef prefix_ diff --git a/PPI/IOEvent.hh b/PPI/IOEvent.hh index 7b3bf48..730b66b 100644 --- a/PPI/IOEvent.hh +++ b/PPI/IOEvent.hh @@ -88,12 +88,17 @@ namespace ppi { ///\name Structors and default members ///@{ + IOEvent(); + template IOEvent(Handle handle, unsigned events); ///@} /////////////////////////////////////////////////////////////////////////// + template + void set(Handle handle, unsigned events); + /** \brief Unhandled error condition */ struct ErrorException : public senf::Exception { ErrorException() : senf::Exception("senf::ppi::IOEvent::ErrorException"){} }; diff --git a/PPI/Jack.cti b/PPI/Jack.cti index 220df86..2266a57 100644 --- a/PPI/Jack.cti +++ b/PPI/Jack.cti @@ -43,8 +43,26 @@ senf::ppi::connector::ActiveInputJack::ActiveInputJack(ActiveInput<> : GenericActiveInputJack (input) {} -prefix_ senf::ppi::connector::ActiveInputJack::ActiveInputJack(ActiveInput<> & input) - : GenericActiveInputJack (input) +template +prefix_ +senf::ppi::connector::ActiveInputJack::ActiveInputJack(ActiveInputJack & input) + : GenericActiveInputJack (input.connector()) +{} + +template +prefix_ +senf::ppi::connector::ActiveInputJack::ActiveInputJack(ActiveInputJack<> & input) + : GenericActiveInputJack (input.connector()) +{} + +prefix_ +senf::ppi::connector::ActiveInputJack::ActiveInputJack(ActiveInput<> & input) + : GenericActiveInputJack (input) +{} + +prefix_ +senf::ppi::connector::ActiveInputJack::ActiveInputJack(ActiveInputJack & input) + : GenericActiveInputJack (input.connector()) {} template @@ -59,9 +77,26 @@ senf::ppi::connector::ActiveOutputJack::ActiveOutputJack(ActiveOutpu : GenericActiveOutputJack (output) {} -prefix_ -senf::ppi::connector::ActiveOutputJack::ActiveOutputJack(ActiveOutput<> & output) - : GenericActiveOutputJack (output) +template +prefix_ senf::ppi::connector::ActiveOutputJack:: +ActiveOutputJack(ActiveOutputJack & output) + : GenericActiveOutputJack (output.connector()) +{} + +template +prefix_ senf::ppi::connector::ActiveOutputJack:: +ActiveOutputJack(ActiveOutputJack<> & output) + : GenericActiveOutputJack (output.connector()) +{} + +prefix_ senf::ppi::connector::ActiveOutputJack:: +ActiveOutputJack(ActiveOutput<> & output) + : GenericActiveOutputJack (output) +{} + +prefix_ senf::ppi::connector::ActiveOutputJack:: +ActiveOutputJack(ActiveOutputJack & output) + : GenericActiveOutputJack (output.connector()) {} template @@ -76,11 +111,28 @@ senf::ppi::connector::PassiveInputJack::PassiveInputJack(PassiveInpu : GenericPassiveInputJack (input) {} +template +prefix_ +senf::ppi::connector::PassiveInputJack::PassiveInputJack(PassiveInputJack & input) + : GenericPassiveInputJack (input.connector()) +{} + +template +prefix_ senf::ppi::connector::PassiveInputJack:: +PassiveInputJack(PassiveInputJack<> & input) + : GenericPassiveInputJack (input.connector()) +{} + prefix_ senf::ppi::connector::PassiveInputJack::PassiveInputJack(PassiveInput<> & input) : GenericPassiveInputJack (input) {} +prefix_ senf::ppi::connector::PassiveInputJack:: +PassiveInputJack(PassiveInputJack & input) + : GenericPassiveInputJack (input.connector()) +{} + template prefix_ senf::ppi::connector::PassiveOutputJack:: PassiveOutputJack(PassiveOutput & output) @@ -93,9 +145,26 @@ PassiveOutputJack(PassiveOutput<> & output) : GenericPassiveOutputJack (output) {} -prefix_ -senf::ppi::connector::PassiveOutputJack::PassiveOutputJack(PassiveOutput<> & output) - : GenericPassiveOutputJack (output) +template +prefix_ senf::ppi::connector::PassiveOutputJack:: +PassiveOutputJack(PassiveOutputJack & output) + : GenericPassiveOutputJack (output.connector()) +{} + +template +prefix_ senf::ppi::connector::PassiveOutputJack:: +PassiveOutputJack(PassiveOutputJack<> & output) + : GenericPassiveOutputJack (output.connector()) +{} + +prefix_ senf::ppi::connector::PassiveOutputJack:: +PassiveOutputJack(PassiveOutput<> & output) + : GenericPassiveOutputJack (output) +{} + +prefix_ senf::ppi::connector::PassiveOutputJack:: +PassiveOutputJack(PassiveOutputJack & output) + : GenericPassiveOutputJack (output.connector()) {} template diff --git a/PPI/Jack.hh b/PPI/Jack.hh index 5cfbc12..83657ba 100644 --- a/PPI/Jack.hh +++ b/PPI/Jack.hh @@ -97,6 +97,9 @@ namespace connector { public: explicit ActiveInputJack(ActiveInput & input); explicit ActiveInputJack(ActiveInput<> & input); + + explicit ActiveInputJack(ActiveInputJack & input); + explicit ActiveInputJack(ActiveInputJack<> & input); }; #ifndef DOXYGEN @@ -107,6 +110,7 @@ namespace connector { { public: explicit ActiveInputJack(ActiveInput<> & input); + explicit ActiveInputJack(ActiveInputJack & input); }; #endif @@ -118,6 +122,9 @@ namespace connector { public: explicit ActiveOutputJack(ActiveOutput & output); explicit ActiveOutputJack(ActiveOutput<> & output); + + explicit ActiveOutputJack(ActiveOutputJack & output); + explicit ActiveOutputJack(ActiveOutputJack<> & output); }; #ifndef DOXYGEN @@ -128,6 +135,7 @@ namespace connector { { public: explicit ActiveOutputJack(ActiveOutput<> & output); + explicit ActiveOutputJack(ActiveOutputJack & output); }; #endif @@ -139,6 +147,9 @@ namespace connector { public: explicit PassiveInputJack(PassiveInput & input); explicit PassiveInputJack(PassiveInput<> & input); + + explicit PassiveInputJack(PassiveInputJack & input); + explicit PassiveInputJack(PassiveInputJack<> & input); }; #ifndef DOXYGEN @@ -149,6 +160,7 @@ namespace connector { { public: explicit PassiveInputJack(PassiveInput<> & input); + explicit PassiveInputJack(PassiveInputJack & input); }; #endif @@ -160,6 +172,9 @@ namespace connector { public: explicit PassiveOutputJack(PassiveOutput & output); explicit PassiveOutputJack(PassiveOutput<> & output); + + explicit PassiveOutputJack(PassiveOutputJack & output); + explicit PassiveOutputJack(PassiveOutputJack<> & output); }; #ifndef DOXYGEN @@ -170,6 +185,7 @@ namespace connector { { public: explicit PassiveOutputJack(PassiveOutput<> & output); + explicit PassiveOutputJack(PassiveOutputJack & output); }; #endif diff --git a/PPI/SocketSource.ct b/PPI/SocketSource.ct index eb69a5d..7ea5506 100644 --- a/PPI/SocketSource.ct +++ b/PPI/SocketSource.ct @@ -45,9 +45,18 @@ prefix_ Packet senf::ppi::DgramReader::operator()(Handle handle) // senf::ppi::module::ActiveSocketSource template +prefix_ senf::ppi::module::ActiveSocketSource::ActiveSocketSource() +{} + +template +prefix_ senf::ppi::module::ActiveSocketSource::ActiveSocketSource(Reader reader) + : reader_(reader) +{} + +template prefix_ senf::ppi::module::ActiveSocketSource:: ActiveSocketSource(Handle handle) - : handle_(handle), event_(handle_, IOEvent::Read), reader_() + : handle_(handle), event_(handle_, IOEvent::Read) { registerEvent( event_, &ActiveSocketSource::read ); route(event_, output); diff --git a/PPI/SocketSource.cti b/PPI/SocketSource.cti index 90e89e0..8bb2e7c 100644 --- a/PPI/SocketSource.cti +++ b/PPI/SocketSource.cti @@ -39,6 +39,20 @@ prefix_ Reader & senf::ppi::module::ActiveSocketSource::reader() return reader_; } +template +prefix_ typename senf::ppi::module::ActiveSocketSource::Handle +senf::ppi::module::ActiveSocketSource::handle() +{ + return handle_; +} + +template +prefix_ void senf::ppi::module::ActiveSocketSource::handle(Handle handle) +{ + handle_ = handle; + event_.set(handle_, IOEvent::Read); +} + ///////////////////////////////cti.e/////////////////////////////////////// #undef prefix_ diff --git a/PPI/SocketSource.hh b/PPI/SocketSource.hh index 44368fb..3c78d58 100644 --- a/PPI/SocketSource.hh +++ b/PPI/SocketSource.hh @@ -116,7 +116,13 @@ namespace module { connector::ActiveOutput output; ///< Output connector to which the data received is written - ActiveSocketSource(Handle handle); ///< Create new reader for the given handle + ActiveSocketSource(); ///< Create non-connected reader + /**< The reader will be disabled until a socket is set + \pre Requires \a Reader to be default constructible */ + explicit ActiveSocketSource(Reader reader); ///< Create non-connected reader + /**< The reader will be disabled until a socket is set + \pre Requires \a Reader to be copy constructible */ + explicit ActiveSocketSource(Handle handle); ///< Create new reader for the given handle /**< Data will be read from \a handle and be parsed by \a Reader. \pre Requires \a Reader to be default constructible @@ -129,6 +135,10 @@ namespace module { \param[in] handle Handle to read data from */ Reader & reader(); ///< Access Reader helper + Handle handle(); ///< Access handle + void handle(Handle handle); ///< Set handle + /**< Assigning an empty or in-valid() handle will disable + the module until a new, valid handle is assigned. */ private: void read(); diff --git a/SConstruct b/SConstruct index 2acf3d7..5fe796b 100644 --- a/SConstruct +++ b/SConstruct @@ -183,11 +183,6 @@ if not env.GetOption('clean') and not os.path.exists(".prepare-stamp") \ env.Clean('all', '.prepare-stamp') -# Not nice, but until we get to fixing the dependency jungle -# concerning generated sources ... -scripts = [] -dependencies = [] - SConscript(glob.glob("*/SConscript")) SENFSCons.StandardTargets(env)