Utils: Implement Tags.hh and move 'senf::noinit' and 'senf::nothrow' there
g0dil [Wed, 30 Jan 2008 15:27:01 +0000 (15:27 +0000)]
Adjust all senf components to use Utils/Tags.hh (if necessary)

git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@648 270642c3-0616-0410-b53a-bc976706d245

29 files changed:
Examples/DVBAdapter/ULEdec.cc
Examples/Sniffer/Sniffer.cc
PPI/SocketSource.ct
Packets/Mainpage.dox
Packets/Packet.cti
Packets/Packet.hh
Packets/Packet.test.cc
Packets/PacketInterpreter.ct
Packets/PacketInterpreter.cti
Packets/PacketInterpreter.hh
Packets/PacketInterpreter.test.cc
Socket/ProtocolClientSocketHandle.cti
Socket/ProtocolClientSocketHandle.hh
Socket/ProtocolServerSocketHandle.cti
Socket/ProtocolServerSocketHandle.hh
Socket/Protocols/INet/INet4Address.cci
Socket/Protocols/INet/INet4Address.ct
Socket/Protocols/INet/INet4Address.hh
Socket/Protocols/INet/INet6Address.cci
Socket/Protocols/INet/INet6Address.ct
Socket/Protocols/INet/INet6Address.hh
Socket/Protocols/Raw/MACAddress.cc
Socket/Protocols/Raw/MACAddress.cci
Socket/Protocols/Raw/MACAddress.ct
Socket/Protocols/Raw/MACAddress.hh
Utils/Exception.hh
Utils/Mainpage.dox
Utils/Tags.hh [new file with mode: 0644]
Utils/Tags.test.cc [new file with mode: 0644]

index 327943a..abec6e4 100644 (file)
@@ -63,7 +63,7 @@ ULEdec::ULEdec(unsigned short adapter, unsigned short device)
 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.
index b570004..f228fe7 100644 (file)
@@ -48,7 +48,7 @@ int loop_main (int argc, char const * argv[])
 
         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(
@@ -85,7 +85,7 @@ private:
     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(
index 1ee66f3..2d9e881 100644 (file)
@@ -36,7 +36,7 @@
 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;
 }
index 1c551fd..56f68c5 100644 (file)
     
     \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
 
index 6331b1c..dd980e6 100644 (file)
@@ -154,9 +154,9 @@ senf::ConcretePacket<PacketType>::create()
 
 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>
@@ -168,9 +168,9 @@ senf::ConcretePacket<PacketType>::create(size_type size)
 
 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>
@@ -192,9 +192,9 @@ senf::ConcretePacket<PacketType>::createAfter(Packet packet)
 
 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>
@@ -206,9 +206,9 @@ senf::ConcretePacket<PacketType>::createAfter(Packet packet, size_type size)
 
 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>
@@ -230,9 +230,9 @@ senf::ConcretePacket<PacketType>::createBefore(Packet packet)
 
 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
index 996e2c1..371659a 100644 (file)
@@ -30,6 +30,7 @@
 #include <boost/operators.hpp>
 
 #include "../Utils/Exception.hh"
+#include "../Utils/Tags.hh"
 #include "../Utils/safe_bool.hh"
 #include "PacketInterpreter.hh"
 
@@ -149,9 +150,6 @@ namespace senf {
                                         ///< 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
         ///@{
@@ -446,10 +444,10 @@ namespace senf {
         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
@@ -460,11 +458,12 @@ namespace senf {
                                              \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); 
@@ -485,14 +484,14 @@ namespace senf {
                                              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
@@ -507,7 +506,7 @@ namespace senf {
                                              \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
@@ -515,7 +514,7 @@ namespace senf {
                                              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, 
@@ -541,7 +540,7 @@ namespace senf {
                                              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
index 90d383b..81e1b4b 100644 (file)
@@ -195,10 +195,10 @@ BOOST_AUTO_UNIT_TEST(concretePacket)
     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());
@@ -206,14 +206,14 @@ BOOST_AUTO_UNIT_TEST(concretePacket)
     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 );
@@ -222,7 +222,7 @@ BOOST_AUTO_UNIT_TEST(concretePacket)
     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 );
index ee4ff1f..72715e7 100644 (file)
@@ -63,14 +63,14 @@ senf::PacketInterpreter<PacketType>::create(size_type size)
 {
     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));
@@ -86,7 +86,7 @@ senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr pack
 {
     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;
@@ -95,7 +95,7 @@ senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr pack
 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)
@@ -134,7 +134,7 @@ template <class PacketType>
 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();
@@ -143,7 +143,7 @@ senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr pac
 
 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());
@@ -222,7 +222,7 @@ prefix_ senf::PacketInterpreterBase::ptr
 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;
 }
@@ -233,7 +233,7 @@ senf::PacketInterpreterBase::Factory::createAfter(PacketInterpreterBase::ptr pac
                                                   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;
 }
@@ -253,10 +253,10 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::create()
 
 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>
@@ -269,10 +269,10 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::create(size_type size)
 
 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
@@ -288,10 +288,10 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterB
 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>
@@ -306,10 +306,10 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterB
 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
@@ -326,10 +326,10 @@ createBefore(PacketInterpreterBase::ptr 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
index 1896850..b2696f6 100644 (file)
@@ -75,9 +75,9 @@ senf::PacketInterpreter<PacketType>::create()
 
 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>
@@ -101,9 +101,9 @@ senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr pack
 
 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
index 707e4b4..9a1a3fa 100644 (file)
@@ -34,6 +34,7 @@
 #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"
 
@@ -75,7 +76,6 @@ namespace senf {
 
         enum Append_t { Append };
         enum Prepend_t { Prepend };
-        enum NoInit_t { noinit };
 
         /** \brief Internal: Abstract packet factory
 
@@ -91,19 +91,19 @@ namespace senf {
             // 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;
@@ -111,7 +111,7 @@ namespace senf {
             // 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
 
@@ -256,18 +256,18 @@ namespace senf {
         // 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);
@@ -275,7 +275,7 @@ namespace senf {
         // 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
 
@@ -333,27 +333,27 @@ namespace senf {
             // 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
index eb3a6db..13c9c93 100644 (file)
@@ -129,9 +129,9 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter)
 
     {
         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 );
     }
 
@@ -162,7 +162,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter)
             (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 );
     }
@@ -178,7 +178,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter)
         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) );
     }
 
     {
@@ -204,7 +204,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter)
 
         senf::PacketInterpreter<OtherPacket>::ptr p3
             (senf::PacketInterpreter<OtherPacket>::createBefore(
-                p,senf::PacketInterpreterBase::noinit));
+                p,senf::noinit));
         
         BOOST_CHECK_EQUAL( p3->data().size(), 10u );
     }
@@ -225,10 +225,10 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter_factory)
 
     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 );
 
     {
@@ -245,7 +245,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter_factory)
         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() );
 
@@ -254,7 +254,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter_factory)
         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() );
 
@@ -273,7 +273,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter_factory)
         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 );
index 9fe7718..e467fb0 100644 (file)
@@ -37,7 +37,7 @@
 
 template <class SocketProtocol>
 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
-ProtocolClientSocketHandle(UninitializedType)
+ProtocolClientSocketHandle(senf::NoInit_t)
 {}
 
 template <class SocketProtocol>
index ed15510..8a04655 100644 (file)
@@ -30,6 +30,7 @@
 // Custom includes
 #include "ClientSocketHandle.hh"
 #include "../config.hh"
+#include "../Utils/Tags.hh"
 
 #include "ProtocolClientSocketHandle.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -66,7 +67,6 @@ namespace senf {
         // Types
 
         typedef SocketProtocol Protocol; ///< The sockets protocol
-        enum UninitializedType { Uninitialized }; ///< Flag to call 'uninitialized' constructor
 
         ///////////////////////////////////////////////////////////////////////////
         ///\name Structors and default members
@@ -95,7 +95,7 @@ namespace senf {
 
             \implementation The socket handle will have no \c body allocated.
          */
-        ProtocolClientSocketHandle(UninitializedType);
+        ProtocolClientSocketHandle(senf::NoInit_t);
 
         ///@}
         ///////////////////////////////////////////////////////////////////////////
index c615b32..85ce200 100644 (file)
@@ -37,7 +37,7 @@
 
 template <class SocketProtocol>
 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
-ProtocolServerSocketHandle(UninitializedType)
+ProtocolServerSocketHandle(senf::NoInit_t)
 {}
 
 template <class SocketProtocol>
index 4e010dc..2833f85 100644 (file)
@@ -30,6 +30,7 @@
 // Custom includes
 #include "ServerSocketHandle.hh"
 #include "../config.hh"
+#include "../Utils/Tags.hh"
 
 #include "ProtocolServerSocketHandle.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -70,7 +71,6 @@ namespace senf {
         // Types
 
         typedef SocketProtocol Protocol; ///< The socket protocol
-        enum UninitializedType { Uninitialized }; ///< Flag to call 'uninitialized' constructor
 
         ///////////////////////////////////////////////////////////////////////////
         ///\name Structors and default members
@@ -100,7 +100,7 @@ namespace senf {
 
             \implementation The socket handle will have no \c body allocated.
          */
-        ProtocolServerSocketHandle(UninitializedType);
+        ProtocolServerSocketHandle(senf::NoInit_t);
         ///@}
         ///////////////////////////////////////////////////////////////////////////
 
index 4fb8774..65cc831 100644 (file)
@@ -36,7 +36,7 @@ prefix_ senf::INet4Address::INet4Address()
     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)
index 4d223c0..408355b 100644 (file)
@@ -36,7 +36,7 @@
 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)
index 19ec737..a77903d 100644 (file)
@@ -33,6 +33,7 @@
 #include <boost/array.hpp>
 #include <boost/operators.hpp>
 #include "../../../Utils/safe_bool.hh"
+#include "../../../Utils/Tags.hh"
 
 //#include "INet4Address.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -69,14 +70,12 @@ namespace senf {
         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
 
index 95e5335..5a788b6 100644 (file)
@@ -32,7 +32,7 @@
 #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,
index 360aa9e..83cc008 100644 (file)
@@ -36,7 +36,7 @@
 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)
index a9d0cee..436d5fe 100644 (file)
@@ -33,6 +33,7 @@
 #include <boost/array.hpp>
 #include <boost/operators.hpp>
 #include "../../../Utils/safe_bool.hh"
+#include "../../../Utils/Tags.hh"
 #include "INet4Address.hh"
 
 //#include "INet6Address.mpp"
@@ -108,7 +109,6 @@ namespace senf {
         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
@@ -134,7 +134,7 @@ namespace senf {
         ///\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);
index 361e457..48d2a1b 100644 (file)
@@ -72,7 +72,7 @@ namespace {
 
 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 (":-");
@@ -92,7 +92,7 @@ prefix_ senf::MACAddress senf::MACAddress::from_eui64(boost::uint64_t v)
 {
     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 );
index 4db9e85..1879c90 100644 (file)
@@ -38,7 +38,7 @@ prefix_ senf::MACAddress::MACAddress()
     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)
index 5b62341..2c6ae39 100644 (file)
@@ -36,7 +36,7 @@
 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)
index 705c6e1..2ddd74d 100644 (file)
@@ -33,6 +33,7 @@
 #include <boost/utility.hpp>
 #include <boost/type_traits.hpp>
 #include "../../../Utils/safe_bool.hh"
+#include "../../../Utils/Tags.hh"
 
 //#include "MACAddress.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -58,10 +59,8 @@ namespace senf {
         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);
index efb44f4..787a499 100644 (file)
@@ -180,8 +180,6 @@ namespace senf {
      */
     void throwErrno(std::string const & where, int code);
 
-    enum NoThrow_t { nothrow };
-
 }
 
 ///////////////////////////////hh.e////////////////////////////////////////
index 5ea64f3..e5639af 100644 (file)
@@ -87,6 +87,8 @@ namespace senf {
 
     <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
diff --git a/Utils/Tags.hh b/Utils/Tags.hh
new file mode 100644 (file)
index 0000000..d534672
--- /dev/null
@@ -0,0 +1,100 @@
+// $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:
diff --git a/Utils/Tags.test.cc b/Utils/Tags.test.cc
new file mode 100644 (file)
index 0000000..c58dad5
--- /dev/null
@@ -0,0 +1,52 @@
+// $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: