namespace senf {
namespace ppi {
-#ifndef DOXYGEN
+ /** \brief Connect modules
+
+ senf::ppi::connect() establishes a connection between two modules or, to be more precise,
+ between two connectors. It will connect any input to any output connector as long as one is
+ active and the other passive.
+ If a module has an output connector called \c output, the module may be directly specified
+ as \a source argument. In the same way, if a module has an input connector called \c input,
+ the module may be given directly as \a target argument. This simplifies the most common case
+ of a module with one input and one output connector.
+
+ \see \ref ppi_connections
+ */
void connect(connector::ActiveOutput & source, connector::PassiveInput & target);
+
+ /** \brief Connect modules
+ \see connect() */
void connect(connector::PassiveOutput & source, connector::ActiveInput & target);
-
+
+#ifndef DOXYGEN
+
template <class T, class C>
void connect(T & source, C & target,
typename boost::disable_if< boost::is_base_of<connector::Connector, T> >::type * = 0,
typename boost::disable_if< boost::is_base_of<connector::Connector, T1> >::type * = 0,
typename boost::disable_if< boost::is_base_of<connector::Connector, T2> >::type * = 0);
-#else
-
- /** \brief Connect modules
-
- senf::ppi::connect() establishes a connection between two modules or, to be more precise,
- between two connectors. It will connect any input to any output connector as long as one is
- active and the other passive.
-
- If a module has an output connector called \c output, the module may be directly specified
- as \a source argument. In the same way, if a module has an input connector called \c input,
- the module may be given directly as \a target argument. This simplifies the most common case
- of a module with one input and one output connector.
-
- \see \ref ppi_connections
- */
- void connect(connector::ActiveInput & source, connector::PassiveOutput & target);
-
- /** \brief Connect modules
- \see connect() */
- void connect(connector::PassiveInput & source, connector::ActiveOutput & target);
-
#endif
/** \brief Start the network
route(input, event_);
}
+template <class Sink>
+prefix_ senf::ppi::module::ActiveSocketSink<Sink>::ActiveSocketSink(Handle handle,
+ Sink const & sink)
+ : handle_(handle), event_(handle_, IOEvent::Write), writer_(sink)
+{
+ registerEvent( event_, &ActiveSocketSink::write );
+ route(input, event_);
+}
+
////////////////////////////////////////
// private members
input.onRequest(&PassiveSocketSink::write);
}
+template <class Sink>
+prefix_ senf::ppi::module::PassiveSocketSink<Sink>::PassiveSocketSink(Handle handle,
+ Sink const & sink)
+ : handle_(handle), writer_(sink)
+{
+ noroute(input);
+ input.onRequest(&PassiveSocketSink::write);
+}
+
////////////////////////////////////////
// private members
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer NETwork research (NET)
+// 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 SocketSink inline template implementation */
+
+//#include "SocketSink.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::ActiveSocketSink<Sink>
+
+template <class Sink>
+prefix_ Sink & senf::ppi::module::ActiveSocketSink<Sink>::sink()
+{
+ return writer_;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::PassiveSocketSink<Sink>
+
+template <class Sink>
+prefix_ Sink & senf::ppi::module::PassiveSocketSink<Sink>::sink()
+{
+ return writer_;
+}
+
+///////////////////////////////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:
{
public:
typedef unspecified Handle; // type of handle requested
- SomeSink(); // default constructible
+
+ SomeSink(); // EITHER default constructible OR
+ SomeSink(SomeSink const & other); // copy constructible
+
void operator()(Handle handle, Packet packet); // insertion function
};
\endcode
ActiveSocketSink(Handle handle); ///< Create new writer for the given handle
/**< Data will be written to \a handle using \a Sink.
+ \pre Requires \a Sink to be default constructible
\param[in] handle Handle to write data to */
+ ActiveSocketSink(Handle handle, Sink const & sink);
+ ///< Create new writer for the given handle
+ /**< Data will be written to \a handle using \a Sink.
+ \pre Requires \a Sink to be copy constructible
+ \param[in] handle Handle to write data to
+ \param[in] sink Sink helper writing packet date to the
+ socket */
+
+ Sink & sink(); ///< Access the sink helper
+
private:
void write();
{
public:
typedef unspecified Handle; // type of handle requested
- SomeSink(); // default constructible
+
+ SomeSink(); // EITHER default constructible
+ SomeSink(SomeSink const & other); // OR copy constructible
+
void operator()(Handle handle, Packet packet); // insertion function
};
\endcode
PassiveSocketSink(Handle handle); ///< Create new writer for the given handle
/**< Data will be written to \a handle using \a Sink.
+ \pre Requires \a Sink to be default constructible
\param[in] handle Handle to write data to */
+ PassiveSocketSink(Handle handle, Sink const & sink);
+ ///< Create new writer for the given handle
+ /**< Data will be written to \a handle using \a Sink.
+ \pre Requires \a Sink to be copy constructible
+ \param[in] handle Handle to write data to */
+
+ Sink & sink(); ///< Access the sink helper
private:
void write();
///////////////////////////////hh.e////////////////////////////////////////
#include "SocketSink.cci"
#include "SocketSink.ct"
-//#include "SocketSink.cti"
+#include "SocketSink.cti"
#endif
\f
route(event_, output);
}
+template <class Source>
+prefix_ senf::ppi::module::ActiveSocketSource<Source>::ActiveSocketSource(Handle handle,
+ Source source)
+ : handle_(handle), event_(handle_, IOEvent::Read), reader_(source)
+{
+ registerEvent( event_, &ActiveSocketSource::read );
+ route(event_, output);
+}
+
////////////////////////////////////////
// private members
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer NETwork research (NET)
+// 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 SocketSource inline template implementation */
+
+//#include "SocketSource.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::ActiveSocketSource<Source>
+
+template <class Source>
+prefix_ Source & senf::ppi::module::ActiveSocketSource<Source>::source()
+{
+ return reader_;
+}
+
+///////////////////////////////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:
class SomeSource
{
public:
- typedef unspecified_type Handle; // type of handle requested
- SomeSource(); // default constructible
- Packet operator()(Handle handle); // extraction function
+ typedef unspecified_type Handle; // type of handle requested
+
+ SomeSource(); // EITHER default constructible
+ SomeSource(SomeSource const & other); // OR copy constructible
+
+ Packet operator()(Handle handle); // extraction function
};
\endcode
Whenever the FileHandle object is ready for reading, the \a Source's \c operator() is called
ActiveSocketSource(Handle handle); ///< Create new reader for the given handle
/**< Data will be read from \a handle and be parsed by \a
Source.
+ \pre Requires \a Source to be default constructible
+ \param[in] handle Handle to read data from */
+ ActiveSocketSource(Handle handle, Source source);
+ ///< Create new reader for the given handle
+ /**< Data will be read from \a handle and be parsed by \a
+ Source.
+ \pre Requires \a Source to be copy constructible
\param[in] handle Handle to read data from */
+ Source & source(); ///< Access source helper
+
private:
void read();
///////////////////////////////hh.e////////////////////////////////////////
//#include "SocketSource.cci"
#include "SocketSource.ct"
-//#include "SocketSource.cti"
+#include "SocketSource.cti"
#endif
\f
debbin Build debian binary package
linklint Check links of doxygen documentation with 'linklint'
fixlinks Fix broken links in doxygen documentation
+valgrind Run all tests under valgrind/memcheck
""")
if os.environ.get('debian_build'):
prefix_ void senf::throwErrno(std::string const & where, int code)
{
+#ifndef SENF_NO_ERRNOEXC
switch (code) {
// BOOST_PP_REPEAT is limited to 256 repetitions. The max errno value I found in any header file
default:
throw SystemException(where, code);
}
+#else
+ throw SystemException(where, code);
+#endif
}
///////////////////////////////cc.e////////////////////////////////////////