Skip to content
Snippets Groups Projects
Commit 21a05ab9 authored by g0dil's avatar g0dil
Browse files

Utils/Exception: Allow to disable ErrnoExceptions via SENF_NO_ERRNOEXC

PPI: Allow access to source/sink helper in (Active|Passive)Socket(Source|Sink)
parent 8e1abab7
No related branches found
No related tags found
No related merge requests found
......@@ -37,11 +37,27 @@
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,
......@@ -57,27 +73,6 @@ namespace ppi {
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
......
......@@ -41,6 +41,15 @@ prefix_ senf::ppi::module::ActiveSocketSink<Sink>::ActiveSocketSink(Handle handl
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
......@@ -61,6 +70,15 @@ prefix_ senf::ppi::module::PassiveSocketSink<Sink>::PassiveSocketSink(Handle han
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
......
// $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_
// 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:
......@@ -82,7 +82,10 @@ namespace module {
{
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
......@@ -102,7 +105,18 @@ namespace module {
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();
......@@ -128,7 +142,10 @@ namespace module {
{
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
......@@ -148,7 +165,15 @@ namespace module {
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();
......@@ -163,7 +188,7 @@ namespace module {
///////////////////////////////hh.e////////////////////////////////////////
#include "SocketSink.cci"
#include "SocketSink.ct"
//#include "SocketSink.cti"
#include "SocketSink.cti"
#endif
......
......@@ -53,6 +53,15 @@ ActiveSocketSource(Handle handle)
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
......
// $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_
// 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:
......@@ -87,9 +87,12 @@ namespace module {
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
......@@ -111,8 +114,17 @@ namespace module {
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();
......@@ -126,7 +138,7 @@ namespace module {
///////////////////////////////hh.e////////////////////////////////////////
//#include "SocketSource.cci"
#include "SocketSource.ct"
//#include "SocketSource.cti"
#include "SocketSource.cti"
#endif
......
......@@ -112,6 +112,7 @@ debsrc Build debian source package
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'):
......
......@@ -35,6 +35,7 @@
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
......@@ -61,6 +62,9 @@ prefix_ void senf::throwErrno(std::string const & where, int code)
default:
throw SystemException(where, code);
}
#else
throw SystemException(where, code);
#endif
}
///////////////////////////////cc.e////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment