void ULEdec::handleEvent(senf::Scheduler::EventId event)
{
senf::TransportPacket ts_packet (
- senf::TransportPacket::create(188, senf::TransportPacket::noinit));
+ senf::TransportPacket::create(188, senf::noinit));
dvrHandle.read( ts_packet.data() );
// Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control.
while (true) { // forever
senf::EthernetPacket packet (senf::EthernetPacket::create(
- senf::EthernetPacket::noinit));
+ senf::noinit));
sock.read(packet.data(),0);
packet.dump(std::cout);
senf::hexdump(
void dumpPacket(senf::Scheduler::EventId event)
{
senf::EthernetPacket packet (
- senf::EthernetPacket::create(senf::EthernetPacket::noinit));
+ senf::EthernetPacket::create(senf::noinit));
sock.read(packet.data(),0);
packet.dump(std::cout);
senf::hexdump(
template <class Packet>
prefix_ Packet senf::ppi::DgramReader<Packet>::operator()(Handle handle)
{
- Packet packet (Packet::create(Packet::noinit));
+ Packet packet (Packet::create(senf::noinit));
handle.read(packet.data(),0u);
return packet;
}
\code
senf::PacketSocketHandle sock ("eth0");
- senf::EthernetPacket packet (senf::EthernetPacket::create(senf::Packet::noinit));
+ senf::EthernetPacket packet (senf::EthernetPacket::create(senf::noinit));
sock.read(packet.data(),0u);
\endcode
template <class PacketType>
prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::create(NoInit_t)
+senf::ConcretePacket<PacketType>::create(senf::NoInit_t)
{
- return ConcretePacket(interpreter::create(interpreter::noinit));
+ return ConcretePacket(interpreter::create(senf::noinit));
}
template <class PacketType>
template <class PacketType>
prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::create(size_type size, NoInit_t)
+senf::ConcretePacket<PacketType>::create(size_type size, senf::NoInit_t)
{
- return ConcretePacket(interpreter::create(size,interpreter::noinit));
+ return ConcretePacket(interpreter::create(size,senf::noinit));
}
template <class PacketType>
template <class PacketType>
prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createAfter(Packet packet, NoInit_t)
+senf::ConcretePacket<PacketType>::createAfter(Packet packet, senf::NoInit_t)
{
- return ConcretePacket(interpreter::createAfter(packet.ptr(),interpreter::noinit));
+ return ConcretePacket(interpreter::createAfter(packet.ptr(),senf::noinit));
}
template <class PacketType>
template <class PacketType>
prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createAfter(Packet packet, size_type size, NoInit_t)
+senf::ConcretePacket<PacketType>::createAfter(Packet packet, size_type size, senf::NoInit_t)
{
- return ConcretePacket(interpreter::createAfter(packet.ptr(), size, interpreter::noinit));
+ return ConcretePacket(interpreter::createAfter(packet.ptr(), size, senf::noinit));
}
template <class PacketType>
template <class PacketType>
prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createBefore(Packet packet, NoInit_t)
+senf::ConcretePacket<PacketType>::createBefore(Packet packet, senf::NoInit_t)
{
- return ConcretePacket(interpreter::createBefore(packet.ptr(), interpreter::noinit));
+ return ConcretePacket(interpreter::createBefore(packet.ptr(), senf::noinit));
}
// Create a clone of the current packet
#include <boost/operators.hpp>
#include "../Utils/Exception.hh"
+#include "../Utils/Tags.hh"
#include "../Utils/safe_bool.hh"
#include "PacketInterpreter.hh"
///< Unsigned type to represent packet size
typedef PacketInterpreterBase::factory_t factory_t; ///< Packet factory type (see below)
- enum NoInit_t { noinit }; ///< Special argument flag
- /**< Used in some ConcretePacket constructors */
-
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
///@{
static ConcretePacket create(); ///< Create default initialized packet
/**< The packet will be initialized to it's default empty
state. */
- static ConcretePacket create(NoInit_t); ///< Create uninitialized empty packet
+ static ConcretePacket create(senf::NoInit_t); ///< Create uninitialized empty packet
/**< This will create a completely empty and uninitialized
packet with <tt>size() == 0</tt>.
- \param[in] noinit This parameter must always have the
+ \param[in] senf::noinit This parameter must always have the
value \c senf::noinit. */
static ConcretePacket create(size_type size); ///< Create default initialized packet
/**< This member will create a default initialized packet
\throws TruncatedPacketException if \a size is smaller
than the smallest permissible size for this type of
packet. */
- static ConcretePacket create(size_type size, NoInit_t); ///< Create uninitialized packet
+ static ConcretePacket create(size_type size, senf::NoInit_t);
+ ///< Create uninitialized packet
/**< Creates an uninitialized (all-zero) packet of the exact
given size.
\param[in] size Size of the packet to create in bytes
- \param[in] noinit This parameter must always have the
+ \param[in] senf::noinit This parameter must always have the
value \c senf::noinit. */
template <class ForwardReadableRange>
static ConcretePacket create(ForwardReadableRange const & range);
state. It will be appended as next header/interpreter
after \a packet in that packets interpreter chain.
\param[in] packet Packet to append new packet to. */
- static ConcretePacket createAfter(Packet packet, NoInit_t);
+ static ConcretePacket createAfter(Packet packet, senf::NoInit_t);
///< Create uninitialized empty packet after\a packet
/**< This will create a completely empty and uninitialized
packet with <tt>size() == 0</tt>. It will be appended
as next header/interpreter after \a packet in that
packets interpreter chain.
\param[in] packet Packet to append new packet to.
- \param[in] noinit This parameter must always have the
+ \param[in] senf::noinit This parameter must always have the
value \c senf::noinit. */
static ConcretePacket createAfter(Packet packet, size_type size);
///< Create default initialized packet after \a packet
\throws TruncatedPacketException if \a size is smaller
than the smallest permissible size for this type of
packet. */
- static ConcretePacket createAfter(Packet packet, size_type size, NoInit_t);
+ static ConcretePacket createAfter(Packet packet, size_type size, senf::NoInit_t);
///< Create uninitialized packet after \a packet
/**< Creates an uninitialized (all-zero) packet of the exact
given size. It will be appended as next
interpreter chain.
\param[in] packet Packet to append new packet to.
\param[in] size Size of the packet to create in bytes
- \param[in] noinit This parameter must always have the
+ \param[in] senf::noinit This parameter must always have the
value \c senf::noinit. */
template <class ForwardReadableRange>
static ConcretePacket createAfter(Packet packet,
header/interpreter before \a packet in that packets
interpreter chain.
\param[in] packet Packet to prepend new packet to. */
- static ConcretePacket createBefore(Packet packet, NoInit_t);
+ static ConcretePacket createBefore(Packet packet, senf::NoInit_t);
///< Create uninitialized empty packet before \a packet
/**< Creates a completely empty and uninitialized packet. It
will be prepended as previous header/interpreter before
senf::PacketData::byte data[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
BOOST_CHECK_EQUAL( FooPacket::create().size(), 4u );
- BOOST_CHECK_EQUAL( FooPacket::create(FooPacket::noinit).size(), 0u );
+ BOOST_CHECK_EQUAL( FooPacket::create(senf::noinit).size(), 0u );
BOOST_CHECK_THROW( FooPacket::create(2u), senf::TruncatedPacketException );
BOOST_CHECK_EQUAL( FooPacket::create(10u).size(), 10u );
- BOOST_CHECK_EQUAL( FooPacket::create(2u,FooPacket::noinit).size(), 2u );
+ BOOST_CHECK_EQUAL( FooPacket::create(2u,senf::noinit).size(), 2u );
BOOST_CHECK_EQUAL( FooPacket::create(data).size(), 6u );
senf::Packet packet (FooPacket::create());
BOOST_CHECK_EQUAL( FooPacket::createAfter(packet).size(), 4u );
BOOST_CHECK_EQUAL( packet.size(), 8u );
- BOOST_CHECK_EQUAL( FooPacket::createAfter(packet,FooPacket::noinit).size(), 0u );
+ BOOST_CHECK_EQUAL( FooPacket::createAfter(packet,senf::noinit).size(), 0u );
BOOST_CHECK_EQUAL( packet.size(), 4u );
BOOST_CHECK_THROW( FooPacket::createAfter(packet,2u), senf::TruncatedPacketException );
BOOST_CHECK_EQUAL( FooPacket::createAfter(packet,10u).size(), 10u );
BOOST_CHECK_EQUAL( packet.size(), 14u );
- BOOST_CHECK_EQUAL( FooPacket::createAfter(packet,2u,FooPacket::noinit).size(), 2u );
+ BOOST_CHECK_EQUAL( FooPacket::createAfter(packet,2u,senf::noinit).size(), 2u );
BOOST_CHECK_EQUAL( packet.size(), 6u );
BOOST_CHECK_EQUAL( FooPacket::createAfter(packet,data).size(), 6u );
BOOST_CHECK_EQUAL( FooPacket::createBefore(packet).size(), 14u );
BOOST_CHECK_EQUAL( packet.size(), 10u );
- BOOST_CHECK_EQUAL( FooPacket::createBefore(packet,FooPacket::noinit).size(), 10u );
+ BOOST_CHECK_EQUAL( FooPacket::createBefore(packet,senf::noinit).size(), 10u );
BOOST_CHECK_EQUAL( packet.size(), 10u );
BOOST_CHECK( packet.clone() != packet );
{
if (size < initSize())
throw TruncatedPacketException();
- ptr pi (create(size,noinit));
+ ptr pi (create(size,senf::noinit));
pi->init();
return pi;
}
template <class PacketType>
prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::create(size_type size, NoInit_t)
+senf::PacketInterpreter<PacketType>::create(size_type size, senf::NoInit_t)
{
detail::PacketImpl::Guard p (new detail::PacketImpl(size,0));
ptr pi (create(p.p,p.p->begin(),p.p->end(),Append));
{
if (size < initSize())
throw TruncatedPacketException();
- ptr pi (createAfter(packet,size,noinit));
+ ptr pi (createAfter(packet,size,senf::noinit));
std::fill(pi->data().begin(), pi->data().end(),0);
pi->init();
return pi;
template <class PacketType>
prefix_ typename senf::PacketInterpreter<PacketType>::ptr
senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr packet,
- size_type size, NoInit_t)
+ size_type size, senf::NoInit_t)
{
optional_range r (packet->nextPacketRange());
if (!r)
prefix_ typename senf::PacketInterpreter<PacketType>::ptr
senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr packet)
{
- ptr pi (createBefore(packet, noinit));
+ ptr pi (createBefore(packet, senf::noinit));
pi->data().insert(pi->data().begin(),initHeadSize(),byte(0x00u));
pi->data().insert(pi->data().end(),initSize()-initHeadSize(),byte(0x00u));
pi->init();
template <class PacketType>
prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr packet, NoInit_t)
+senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t)
{
if (packet->prev())
packet->impl().truncateInterpretersBackwards(packet->prev().get());
senf::PacketInterpreterBase::Factory::create(ForwardReadableRange const & range)
const
{
- ptr pi (create(boost::size(range),noinit));
+ ptr pi (create(boost::size(range),senf::noinit));
std::copy(boost::begin(range), boost::end(range), pi->data().begin());
return pi;
}
ForwardReadableRange const & range)
const
{
- ptr pi (createAfter(packet,boost::size(range),noinit));
+ ptr pi (createAfter(packet,boost::size(range),senf::noinit));
std::copy(boost::begin(range), boost::end(range), pi->data().begin());
return pi;
}
template <class PacketType>
prefix_ typename senf::PacketInterpreterBase::ptr
-senf::PacketInterpreter<PacketType>::FactoryImpl::create(NoInit_t)
+senf::PacketInterpreter<PacketType>::FactoryImpl::create(senf::NoInit_t)
const
{
- return senf::PacketInterpreter<PacketType>::create(noinit);
+ return senf::PacketInterpreter<PacketType>::create(senf::noinit);
}
template <class PacketType>
template <class PacketType>
prefix_ typename senf::PacketInterpreterBase::ptr
-senf::PacketInterpreter<PacketType>::FactoryImpl::create(size_type size, NoInit_t)
+senf::PacketInterpreter<PacketType>::FactoryImpl::create(size_type size, senf::NoInit_t)
const
{
- return senf::PacketInterpreter<PacketType>::create(size, noinit);
+ return senf::PacketInterpreter<PacketType>::create(size, senf::noinit);
}
// Create packet as new packet after a given packet
template <class PacketType>
prefix_ typename senf::PacketInterpreterBase::ptr
senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet,
- NoInit_t)
+ senf::NoInit_t)
const
{
- return senf::PacketInterpreter<PacketType>::createAfter(packet,noinit);
+ return senf::PacketInterpreter<PacketType>::createAfter(packet,senf::noinit);
}
template <class PacketType>
template <class PacketType>
prefix_ typename senf::PacketInterpreterBase::ptr
senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet,
- size_type size, NoInit_t)
+ size_type size, senf::NoInit_t)
const
{
- return senf::PacketInterpreter<PacketType>::createAfter(packet,size,noinit);
+ return senf::PacketInterpreter<PacketType>::createAfter(packet,size,senf::noinit);
}
// Create packet as new packet (header) before a given packet
template <class PacketType>
prefix_ senf::PacketInterpreterBase::ptr
senf::PacketInterpreter<PacketType>::FactoryImpl::
-createBefore(PacketInterpreterBase::ptr packet, NoInit_t)
+createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t)
const
{
- return senf::PacketInterpreter<PacketType>::createBefore(packet,noinit);
+ return senf::PacketInterpreter<PacketType>::createBefore(packet,senf::noinit);
}
// Parse next packet in chain
template <class PacketType>
prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::create(NoInit_t)
+senf::PacketInterpreter<PacketType>::create(senf::NoInit_t)
{
- return create(0,noinit);
+ return create(0,senf::noinit);
}
template <class PacketType>
template <class PacketType>
prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr packet, NoInit_t)
+senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr packet, senf::NoInit_t)
{
- return createAfter(packet, 0, noinit);
+ return createAfter(packet, 0, senf::noinit);
}
// Create clone of current packet
#include <boost/type_traits/alignment_of.hpp>
#include "../Utils/intrusive_refcount.hh"
#include "../Utils/pool_alloc_mixin.hh"
+#include "../Utils/Tags.hh"
#include "PacketData.hh"
#include "../Utils/TypeIdValue.hh"
enum Append_t { Append };
enum Prepend_t { Prepend };
- enum NoInit_t { noinit };
/** \brief Internal: Abstract packet factory
// Create completely new packet
virtual ptr create() const = 0;
- virtual ptr create(NoInit_t) const = 0;
+ virtual ptr create(senf::NoInit_t) const = 0;
virtual ptr create(size_type size) const = 0;
- virtual ptr create(size_type size, NoInit_t) const = 0;
+ virtual ptr create(size_type size, senf::NoInit_t) const = 0;
template <class ForwardReadableRange>
ptr create(ForwardReadableRange const & range) const;
// Create packet as new packet after a given packet
virtual ptr createAfter(PacketInterpreterBase::ptr packet) const = 0;
- virtual ptr createAfter(PacketInterpreterBase::ptr packet, NoInit_t) const = 0;
+ virtual ptr createAfter(PacketInterpreterBase::ptr packet, senf::NoInit_t) const = 0;
virtual ptr createAfter(PacketInterpreterBase::ptr packet, size_type size) const = 0;
virtual ptr createAfter(PacketInterpreterBase::ptr packet, size_type size,
- NoInit_t) const = 0;
+ senf::NoInit_t) const = 0;
template <class ForwardReadableRange>
ptr createAfter(PacketInterpreterBase::ptr packet,
ForwardReadableRange const & range) const;
// Create packet as new packet (header) const before a given packet
virtual ptr createBefore(PacketInterpreterBase::ptr packet) const = 0;
- virtual ptr createBefore(PacketInterpreterBase::ptr packet, NoInit_t) const = 0;
+ virtual ptr createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t) const = 0;
// Parse next packet in chain
// Create completely new packet
static ptr create();
- static ptr create(NoInit_t);
+ static ptr create(senf::NoInit_t);
static ptr create(size_type size);
- static ptr create(size_type size, NoInit_t);
+ static ptr create(size_type size, senf::NoInit_t);
template <class ForwardReadableRange>
static ptr create(ForwardReadableRange const & range);
// Create packet as new packet after a given packet
static ptr createAfter(PacketInterpreterBase::ptr packet);
- static ptr createAfter(PacketInterpreterBase::ptr packet, NoInit_t);
+ static ptr createAfter(PacketInterpreterBase::ptr packet, senf::NoInit_t);
static ptr createAfter(PacketInterpreterBase::ptr packet, size_type size);
- static ptr createAfter(PacketInterpreterBase::ptr packet, size_type size, NoInit_t);
+ static ptr createAfter(PacketInterpreterBase::ptr packet, size_type size, senf::NoInit_t);
template <class ForwardReadableRange>
static ptr createAfter(PacketInterpreterBase::ptr packet,
ForwardReadableRange const & range);
// Create packet as new packet (header) before a given packet
static ptr createBefore(PacketInterpreterBase::ptr packet);
- static ptr createBefore(PacketInterpreterBase::ptr packet, NoInit_t);
+ static ptr createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t);
// Create a clone of the current packet
// Create completely new packet
virtual PacketInterpreterBase::ptr create() const;
- virtual PacketInterpreterBase::ptr create(NoInit_t) const;
+ virtual PacketInterpreterBase::ptr create(senf::NoInit_t) const;
virtual PacketInterpreterBase::ptr create(size_type size) const;
- virtual PacketInterpreterBase::ptr create(size_type size,NoInit_t) const;
+ virtual PacketInterpreterBase::ptr create(size_type size,senf::NoInit_t) const;
// Create packet as new packet after a given packet
virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr packet)
const;
virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr packet,
- NoInit_t) const;
+ senf::NoInit_t) const;
virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr packet,
size_type size) const;
virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr packet,
- size_type size, NoInit_t) const;
+ size_type size, senf::NoInit_t) const;
// Create packet as new packet (header) before a given packet
virtual PacketInterpreterBase::ptr createBefore(PacketInterpreterBase::ptr packet)
const;
virtual PacketInterpreterBase::ptr createBefore(PacketInterpreterBase::ptr packet,
- NoInit_t)
+ senf::NoInit_t)
const;
// Parse next packet in chain
{
BOOST_CHECK_NO_THROW(
- senf::PacketInterpreter<OtherPacket>::create(4u,senf::PacketInterpreterBase::noinit));
+ senf::PacketInterpreter<OtherPacket>::create(4u,senf::noinit));
senf::PacketInterpreter<OtherPacket>::ptr p
- (senf::PacketInterpreter<OtherPacket>::create(senf::PacketInterpreterBase::noinit));
+ (senf::PacketInterpreter<OtherPacket>::create(senf::noinit));
BOOST_CHECK_EQUAL( p->data().size(), 0u );
}
(senf::PacketInterpreter<OtherPacket>::create(12u));
senf::PacketInterpreter<OtherPacket>::ptr p2
(senf::PacketInterpreter<OtherPacket>::createAfter(
- p,senf::PacketInterpreterBase::noinit));
+ p,senf::noinit));
BOOST_CHECK_EQUAL( p2->data().size(), 0u );
BOOST_CHECK_EQUAL( p->data().size(), 8u );
}
BOOST_CHECK_THROW( senf::PacketInterpreter<OtherPacket>::createAfter(p,4u),
senf::TruncatedPacketException );
BOOST_CHECK_NO_THROW( senf::PacketInterpreter<OtherPacket>::createAfter(
- p,4u,senf::PacketInterpreterBase::noinit) );
+ p,4u,senf::noinit) );
}
{
senf::PacketInterpreter<OtherPacket>::ptr p3
(senf::PacketInterpreter<OtherPacket>::createBefore(
- p,senf::PacketInterpreterBase::noinit));
+ p,senf::noinit));
BOOST_CHECK_EQUAL( p3->data().size(), 10u );
}
BOOST_CHECK( factory->create()->is<OtherPacket>() );
BOOST_CHECK_EQUAL( factory->create()->data().size(), 8u );
- BOOST_CHECK_EQUAL( factory->create(senf::PacketInterpreterBase::noinit)->data().size(), 0u );
+ BOOST_CHECK_EQUAL( factory->create(senf::noinit)->data().size(), 0u );
BOOST_CHECK_EQUAL( factory->create(12u)->data().size(), 12u );
BOOST_CHECK_EQUAL(
- factory->create(4u, senf::PacketInterpreterBase::noinit)->data().size(), 4u );
+ factory->create(4u, senf::noinit)->data().size(), 4u );
BOOST_CHECK_EQUAL( factory->create(data)->data().size(), 6u );
{
BOOST_CHECK( ! p->next()->next() );
BOOST_CHECK_EQUAL(
- factory->createAfter(p, senf::PacketInterpreterBase::noinit)->data().size(), 0u );
+ factory->createAfter(p, senf::noinit)->data().size(), 0u );
BOOST_CHECK_EQUAL( p->data().size(), 0u );
BOOST_CHECK( ! p->next()->next() );
BOOST_CHECK( ! p->next()->next() );
BOOST_CHECK_EQUAL(
- factory->createAfter(p,4u, senf::PacketInterpreterBase::noinit)->data().size(), 4u );
+ factory->createAfter(p,4u, senf::noinit)->data().size(), 4u );
BOOST_CHECK_EQUAL( p->data().size(), 4u );
BOOST_CHECK( ! p->next()->next() );
BOOST_CHECK_EQUAL( p->prev()->data().size(), 12u );
BOOST_CHECK_EQUAL(
- factory->createBefore(p,senf::PacketInterpreterBase::noinit)->data().size(), 4u );
+ factory->createBefore(p,senf::noinit)->data().size(), 4u );
BOOST_REQUIRE( p->prev() );
BOOST_CHECK( ! p->prev()->prev() );
BOOST_CHECK_EQUAL( p->prev()->data().size(), 4u );
template <class SocketProtocol>
prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
-ProtocolClientSocketHandle(UninitializedType)
+ProtocolClientSocketHandle(senf::NoInit_t)
{}
template <class SocketProtocol>
// Custom includes
#include "ClientSocketHandle.hh"
#include "../config.hh"
+#include "../Utils/Tags.hh"
#include "ProtocolClientSocketHandle.mpp"
///////////////////////////////hh.p////////////////////////////////////////
// Types
typedef SocketProtocol Protocol; ///< The sockets protocol
- enum UninitializedType { Uninitialized }; ///< Flag to call 'uninitialized' constructor
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
\implementation The socket handle will have no \c body allocated.
*/
- ProtocolClientSocketHandle(UninitializedType);
+ ProtocolClientSocketHandle(senf::NoInit_t);
///@}
///////////////////////////////////////////////////////////////////////////
template <class SocketProtocol>
prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
-ProtocolServerSocketHandle(UninitializedType)
+ProtocolServerSocketHandle(senf::NoInit_t)
{}
template <class SocketProtocol>
// Custom includes
#include "ServerSocketHandle.hh"
#include "../config.hh"
+#include "../Utils/Tags.hh"
#include "ProtocolServerSocketHandle.mpp"
///////////////////////////////hh.p////////////////////////////////////////
// Types
typedef SocketProtocol Protocol; ///< The socket protocol
- enum UninitializedType { Uninitialized }; ///< Flag to call 'uninitialized' constructor
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
\implementation The socket handle will have no \c body allocated.
*/
- ProtocolServerSocketHandle(UninitializedType);
+ ProtocolServerSocketHandle(senf::NoInit_t);
///@}
///////////////////////////////////////////////////////////////////////////
std::fill(begin(), end(), 0u);
}
-prefix_ senf::INet4Address::INet4Address(NoInit_t)
+prefix_ senf::INet4Address::INet4Address(senf::NoInit_t)
{}
prefix_ senf::INet4Address senf::INet4Address::from_inaddr(inaddr_type v)
template <class InputIterator>
prefix_ senf::INet4Address senf::INet4Address::from_data(InputIterator i)
{
- INet4Address addr (INet4Address::noinit);
+ INet4Address addr (senf::noinit);
iterator j (addr.begin());
iterator const j_end (addr.end());
for (;j!=j_end;++j,++i)
#include <boost/array.hpp>
#include <boost/operators.hpp>
#include "../../../Utils/safe_bool.hh"
+#include "../../../Utils/Tags.hh"
//#include "INet4Address.mpp"
///////////////////////////////hh.p////////////////////////////////////////
static INet4Address const Loopback; ///< The loopback (127.0.0.1) address
static INet4Address const Broadcast; ////< The global broadcast (255.255.255.255) address
- enum NoInit_t { noinit };
-
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
///@{
INet4Address(); ///< Construct an empty address
- explicit INet4Address(NoInit_t); ///< Construct uninitialized (!) address
+ explicit INet4Address(senf::NoInit_t); ///< Construct uninitialized (!) address
explicit INet4Address(address_type value);
///< Construct an address constant
#define prefix_ inline
///////////////////////////////cci.p///////////////////////////////////////
-prefix_ senf::INet6Address::INet6Address(NoInit_t)
+prefix_ senf::INet6Address::INet6Address(senf::NoInit_t)
{}
prefix_ senf::INet6Address::INet6Address(boost::uint16_t a0, boost::uint16_t a1,
template <class InputIterator>
prefix_ senf::INet6Address senf::INet6Address::from_data(InputIterator i)
{
- INet6Address addr (INet6Address::noinit);
+ INet6Address addr (senf::noinit);
iterator j (addr.begin());
iterator const j_end (addr.end());
for (;j!=j_end;++j,++i)
#include <boost/array.hpp>
#include <boost/operators.hpp>
#include "../../../Utils/safe_bool.hh"
+#include "../../../Utils/Tags.hh"
#include "INet4Address.hh"
//#include "INet6Address.mpp"
static INet6Address const AllNodes; ///< The 'all nodes' link-local multicast address
static INet6Address const AllRouters; ///< The 'all routers' link-local multicast address
- enum NoInit_t { noinit };
enum Resolve_t { ResolveINet6, ResolveINet4 };
/** \brief Possible scope values
///\name Structors and default members
///@{
- explicit INet6Address(NoInit_t); ///< Construct uninitialized (!) address
+ explicit INet6Address(senf::NoInit_t); ///< Construct uninitialized (!) address
INet6Address(boost::uint16_t a0=0u, boost::uint16_t a1=0u, boost::uint16_t a2=0u,
boost::uint16_t a3=0u, boost::uint16_t a4=0u, boost::uint16_t a5=0u,
boost::uint16_t a6=0u, boost::uint16_t a7=0u);
prefix_ senf::MACAddress::MACAddress senf::MACAddress::from_string(std::string const & s)
{
- MACAddress mac (MACAddress::noinit);
+ MACAddress mac (senf::noinit);
typedef boost::char_separator<char> separator;
typedef boost::tokenizer<separator> tokenizer;
separator sep (":-");
{
if ( boost::uint16_t(v>>24) != 0xfffe )
throw SyntaxException();
- MACAddress mac (MACAddress::noinit);
+ MACAddress mac (senf::noinit);
mac[0] = boost::uint8_t( v>>56 );
mac[1] = boost::uint8_t( v>>48 );
mac[2] = boost::uint8_t( v>>40 );
std::fill(begin(),end(),0u);
}
-prefix_ senf::MACAddress::MACAddress(NoInit_t)
+prefix_ senf::MACAddress::MACAddress(senf::NoInit_t)
{}
prefix_ senf::MACAddress::MACAddress(boost::uint64_t v)
template <class InputIterator>
prefix_ senf::MACAddress::MACAddress senf::MACAddress::from_data(InputIterator i)
{
- MACAddress mac (MACAddress::noinit);
+ MACAddress mac (senf::noinit);
iterator j (mac.begin());
iterator const j_end (mac.end());
for (;j!=j_end;++j,++i)
#include <boost/utility.hpp>
#include <boost/type_traits.hpp>
#include "../../../Utils/safe_bool.hh"
+#include "../../../Utils/Tags.hh"
//#include "MACAddress.mpp"
///////////////////////////////hh.p////////////////////////////////////////
static MACAddress const Broadcast; ///< The broadcast address
static MACAddress const None; ///< The empty (0) address
- enum NoInit_t { noinit };
-
MACAddress(); ///< Construct zero-initialized address
- MACAddress(NoInit_t); ///< Construct uninitialized (!) address
+ MACAddress(senf::NoInit_t); ///< Construct uninitialized (!) address
explicit MACAddress(boost::uint64_t v); ///< Construct MACAddress constants
static MACAddress from_string(std::string const & s);
*/
void throwErrno(std::string const & where, int code);
- enum NoThrow_t { nothrow };
-
}
///////////////////////////////hh.e////////////////////////////////////////
<tr><td>\ref IpChecksum</td><td>calculating the 16 bit checksum used in the IP
specification</td></tr>
+
+ <tr><td>\ref utils_tags</td><td>Miscellaneous type tags</td></tr>
</table>
\section compatibility Compatibility
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// 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 Tags public header */
+
+#ifndef HH_Tags_
+#define HH_Tags_ 1
+
+// Custom includes
+
+//#include "Tags.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+/** \defgroup utils_tags Type tags
+
+ Type tags are used to select variants of a member, function, template or constructor. A Type tag
+ always has only a single value which is passed wherever a parameter of that tag's type is
+ needed.
+
+ The argument which expects a type-tag value will always be declared in such a way, that it is
+ optional. Examples of type tag use are:
+
+ \code
+ result = object.find<Foo>(); // This call may throw
+ result = object.find<Foo>(senf::nothrow); // This call will not throw
+ \endcode
+
+ Of course, this only works with objects which explicitly declare, that they take an optional
+ senf::NoThrow_t type aprameter.
+
+ */
+
+namespace senf {
+
+ /** \brief Type tag selecting non-throwing variant of something
+
+ This tag is used to select the non-throwing variant of a member, function, template or
+ constructor. An argument of this type is always declared in such a way, that it is
+ optional.
+
+ There is only a single value for this type: \ref senf::nothrow which is the value to pass
+ wherever an (optional) senf::NoThrow_t parameter is requested.
+
+ \see \ref utils_tags
+ \ingroup utils_tags
+ */
+ enum NoThrow_t { nothrow };
+
+ /** \brief Type tag selecting uninitialized variant of something
+
+ This tag is used to select the unititialized variant of a member, function, template or
+ constructor (mostly a constructor). An argument of this type is always declared in such a
+ way, that it is optional.
+
+ There is only a single value for this type: \ref senf::noinit which is the value to pass
+ wherever an (optional) senf::NoInit_t parameter is requested.
+
+ \see \ref utils_tags
+ \ingroup utils_tags
+ */
+ enum NoInit_t { noinit };
+
+}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "Tags.cci"
+//#include "Tags.ct"
+//#include "Tags.cti"
+#endif
+
+\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:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// 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 Tags.test unit tests */
+
+//#include "Tags.test.hh"
+//#include "Tags.test.ih"
+
+// Custom includes
+#include "Tags.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+// Nothing to test
+
+///////////////////////////////cc.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: