From: tho Date: Mon, 2 Aug 2010 12:34:03 +0000 (+0000) Subject: PPI: introduced SENF_PPI_NOTRACE define X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=32bf29e751e6c73ca2bc78c21996e4320e934673 PPI: introduced SENF_PPI_NOTRACE define Socket,PPI: pass handle parameter by reference git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1655 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/.project b/.project index 144c5b8..35e578c 100644 --- a/.project +++ b/.project @@ -6,6 +6,11 @@ + org.python.pydev.PyDevBuilder + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, @@ -23,15 +28,15 @@ org.eclipse.cdt.make.core.buildArguments - + scons -j2 org.eclipse.cdt.make.core.buildCommand - make + nice org.eclipse.cdt.make.core.cleanBuildTarget - clean + -c org.eclipse.cdt.make.core.contents @@ -51,7 +56,7 @@ org.eclipse.cdt.make.core.fullBuildTarget - build + default org.eclipse.cdt.make.core.stopOnError @@ -59,7 +64,7 @@ org.eclipse.cdt.make.core.useDefaultBuildCmd - true + false @@ -74,5 +79,6 @@ org.eclipse.cdt.managedbuilder.core.managedBuildNature org.eclipse.cdt.core.cnature org.eclipse.cdt.core.ccnature + org.python.pydev.pythonNature diff --git a/SConstruct b/SConstruct index 3d97d47..08a96af 100644 --- a/SConstruct +++ b/SConstruct @@ -104,7 +104,7 @@ env.Append( CPPDEFINES = [ '$expandLogOption', '$CPPDEFINES_' ], expandLogOption = senfutil.expandLogOption, CPPDEFINES_ = senfutil.BuildTypeOptions('CPPDEFINES'), - CPPDEFINES_final = [ ], + CPPDEFINES_final = [ 'SENF_PPI_NOTRACE'], CPPDEFINES_normal = [ 'SENF_DEBUG' ], CPPDEFINES_debug = [ '$CPPDEFINES_normal' ], diff --git a/senf/PPI/Connectors.cc b/senf/PPI/Connectors.cc index 0813b41..0ee44f5 100644 --- a/senf/PPI/Connectors.cc +++ b/senf/PPI/Connectors.cc @@ -80,7 +80,7 @@ senf::ppi::connector::Connector::TraceState senf::ppi::connector::Connector::tra prefix_ void senf::ppi::connector::Connector::trace(Packet const & p, char const * label) { - if (traceState_ == NO_TRACING) + if (traceState_ == NO_TRACING) return; SENF_LOG_BLOCK(({ std::string type (prettyName(p.typeId().id())); @@ -119,6 +119,7 @@ namespace { ConsoleRegister::ConsoleRegister() { +#ifndef SENF_PPI_NOTRACE senf::ppi::ModuleManager::instance().consoleDir() .add("tracing", senf::console::factory::Command( SENF_FNP(senf::ppi::connector::Connector::TraceState, @@ -158,6 +159,7 @@ namespace { (senf::ppi::connector::Connector::TraceState))) .arg("state", "new tracing state") ); +#endif } ConsoleRegister consoleRegister; @@ -224,7 +226,7 @@ prefix_ void senf::ppi::connector::PassiveConnector::notifyUnthrottle() if (!nativeThrottled_) emitUnthrottle(); } else - throttleTrace("OUT", "not forwarding unthrottle event"); + SENF_PPI_THROTTLE_TRACE("OUT", "not forwarding unthrottle event"); } /////////////////////////////////////////////////////////////////////////// @@ -241,7 +243,7 @@ prefix_ void senf::ppi::connector::ActiveConnector::v_init() prefix_ void senf::ppi::connector::ActiveConnector::notifyThrottle() { - throttleTrace("IN ", "throttle"); + SENF_PPI_THROTTLE_TRACE("IN ", "throttle"); if (! throttled_) { throttled_ = true; if (throttleCallback_) @@ -255,7 +257,7 @@ prefix_ void senf::ppi::connector::ActiveConnector::notifyThrottle() prefix_ void senf::ppi::connector::ActiveConnector::notifyUnthrottle() { - throttleTrace("IN ", "unthrottle"); + SENF_PPI_THROTTLE_TRACE("IN ", "unthrottle"); if (throttled_) { throttled_ = false; if (unthrottleCallback_) @@ -292,7 +294,7 @@ prefix_ senf::Packet senf::ppi::connector::InputConnector::operator()() queue_.pop_back(); v_dequeueEvent(); } - trace(p, "IN "); + SENF_PPI_TRACE(p, "IN "); return p; } diff --git a/senf/PPI/Connectors.cci b/senf/PPI/Connectors.cci index 986a2a4..16948c0 100644 --- a/senf/PPI/Connectors.cci +++ b/senf/PPI/Connectors.cci @@ -31,6 +31,14 @@ #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// +#ifdef SENF_PPI_NOTRACE +# define SENF_PPI_THROTTLE_TRACE(label, type) +# define SENF_PPI_TRACE(packet, label) +#else +# define SENF_PPI_THROTTLE_TRACE(label, type) throttleTrace(label, type) +# define SENF_PPI_TRACE(packet, label) trace(packet, label) +#endif + /////////////////////////////////////////////////////////////////////////// // senf::ppi::connector::Connector @@ -119,14 +127,14 @@ prefix_ bool senf::ppi::connector::PassiveConnector::throttled() prefix_ void senf::ppi::connector::PassiveConnector::emitThrottle() { - throttleTrace("OUT", "throttle"); + SENF_PPI_THROTTLE_TRACE("OUT", "throttle"); if (connected()) peer().notifyThrottle(); } prefix_ void senf::ppi::connector::PassiveConnector::emitUnthrottle() { - throttleTrace("OUT", "unthrottle"); + SENF_PPI_THROTTLE_TRACE("OUT", "unthrottle"); if (connected()) { peer().notifyUnthrottle(); v_unthrottleEvent(); @@ -193,10 +201,11 @@ prefix_ void senf::ppi::connector::PassiveConnector::emit() { // No event callback has been registered (onRequest() call missing) SENF_ASSERT(callback_, "senf::ppi::connector::PassiveConnector: missing onRequest()"); - if (!throttled()) + if (!throttled()) { callback_(); - else - throttleTrace("IN ", "queueing packet"); + } else { + SENF_PPI_THROTTLE_TRACE("IN ", "queueing packet"); + } } /////////////////////////////////////////////////////////////////////////// @@ -307,7 +316,7 @@ prefix_ senf::ppi::connector::InputConnector & senf::ppi::connector::OutputConne prefix_ void senf::ppi::connector::OutputConnector::operator()(Packet const & p) { - trace(p, "OUT"); + SENF_PPI_TRACE(p, "OUT"); if (connected()) peer().enqueue(p); } diff --git a/senf/PPI/QueueingSocketSink.ct b/senf/PPI/QueueingSocketSink.ct index 93a412e..594c501 100644 --- a/senf/PPI/QueueingSocketSink.ct +++ b/senf/PPI/QueueingSocketSink.ct @@ -56,7 +56,7 @@ prefix_ senf::ppi::QueueingAlgorithm::ptr senf::ppi::detail::QueueingAlgorithmRe // senf::ppi::module::PassiveQueueingSocketSink template -prefix_ senf::ppi::module::PassiveQueueingSocketSink::PassiveQueueingSocketSink(Handle handle, QueueingAlgorithm::ptr qAlgorithm) +prefix_ senf::ppi::module::PassiveQueueingSocketSink::PassiveQueueingSocketSink(Handle const & handle, QueueingAlgorithm::ptr qAlgorithm) : dir( this), handle_( handle), writer_( ), qAlgo_( qAlgorithm), @@ -138,4 +138,4 @@ prefix_ void senf::ppi::module::PassiveQueueingSocketSink::setQAlgorithm // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" -// End: +// End:: diff --git a/senf/PPI/QueueingSocketSink.cti b/senf/PPI/QueueingSocketSink.cti index 481ff99..c131ab7 100644 --- a/senf/PPI/QueueingSocketSink.cti +++ b/senf/PPI/QueueingSocketSink.cti @@ -56,7 +56,7 @@ prefix_ typename Writer::Handle & senf::ppi::module::PassiveQueueingSocketSink -prefix_ void senf::ppi::module::PassiveQueueingSocketSink::handle(Handle handle) +prefix_ void senf::ppi::module::PassiveQueueingSocketSink::handle(Handle const & handle) { handle_ = handle; event_.set( handle_, IOEvent::Write); diff --git a/senf/PPI/QueueingSocketSink.hh b/senf/PPI/QueueingSocketSink.hh index 83de20f..6d6ed8d 100644 --- a/senf/PPI/QueueingSocketSink.hh +++ b/senf/PPI/QueueingSocketSink.hh @@ -146,11 +146,12 @@ namespace module { connector::PassiveInput input; ///< Input connector from which data is received console::ScopedDirectory > dir; - explicit PassiveQueueingSocketSink(Handle handle, QueueingAlgorithm::ptr qAlgorithm); + explicit PassiveQueueingSocketSink(Handle const & handle, QueueingAlgorithm::ptr qAlgorithm); Writer & writer(); ///< Access the Writer Handle & handle(); ///< Access handle - void handle(Handle handle); ///< Set handle + void handle(Handle const & handle); + ///< Set handle /**< Assigning an empty or in-valid() handle will disable the module until a new valid handle is assigned. */ QueueingAlgorithm & qAlgorithm(); diff --git a/senf/PPI/SocketSink.cc b/senf/PPI/SocketSink.cc index b02f7e9..7e5e173 100644 --- a/senf/PPI/SocketSink.cc +++ b/senf/PPI/SocketSink.cc @@ -54,7 +54,7 @@ prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::destination(senf::INet4Soc protocolId_ = dest.port(); } -prefix_ bool senf::ppi::IPv4SourceForcingDgramWriter::operator()(Handle handle, +prefix_ bool senf::ppi::IPv4SourceForcingDgramWriter::operator()(Handle & handle, Packet const & packet) { return sendtoandfrom( @@ -133,7 +133,7 @@ prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::destination(senf::INet6Soc protocolId_ = dest.port(); } -prefix_ bool senf::ppi::IPv6SourceForcingDgramWriter::operator()(Handle handle, +prefix_ bool senf::ppi::IPv6SourceForcingDgramWriter::operator()(Handle & handle, Packet const & packet) { return sendtoandfrom( diff --git a/senf/PPI/SocketSink.cci b/senf/PPI/SocketSink.cci index b137100..80897f7 100644 --- a/senf/PPI/SocketSink.cci +++ b/senf/PPI/SocketSink.cci @@ -33,7 +33,7 @@ /////////////////////////////////////////////////////////////////////////// // senf::ppi::ConnectedDgramWriter -prefix_ bool senf::ppi::ConnectedDgramWriter::operator()(Handle handle, +prefix_ bool senf::ppi::ConnectedDgramWriter::operator()(Handle & handle, Packet const & packet) { return handle.write(packet.data()) != packet.data().begin(); diff --git a/senf/PPI/SocketSink.ct b/senf/PPI/SocketSink.ct index 4864625..1936ea3 100644 --- a/senf/PPI/SocketSink.ct +++ b/senf/PPI/SocketSink.ct @@ -49,7 +49,7 @@ prefix_ senf::ppi::module::ActiveSocketSink::ActiveSocketSink(Writer con } template -prefix_ senf::ppi::module::ActiveSocketSink::ActiveSocketSink(Handle handle) +prefix_ senf::ppi::module::ActiveSocketSink::ActiveSocketSink(Handle const & handle) : handle_(handle), event_(handle_, IOEvent::Write), writer_() { registerEvent( event_, &ActiveSocketSink::write ); @@ -57,7 +57,7 @@ prefix_ senf::ppi::module::ActiveSocketSink::ActiveSocketSink(Handle han } template -prefix_ senf::ppi::module::ActiveSocketSink::ActiveSocketSink(Handle handle, +prefix_ senf::ppi::module::ActiveSocketSink::ActiveSocketSink(Handle const & handle, Writer const & writer) : handle_(handle), event_(handle_, IOEvent::Write), writer_(writer) { @@ -95,7 +95,7 @@ prefix_ senf::ppi::module::PassiveSocketSink::PassiveSocketSink(Writer c } template -prefix_ senf::ppi::module::PassiveSocketSink::PassiveSocketSink(Handle handle) +prefix_ senf::ppi::module::PassiveSocketSink::PassiveSocketSink(Handle const & handle) : handle_(handle), writer_() { noroute(input); @@ -104,7 +104,7 @@ prefix_ senf::ppi::module::PassiveSocketSink::PassiveSocketSink(Handle h } template -prefix_ senf::ppi::module::PassiveSocketSink::PassiveSocketSink(Handle handle, +prefix_ senf::ppi::module::PassiveSocketSink::PassiveSocketSink(Handle const & handle, Writer const & writer) : handle_(handle), writer_(writer) { diff --git a/senf/PPI/SocketSink.cti b/senf/PPI/SocketSink.cti index 4e2ebf7..2b11387 100644 --- a/senf/PPI/SocketSink.cti +++ b/senf/PPI/SocketSink.cti @@ -59,7 +59,7 @@ senf::ppi::TargetDgramWriter::target(typename Handle::Address const } template -prefix_ bool senf::ppi::TargetDgramWriter::operator()(Handle handle, +prefix_ bool senf::ppi::TargetDgramWriter::operator()(Handle & handle, Packet const & packet) { if (target_) @@ -84,7 +84,7 @@ senf::ppi::module::ActiveSocketSink::handle() } template -prefix_ void senf::ppi::module::ActiveSocketSink::handle(Handle handle) +prefix_ void senf::ppi::module::ActiveSocketSink::handle(Handle const & handle) { handle_ = handle; event_.set(handle_, IOEvent::Write); @@ -106,7 +106,7 @@ prefix_ typename Writer::Handle & senf::ppi::module::PassiveSocketSink:: } template -prefix_ void senf::ppi::module::PassiveSocketSink::handle(Handle handle) +prefix_ void senf::ppi::module::PassiveSocketSink::handle(Handle const & handle) { handle_ = handle; checkThrottle(); diff --git a/senf/PPI/SocketSink.hh b/senf/PPI/SocketSink.hh index ab68990..7ee3b8e 100644 --- a/senf/PPI/SocketSink.hh +++ b/senf/PPI/SocketSink.hh @@ -58,7 +58,7 @@ namespace ppi { ///< Handle type supported by this writer typedef Packet PacketType; - bool operator()(Handle handle, Packet const & packet); + bool operator()(Handle & handle, Packet const & packet); ///< Write \a packet to \a handle /**< Write the complete \a packet as a datagram to \a handle. @@ -87,7 +87,7 @@ namespace ppi { typename Handle::Address target() const; ///< Get current target address void target(typename Handle::Address const & target); ///< Set target address - bool operator()(Handle handle, Packet const & packet); ///< Write \a packet to \a handle + bool operator()(Handle & handle, Packet const & packet); ///< Write \a packet to \a handle /**< Write the complete \a packet as a datagram to \a handle. \param[in] handle Handle to write data to @@ -113,7 +113,7 @@ namespace ppi { void destination(senf::INet4SocketAddress & dest); senf::INet4SocketAddress destination(); - bool operator()(Handle handle, Packet const & packet); + bool operator()(Handle & handle, Packet const & packet); ///< Write \a packet to \a handle /**< Write the complete \a packet as a datagram to \a handle. @@ -142,7 +142,7 @@ namespace ppi { void destination(senf::INet6SocketAddress & dest); senf::INet6SocketAddress destination(); - bool operator()(Handle handle, Packet const & packet); + bool operator()(Handle & handle, Packet const & packet); ///< Write \a packet to \a handle /**< Write the complete \a packet as a datagram to \a handle. @@ -210,11 +210,12 @@ namespace module { \pre Requires \a Writer to be copy constructible \param[in] writer Writer helper writing packet date to the socket */ - explicit ActiveSocketSink(Handle handle); ///< Create new writer for the given handle + explicit ActiveSocketSink(Handle const & handle); + ///< Create new writer for the given handle /**< Data will be written to \a handle using \a Writer. \pre Requires \a Writer to be default constructible \param[in] handle Handle to write data to */ - ActiveSocketSink(Handle handle, Writer const & writer); + ActiveSocketSink(Handle const & handle, Writer const & writer); ///< Create new writer for the given handle /**< Data will be written to \a handle using \a Writer. \pre Requires \a Writer to be copy constructible @@ -224,7 +225,8 @@ namespace module { Writer & writer(); ///< Access the Writer Handle handle(); ///< Access handle - void handle(Handle handle); ///< Set handle + void handle(Handle const & handle); + ///< Set handle /**< Assigning an empty or in-valid() handle will disable the module until a new. valid handle is assigned. */ @@ -286,11 +288,12 @@ namespace module { \pre Requires \a Writer to be copy constructible \param[in] writer Writer helper writing packet date to the socket */ - explicit PassiveSocketSink(Handle handle); ///< Create new writer for the given handle + explicit PassiveSocketSink(Handle const & handle); + ///< Create new writer for the given handle /**< Data will be written to \a handle using \a Writer. \pre Requires \a Writer to be default constructible \param[in] handle Handle to write data to */ - PassiveSocketSink(Handle handle, Writer const & writer); + PassiveSocketSink(Handle const & handle, Writer const & writer); ///< Create new writer for the given handle /**< Data will be written to \a handle using \a Writer. \pre Requires \a Writer to be copy constructible @@ -300,7 +303,8 @@ namespace module { Writer & writer(); ///< Access the Writer Handle & handle(); ///< Access handle - void handle(Handle handle); ///< Set handle + void handle(Handle const & handle); + ///< Set handle /**< Assigning an empty or in-valid() handle will disable the module until a new valid handle is assigned. */ diff --git a/senf/PPI/SocketSource.ct b/senf/PPI/SocketSource.ct index 6eb9780..8429bd9 100644 --- a/senf/PPI/SocketSource.ct +++ b/senf/PPI/SocketSource.ct @@ -34,7 +34,7 @@ // senf::ppi::DgramReader template -prefix_ Packet senf::ppi::DgramReader::operator()(Handle handle) +prefix_ Packet senf::ppi::DgramReader::operator()(Handle & handle) { Packet packet (Packet::create(senf::noinit)); handle.read(packet.data(), MaxSize); @@ -60,7 +60,7 @@ prefix_ senf::ppi::module::ActiveSocketSource::ActiveSocketSource(Reader } template -prefix_ senf::ppi::module::ActiveSocketSource::ActiveSocketSource(Handle handle) +prefix_ senf::ppi::module::ActiveSocketSource::ActiveSocketSource(Handle const & handle) : handle_(handle), event_(handle_, IOEvent::Read) { registerEvent( event_, &ActiveSocketSource::read ); @@ -68,7 +68,7 @@ prefix_ senf::ppi::module::ActiveSocketSource::ActiveSocketSource(Handle } template -prefix_ senf::ppi::module::ActiveSocketSource::ActiveSocketSource(Handle handle, +prefix_ senf::ppi::module::ActiveSocketSource::ActiveSocketSource(Handle const & handle, Reader reader) : handle_(handle), event_(handle_, IOEvent::Read), reader_(reader) { @@ -96,7 +96,7 @@ prefix_ senf::ppi::module::ActiveBurstSocketSource::ActiveBurstSocketSou } template -prefix_ senf::ppi::module::ActiveBurstSocketSource::ActiveBurstSocketSource(Handle handle, unsigned max_burst) +prefix_ senf::ppi::module::ActiveBurstSocketSource::ActiveBurstSocketSource(Handle const & handle, unsigned max_burst) : handle_(handle), event_(handle_, IOEvent::Read), maxBurst_(max_burst) { registerEvent( event_, &ActiveBurstSocketSource::read ); @@ -104,7 +104,7 @@ prefix_ senf::ppi::module::ActiveBurstSocketSource::ActiveBurstSocketSou } template -prefix_ senf::ppi::module::ActiveBurstSocketSource::ActiveBurstSocketSource(Handle handle, +prefix_ senf::ppi::module::ActiveBurstSocketSource::ActiveBurstSocketSource(Handle const & handle, Reader reader, unsigned max_burst) : handle_(handle), event_(handle_, IOEvent::Read), reader_(reader), maxBurst_(max_burst) { diff --git a/senf/PPI/SocketSource.cti b/senf/PPI/SocketSource.cti index 08f37bf..6403b03 100644 --- a/senf/PPI/SocketSource.cti +++ b/senf/PPI/SocketSource.cti @@ -47,7 +47,7 @@ senf::ppi::module::ActiveSocketSource::handle() } template -prefix_ void senf::ppi::module::ActiveSocketSource::handle(Handle handle) +prefix_ void senf::ppi::module::ActiveSocketSource::handle(Handle const & handle) { handle_ = handle; event_.set(handle_, IOEvent::Read); @@ -76,7 +76,7 @@ senf::ppi::module::ActiveBurstSocketSource::handle() } template -prefix_ void senf::ppi::module::ActiveBurstSocketSource::handle(Handle handle) +prefix_ void senf::ppi::module::ActiveBurstSocketSource::handle(Handle const & handle) { handle_ = handle; event_.set(handle_, IOEvent::Read); diff --git a/senf/PPI/SocketSource.hh b/senf/PPI/SocketSource.hh index c41e314..d6af335 100644 --- a/senf/PPI/SocketSource.hh +++ b/senf/PPI/SocketSource.hh @@ -59,7 +59,7 @@ namespace ppi { senf::DatagramFramingPolicy >::policy > Handle; ///< Handle type supported by this reader - Packet 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. @@ -122,12 +122,13 @@ namespace module { 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 + explicit ActiveSocketSource(Handle const & 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 \param[in] handle Handle to read data from */ - ActiveSocketSource(Handle handle, Reader reader); + ActiveSocketSource(Handle const & handle, Reader reader); ///< Create new reader for the given handle /**< Data will be read from \a handle and be parsed by \a Reader. @@ -136,7 +137,8 @@ namespace module { Reader & reader(); ///< Access Reader helper Handle handle(); ///< Access handle - void handle(Handle handle); ///< Set handle + void handle(Handle const & handle); + ///< Set handle /**< Assigning an empty or in-valid() handle will disable the module until a new, valid handle is assigned. */ private: @@ -162,12 +164,13 @@ namespace module { ActiveBurstSocketSource(unsigned max_burst); explicit ActiveBurstSocketSource(Reader reader, unsigned max_burst); - explicit ActiveBurstSocketSource(Handle handle, unsigned max_burst); - ActiveBurstSocketSource(Handle handle, Reader reader, unsigned max_burst); + explicit ActiveBurstSocketSource(Handle const & handle, unsigned max_burst); + ActiveBurstSocketSource(Handle const & handle, Reader reader, unsigned max_burst); Reader & reader(); ///< Access Reader helper Handle handle(); ///< Access handle - void handle(Handle handle); ///< Set handle + void handle(Handle const & handle); + ///< Set handle /**< Assigning an empty or in-valid() handle will disable the module until a new, valid handle is assigned. */ diff --git a/senf/Socket/CommunicationPolicy.cc b/senf/Socket/CommunicationPolicy.cc index f6efbcc..b5ce292 100644 --- a/senf/Socket/CommunicationPolicy.cc +++ b/senf/Socket/CommunicationPolicy.cc @@ -37,13 +37,13 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ void senf::ConnectedCommunicationPolicy::do_listen(FileHandle handle, +prefix_ void senf::ConnectedCommunicationPolicy::do_listen(FileHandle const & handle, unsigned backlog) { ::listen(handle.fd(),backlog); } -prefix_ int senf::ConnectedCommunicationPolicy::do_accept(FileHandle handle, +prefix_ int senf::ConnectedCommunicationPolicy::do_accept(FileHandle const & handle, struct sockaddr * addr, unsigned len) { diff --git a/senf/Socket/CommunicationPolicy.cci b/senf/Socket/CommunicationPolicy.cci index ca9ddd6..6330e72 100644 --- a/senf/Socket/CommunicationPolicy.cci +++ b/senf/Socket/CommunicationPolicy.cci @@ -28,7 +28,7 @@ #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ int senf::ConnectedCommunicationPolicy::accept(FileHandle handle) +prefix_ int senf::ConnectedCommunicationPolicy::accept(FileHandle const & handle) { return do_accept(handle, 0, 0); } diff --git a/senf/Socket/CommunicationPolicy.cti b/senf/Socket/CommunicationPolicy.cti index 6675ed4..f1c857a 100644 --- a/senf/Socket/CommunicationPolicy.cti +++ b/senf/Socket/CommunicationPolicy.cti @@ -34,7 +34,7 @@ #ifndef DOXYGEN template prefix_ void senf::ConnectedCommunicationPolicy:: -listen(ServerSocketHandle handle, unsigned backlog, +listen(ServerSocketHandle const & handle, unsigned backlog, typename IfAddressingPolicyIsNot::type *) { do_listen(handle, backlog); @@ -42,14 +42,14 @@ listen(ServerSocketHandle handle, unsigned backlog, #else template prefix_ void senf::ConnectedCommunicationPolicy:: -listen(ServerSocketHandle handle, unsigned backlog) +listen(ServerSocketHandle const & handle, unsigned backlog) {} #endif #ifndef DOXYGEN template prefix_ int senf::ConnectedCommunicationPolicy:: -accept(ServerSocketHandle handle, +accept(ServerSocketHandle const & handle, typename ServerSocketHandle::Address & address, typename IfAddressingPolicyIsNot::type *) { @@ -58,7 +58,7 @@ accept(ServerSocketHandle handle, #else template prefix_ int senf::ConnectedCommunicationPolicy:: -accept(ServerSocketHandle handle, +accept(ServerSocketHandle const & handle, typename ServerSocketHandle::Address & address) {} #endif diff --git a/senf/Socket/CommunicationPolicy.hh b/senf/Socket/CommunicationPolicy.hh index 47dc01f..c007d73 100644 --- a/senf/Socket/CommunicationPolicy.hh +++ b/senf/Socket/CommunicationPolicy.hh @@ -53,11 +53,11 @@ namespace senf { { # ifndef DOXYGEN template - static void listen(ServerSocketHandle handle, unsigned backlog, + static void listen(ServerSocketHandle const & handle, unsigned backlog, typename IfAddressingPolicyIsNot::type * = 0); # else template - static void listen(ServerSocketHandle handle, unsigned backlog); + static void listen(ServerSocketHandle const & handle, unsigned backlog); ///< Enable establishing new connections on the socket /**< \param[in] handle socket handle to enable reception on \param[in] backlog size of backlog queue */ @@ -65,12 +65,12 @@ namespace senf { # ifndef DOXYGEN template - static int accept(ServerSocketHandle handle, + static int accept(ServerSocketHandle const & handle, typename ServerSocketHandle::Address & address, typename IfAddressingPolicyIsNot::type * = 0); # else template - static int accept(ServerSocketHandle handle, + static int accept(ServerSocketHandle const & handle, typename ServerSocketHandle::Address & address); ///< accept a new connection on the socket. /**< The accept() member will return a new client file @@ -84,7 +84,7 @@ namespace senf { \returns file descriptor of new client socket */ # endif - static int accept(FileHandle handle); + static int accept(FileHandle const & handle); ///< accept a new connection on the socket. /**< The accept() member will return a new client file descriptor. This file descriptor will be used by the @@ -95,8 +95,8 @@ namespace senf { \returns file descriptor of new client socket */ private: - static void do_listen(FileHandle handle, unsigned backlog); - static int do_accept(FileHandle handle, struct sockaddr * addr, unsigned len); + static void do_listen(FileHandle const & handle, unsigned backlog); + static int do_accept(FileHandle const & handle, struct sockaddr * addr, unsigned len); }; /** \brief CommunicationPolicy for unconnected sockets diff --git a/senf/Socket/Protocols/BSDAddressingPolicy.cc b/senf/Socket/Protocols/BSDAddressingPolicy.cc index c8b9c12..06e263b 100644 --- a/senf/Socket/Protocols/BSDAddressingPolicy.cc +++ b/senf/Socket/Protocols/BSDAddressingPolicy.cc @@ -36,7 +36,7 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ void senf::BSDAddressingPolicyMixinBase::do_local(FileHandle handle, +prefix_ void senf::BSDAddressingPolicyMixinBase::do_local(FileHandle const & handle, struct sockaddr * addr, socklen_t * len) { @@ -44,7 +44,7 @@ prefix_ void senf::BSDAddressingPolicyMixinBase::do_local(FileHandle handle, SENF_THROW_SYSTEM_EXCEPTION(""); } -prefix_ void senf::BSDAddressingPolicyMixinBase::do_peer(FileHandle handle, +prefix_ void senf::BSDAddressingPolicyMixinBase::do_peer(FileHandle const & handle, struct sockaddr * addr, socklen_t * len) { @@ -52,7 +52,7 @@ prefix_ void senf::BSDAddressingPolicyMixinBase::do_peer(FileHandle handle, SENF_THROW_SYSTEM_EXCEPTION(""); } -prefix_ void senf::BSDAddressingPolicyMixinBase::do_bind(FileHandle handle, +prefix_ void senf::BSDAddressingPolicyMixinBase::do_bind(FileHandle const & handle, struct sockaddr const * addr, socklen_t len) { @@ -60,7 +60,7 @@ prefix_ void senf::BSDAddressingPolicyMixinBase::do_bind(FileHandle handle, SENF_THROW_SYSTEM_EXCEPTION(""); } -prefix_ void senf::BSDAddressingPolicyMixinBase::do_connect(FileHandle handle, +prefix_ void senf::BSDAddressingPolicyMixinBase::do_connect(FileHandle const & handle, struct sockaddr const * addr, socklen_t len) { diff --git a/senf/Socket/Protocols/BSDAddressingPolicy.cti b/senf/Socket/Protocols/BSDAddressingPolicy.cti index abac866..75bc460 100644 --- a/senf/Socket/Protocols/BSDAddressingPolicy.cti +++ b/senf/Socket/Protocols/BSDAddressingPolicy.cti @@ -38,7 +38,7 @@ template template prefix_ void senf::BSDAddressingPolicyMixin
:: -peer(SocketHandle handle, Address & addr, +peer(SocketHandle const & handle, Address & addr, typename IfCommunicationPolicyIs::type *) { try { @@ -52,7 +52,7 @@ peer(SocketHandle handle, Address & addr, template template prefix_ void senf::BSDAddressingPolicyMixin
:: -peer(SocketHandle handle, Address & addr) +peer(SocketHandle const & handle, Address & addr) {} #endif @@ -60,7 +60,7 @@ peer(SocketHandle handle, Address & addr) template template prefix_ void senf::BSDAddressingPolicyMixin
:: -connect(SocketHandle handle, Address const & addr, +connect(SocketHandle const & handle, Address const & addr, typename IfCommunicationPolicyIs::type *) { try { @@ -74,12 +74,12 @@ connect(SocketHandle handle, Address const & addr, template template prefix_ void senf::BSDAddressingPolicyMixin
:: -connect(SocketHandle handle, Address const & addr) +connect(SocketHandle const & handle, Address const & addr) {} #endif template -prefix_ void senf::BSDAddressingPolicyMixin
::local(FileHandle handle, +prefix_ void senf::BSDAddressingPolicyMixin
::local(FileHandle const & handle, Address & addr) { try { @@ -92,7 +92,7 @@ prefix_ void senf::BSDAddressingPolicyMixin
::local(FileHandle handle, } template -prefix_ void senf::BSDAddressingPolicyMixin
::bind(FileHandle handle, +prefix_ void senf::BSDAddressingPolicyMixin
::bind(FileHandle const & handle, Address const & addr) { try { diff --git a/senf/Socket/Protocols/BSDAddressingPolicy.hh b/senf/Socket/Protocols/BSDAddressingPolicy.hh index 36b970d..a4b17ac 100644 --- a/senf/Socket/Protocols/BSDAddressingPolicy.hh +++ b/senf/Socket/Protocols/BSDAddressingPolicy.hh @@ -50,10 +50,10 @@ namespace senf { */ struct BSDAddressingPolicyMixinBase { - static void do_local(FileHandle handle, struct sockaddr * addr, socklen_t * len); - static void do_peer(FileHandle handle, struct sockaddr * addr, socklen_t * len); - static void do_bind(FileHandle handle, struct sockaddr const * addr, socklen_t len); - static void do_connect(FileHandle handle, struct sockaddr const * addr, socklen_t len); + static void do_local(FileHandle const & handle, struct sockaddr * addr, socklen_t * len); + static void do_peer(FileHandle const & handle, struct sockaddr * addr, socklen_t * len); + static void do_bind(FileHandle const & handle, struct sockaddr const * addr, socklen_t len); + static void do_connect(FileHandle const & handle, struct sockaddr const * addr, socklen_t len); }; /** \brief Template for generic AddressingPolicy implementation based on the BSD socket API @@ -86,11 +86,11 @@ namespace senf { { # ifndef DOXYGEN template - static void peer(SocketHandle handle, Address & addr, + static void peer(SocketHandle const & handle, Address & addr, typename IfCommunicationPolicyIs::type * = 0); # else template - static void peer(SocketHandle handle, Address & addr); + static void peer(SocketHandle const & handle, Address & addr); ///< Return address of remote peer on connected sockets /**< This member is only available if the socket handles communication policy is ConnectedCommunicationPolicy. @@ -98,18 +98,18 @@ namespace senf { \param[in] handle socket handle to get peer address of \param[out] addr address of remote peer */ # endif - static void local(FileHandle handle, Address & addr); + static void local(FileHandle const & handle, Address & addr); ///< Return local of socket /**< \param[in] handle socket handle to check \param[out] addr local socket address */ # ifndef DOXYGEN template - static void connect(SocketHandle handle, Address const & addr, + static void connect(SocketHandle const & handle, Address const & addr, typename IfCommunicationPolicyIs::type * = 0); # else template - static void connect(SocketHandle handle, Address const & addr); + static void connect(SocketHandle const & handle, Address const & addr); ///< Connect to remote host /**< This member is only available if the socket handles communication policy is ConnectedCommunicationPolicy. @@ -118,7 +118,7 @@ namespace senf { \param[in] addr address of remote peer to connect to */ # endif - static void bind(FileHandle handle, Address const & addr); + static void bind(FileHandle const & handle, Address const & addr); ///< Set local socket address /**< \param[in] handle socket handle \param[in] addr local socket address */ diff --git a/senf/Socket/ReadWritePolicy.cc b/senf/Socket/ReadWritePolicy.cc index 3c3138a..64dd850 100644 --- a/senf/Socket/ReadWritePolicy.cc +++ b/senf/Socket/ReadWritePolicy.cc @@ -38,7 +38,7 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ unsigned senf::ReadablePolicy::read(FileHandle handle, char * buffer, +prefix_ unsigned senf::ReadablePolicy::read(FileHandle & handle, char * buffer, unsigned size) { int rv = -1; @@ -59,7 +59,7 @@ prefix_ unsigned senf::ReadablePolicy::read(FileHandle handle, char * buffer, return rv; } -prefix_ unsigned senf::ReadablePolicy::do_readfrom(FileHandle handle, char * buffer, +prefix_ unsigned senf::ReadablePolicy::do_readfrom(FileHandle & handle, char * buffer, unsigned size, struct ::sockaddr * addr, socklen_t * len) { @@ -80,7 +80,7 @@ prefix_ unsigned senf::ReadablePolicy::do_readfrom(FileHandle handle, char * buf return rv; } -prefix_ unsigned senf::WriteablePolicy::do_write(FileHandle handle, char const * buffer, +prefix_ unsigned senf::WriteablePolicy::do_write(FileHandle & handle, char const * buffer, unsigned size) { int rv = -1; @@ -109,7 +109,7 @@ prefix_ unsigned senf::WriteablePolicy::do_write(FileHandle handle, char const * return rv; } -prefix_ unsigned senf::WriteablePolicy::do_writeto(FileHandle handle, +prefix_ unsigned senf::WriteablePolicy::do_writeto(FileHandle & handle, char const * buffer, unsigned size, struct sockaddr const * addr, socklen_t len) { diff --git a/senf/Socket/ReadWritePolicy.cti b/senf/Socket/ReadWritePolicy.cti index edb7915..0227184 100644 --- a/senf/Socket/ReadWritePolicy.cti +++ b/senf/Socket/ReadWritePolicy.cti @@ -34,7 +34,7 @@ #ifndef DOXYGEN template prefix_ unsigned senf::ReadablePolicy:: -readfrom(ClientSocketHandle handle, char * buffer, unsigned size, +readfrom(ClientSocketHandle & handle, char * buffer, unsigned size, typename SPolicy::AddressingPolicy::Address & address, typename IfCommunicationPolicyIs::type *) { @@ -43,7 +43,7 @@ readfrom(ClientSocketHandle handle, char * buffer, unsigned size, #else template prefix_ unsigned senf::ReadablePolicy:: -readfrom(ClientSocketHandle handle, char * buffer, unsigned size, +readfrom(ClientSocketHandle & handle, char * buffer, unsigned size, typename Policy::AddressingPolicy::Address & address) {} #endif @@ -51,7 +51,7 @@ readfrom(ClientSocketHandle handle, char * buffer, unsigned size, #ifndef DOXYGEN template prefix_ unsigned senf::WriteablePolicy:: -write(ClientSocketHandle handle, char const * buffer, unsigned size, +write(ClientSocketHandle & handle, char const * buffer, unsigned size, typename IfCommunicationPolicyIs::type *) { return do_write(handle,buffer,size); @@ -59,14 +59,14 @@ write(ClientSocketHandle handle, char const * buffer, unsigned size, #else template prefix_ unsigned senf::WriteablePolicy:: -write(ClientSocketHandle handle, char const * buffer, unsigned size) +write(ClientSocketHandle & handle, char const * buffer, unsigned size) {} #endif #ifndef DOXYGEN template prefix_ unsigned senf::WriteablePolicy:: -writeto(ClientSocketHandle handle, +writeto(ClientSocketHandle & handle, typename boost::call_traits::param_type addr, char const * buffer, unsigned size, typename IfCommunicationPolicyIs::type *) @@ -76,7 +76,7 @@ writeto(ClientSocketHandle handle, #else template prefix_ unsigned senf::WriteablePolicy:: -writeto(ClientSocketHandle handle, +writeto(ClientSocketHandle & handle, typename Policy::AddressingPolicy::Address const & addr, char const * buffer, unsigned size) {} diff --git a/senf/Socket/ReadWritePolicy.hh b/senf/Socket/ReadWritePolicy.hh index 98ec97e..f3faf27 100644 --- a/senf/Socket/ReadWritePolicy.hh +++ b/senf/Socket/ReadWritePolicy.hh @@ -52,7 +52,7 @@ namespace senf { */ struct ReadablePolicy : public ReadPolicyBase { - static unsigned read(FileHandle handle, char * buffer, unsigned size); + static unsigned read(FileHandle & handle, char * buffer, unsigned size); ///< read data from socket /**< \param[in] handle socket handle to read from \param[in] buffer address of buffer to write data to @@ -60,13 +60,13 @@ namespace senf { \returns number of bytes read */ # ifndef DOXYGEN template - static unsigned readfrom(ClientSocketHandle handle, char * buffer, unsigned size, + static unsigned readfrom(ClientSocketHandle & handle, char * buffer, unsigned size, typename SPolicy::AddressingPolicy::Address & address, typename IfCommunicationPolicyIs< SPolicy,UnconnectedCommunicationPolicy>::type * = 0); # else template - static unsigned readfrom(ClientSocketHandle handle, char * buffer, unsigned size, + static unsigned readfrom(ClientSocketHandle & handle, char * buffer, unsigned size, typename Policy::AddressingPolicy::Address & address); ///< read data from socket returning peer address /**< \param[in] handle socket handle to read from @@ -77,7 +77,7 @@ namespace senf { # endif private: - static unsigned do_readfrom(FileHandle handle, char * buffer, unsigned size, + static unsigned do_readfrom(FileHandle & handle, char * buffer, unsigned size, struct ::sockaddr * addr, socklen_t * len); }; @@ -99,12 +99,12 @@ namespace senf { { # ifndef DOXYGEN template - static unsigned write(ClientSocketHandle handle, char const * buffer, unsigned size, + static unsigned write(ClientSocketHandle & handle, char const * buffer, unsigned size, typename IfCommunicationPolicyIs< SPolicy,ConnectedCommunicationPolicy>::type * = 0); # else template - static unsigned write(ClientSocketHandle handle, char const * buffer, + static unsigned write(ClientSocketHandle & handle, char const * buffer, unsigned size); ///< write data to socket /**< This member is only enabled if the socket uses @@ -119,7 +119,7 @@ namespace senf { # endif # ifndef DOXYGEN template - static unsigned writeto(ClientSocketHandle handle, + static unsigned writeto(ClientSocketHandle & handle, typename boost::call_traits< typename SPolicy::AddressingPolicy::Address>::param_type addr, char const * buffer, unsigned size, @@ -127,7 +127,7 @@ namespace senf { SPolicy,UnconnectedCommunicationPolicy>::type * = 0); # else template - static unsigned writeto(ClientSocketHandle handle, + static unsigned writeto(ClientSocketHandle & handle, typename Policy::AddressingPolicy::Address const & addr, char const * buffer, unsigned size); ///< write data to socket sending to given peer @@ -144,8 +144,8 @@ namespace senf { # endif private: - static unsigned do_write(FileHandle handle, char const * buffer, unsigned size); - static unsigned do_writeto(FileHandle handle, char const * buffer, unsigned size, + static unsigned do_write(FileHandle & handle, char const * buffer, unsigned size); + static unsigned do_writeto(FileHandle & handle, char const * buffer, unsigned size, struct sockaddr const * addr, socklen_t len); };