Scheduler/Console: Add missing Node conversion operator for to variable attributor
g0dil [Thu, 4 Dec 2008 14:36:34 +0000 (14:36 +0000)]
PPI: Change most Packet arguments to const &
Packets: Change most Packet arguments to const &
Packets: Replace weird operator-> impleemntation

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

22 files changed:
PPI/CloneSource.cc
PPI/CloneSource.hh
PPI/Connectors.cci
PPI/Connectors.hh
PPI/DebugModules.cci
PPI/DebugModules.hh
PPI/SocketSink.cc
PPI/SocketSink.cci
PPI/SocketSink.hh
Packets/Packet.cci
Packets/Packet.cti
Packets/Packet.hh
Packets/PacketInterpreter.cti
Packets/PacketInterpreter.hh
Packets/PacketRegistry.cti
Packets/PacketRegistry.hh
Packets/PacketType.ct
Packets/PacketType.cti
Packets/PacketType.hh
Scheduler/Console/Variables.cti
Scheduler/Console/Variables.hh
Scheduler/Console/Variables.test.cc

index 9abde73..60f8e86 100644 (file)
@@ -32,7 +32,7 @@
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
-senf::ppi::module::CloneSource::CloneSource(senf::Packet packet)
+senf::ppi::module::CloneSource::CloneSource(senf::Packet const & packet)
     : packet_(packet)
 {
     noroute(output);
@@ -43,7 +43,7 @@ void senf::ppi::module::CloneSource::request()
 {
     output(packet_.clone());
 }
-void senf::ppi::module::CloneSource::replacePacket(senf::Packet packet)
+void senf::ppi::module::CloneSource::replacePacket(senf::Packet const & packet)
 {
     packet_ = packet;
 }
index 3c767c9..3ce6089 100644 (file)
@@ -52,8 +52,8 @@ namespace module {
 
         connector::PassiveOutput<> output;
 
-        CloneSource(senf::Packet packet);
-        void replacePacket(senf::Packet packet);
+        CloneSource(senf::Packet const & packet);
+        void replacePacket(senf::Packet const & packet);
 
     private:
         void request();
index 122e9e0..3f24b5d 100644 (file)
@@ -258,7 +258,7 @@ prefix_ senf::ppi::connector::InputConnector::InputConnector()
 ////////////////////////////////////////
 // private members
 
-prefix_ void senf::ppi::connector::InputConnector::enqueue(Packet p)
+prefix_ void senf::ppi::connector::InputConnector::enqueue(Packet const & p)
 {
     queue_.push_front(p);
     v_enqueueEvent();
@@ -273,13 +273,13 @@ prefix_ senf::ppi::connector::InputConnector & senf::ppi::connector::OutputConne
     return dynamic_cast<InputConnector&>(Connector::peer());
 }
 
-prefix_ void senf::ppi::connector::OutputConnector::operator()(Packet p)
+prefix_ void senf::ppi::connector::OutputConnector::operator()(Packet const & p)
 {
     if (connected())
         peer().enqueue(p);
 }
 
-prefix_ void senf::ppi::connector::OutputConnector::write(Packet p)
+prefix_ void senf::ppi::connector::OutputConnector::write(Packet const & p)
 {
     operator()(p);
 }
index 07316b6..2e51e9f 100644 (file)
@@ -350,7 +350,7 @@ namespace connector {
         InputConnector();
 
     private:
-        void enqueue(Packet p);
+        void enqueue(Packet const & p);
 
         virtual void v_requestEvent();
         virtual void v_enqueueEvent();
@@ -371,9 +371,9 @@ namespace connector {
         : public virtual Connector
     {
     public:
-        void operator()(Packet p);      ///< Send out a packet
+        void operator()(Packet const & p);      ///< Send out a packet
 
-        void write(Packet p);           ///< Alias for operator()(Packet p)
+        void write(Packet const & p);           ///< Alias for operator()(Packet p)
 
         InputConnector & peer() const;
 
index d1dc071..1326326 100644 (file)
@@ -38,7 +38,7 @@ prefix_ senf::ppi::module::debug::ActiveSource::ActiveSource()
     noroute(output);
 }
 
-prefix_ void senf::ppi::module::debug::ActiveSource::submit(Packet packet)
+prefix_ void senf::ppi::module::debug::ActiveSource::submit(Packet const & packet)
 {
     output(packet);
 }
@@ -68,7 +68,7 @@ prefix_ void senf::ppi::module::debug::PassiveSource::unthrottle()
     output.unthrottle();
 }
 
-prefix_ void senf::ppi::module::debug::PassiveSource::submit(Packet packet)
+prefix_ void senf::ppi::module::debug::PassiveSource::submit(Packet const & packet)
 {
     packets_.push_back(packet);
     output.unthrottle();
index b826447..1ea0f2b 100644 (file)
@@ -84,7 +84,7 @@ namespace debug {
 
         ActiveSource();
 
-        void submit(Packet packet);     ///< Submit packet
+        void submit(Packet const & packet);     ///< Submit packet
                                         /**< \pre boolean_test() is \c true */
 
         bool boolean_test() const;      ///< \c true if \a output is not throttled
@@ -113,7 +113,7 @@ namespace debug {
         void throttle();                ///< Throttle output connector
         void unthrottle();              ///< Unthrottle output connector
 
-        void submit(Packet packet);     ///< Enqueue packet
+        void submit(Packet const & packet);     ///< Enqueue packet
 
         bool empty();                   ///< \c true if queue is empty
         size_type size();               ///< Number of packets in queue
index 6c03858..f3b724d 100644 (file)
@@ -48,7 +48,8 @@ prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::destination(senf::INet4Soc
     protocolId_ = dest.port();
 }
 
-prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::operator()(Handle handle, Packet packet){
+prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::operator()(Handle handle, 
+                                                                Packet const & packet){
     sendtoandfrom(
             handle.fd(),
             reinterpret_cast<void*> (&*packet.data().begin()),
@@ -119,7 +120,8 @@ prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::destination(senf::INet6Soc
     protocolId_ = dest.port();
 }
 
-prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::operator()(Handle handle, Packet packet){
+prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::operator()(Handle handle, 
+                                                                Packet const & packet){
     sendtoandfrom(
             handle.fd(),
             reinterpret_cast<void*> (&*packet.data().begin()),
index 5e1ebda..d34a003 100644 (file)
@@ -33,7 +33,8 @@
 ///////////////////////////////////////////////////////////////////////////
 // senf::ppi::ConnectedDgramWriter
 
-prefix_ void senf::ppi::ConnectedDgramWriter::operator()(Handle handle, Packet packet)
+prefix_ void senf::ppi::ConnectedDgramWriter::operator()(Handle handle, 
+                                                         Packet const & packet)
 {
     handle.write(packet.data());
 }
index 65926d7..742e2db 100644 (file)
@@ -57,7 +57,7 @@ namespace ppi {
                                     senf::ConnectedCommunicationPolicy>::policy > Handle;
                                         ///< Handle type supported by this writer
 
-        void operator()(Handle handle, Packet packet);
+        void operator()(Handle handle, Packet const & packet);
                                         ///< Write \a packet to \a handle
                                         /**< Write the complete \a packet as a datagram to \a
                                              handle.
@@ -80,7 +80,7 @@ namespace ppi {
         void destination(senf::INet4SocketAddress & dest);
         senf::INet4SocketAddress destination();
 
-        void operator()(Handle handle, Packet packet);
+        void operator()(Handle handle, Packet const & packet);
                                         ///< Write \a packet to \a handle
                                         /**< Write the complete \a packet as a datagram to \a
                                              handle.
@@ -108,7 +108,7 @@ namespace ppi {
         void destination(senf::INet6SocketAddress & dest);
         senf::INet6SocketAddress destination();
 
-        void operator()(Handle handle, Packet packet);
+        void operator()(Handle handle, Packet const & packet);
                                         ///< Write \a packet to \a handle
                                         /**< Write the complete \a packet as a datagram to \a
                                              handle.
index 35bd931..5fb6b13 100644 (file)
@@ -108,7 +108,7 @@ prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
     return Packet(ptr()->parseNextAs(factory));
 }
 
-prefix_ senf::Packet senf::Packet::append(Packet packet)
+prefix_ senf::Packet senf::Packet::append(Packet const & packet)
     const
 {
     return Packet(ptr()->append(packet.ptr()));
@@ -131,7 +131,7 @@ prefix_ senf::Packet::size_type senf::Packet::size()
 
 // Other methods
 
-prefix_ bool senf::Packet::operator==(Packet other)
+prefix_ bool senf::Packet::operator==(Packet const & other)
     const
 {
     return ptr() == other.ptr();
@@ -142,7 +142,7 @@ prefix_ void senf::Packet::finalizeThis()
     ptr()->finalizeThis();
 }
 
-prefix_ void senf::Packet::finalizeTo(Packet other)
+prefix_ void senf::Packet::finalizeTo(Packet const & other)
 {
     ptr()->finalizeTo(other.ptr());
 }
index cfd8919..0eb6ddc 100644 (file)
@@ -204,28 +204,29 @@ create(ForwardReadableRange const & range,
 
 template <class PacketType>
 prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createAfter(Packet packet)
+senf::ConcretePacket<PacketType>::createAfter(Packet const & packet)
 {
     return ConcretePacket(interpreter::createAfter(packet.ptr()));
 }
 
 template <class PacketType>
 prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createAfter(Packet packet, senf::NoInit_t)
+senf::ConcretePacket<PacketType>::createAfter(Packet const & packet, senf::NoInit_t)
 {
     return ConcretePacket(interpreter::createAfter(packet.ptr(),senf::noinit));
 }
 
 template <class PacketType>
 prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createAfter(Packet packet, size_type size)
+senf::ConcretePacket<PacketType>::createAfter(Packet const & packet, size_type size)
 {
     return ConcretePacket(interpreter::createAfter(packet.ptr(), size));
 }
 
 template <class PacketType>
 prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createAfter(Packet packet, size_type size, senf::NoInit_t)
+senf::ConcretePacket<PacketType>::createAfter(Packet const & packet, size_type size, 
+                                              senf::NoInit_t)
 {
     return ConcretePacket(interpreter::createAfter(packet.ptr(), size, senf::noinit));
 }
@@ -235,7 +236,7 @@ senf::ConcretePacket<PacketType>::createAfter(Packet packet, size_type size, sen
 template <class PacketType>
 template <class ForwardReadableRange>
 prefix_ senf::ConcretePacket<PacketType> senf::ConcretePacket<PacketType>::
-createAfter(Packet packet, ForwardReadableRange const & range,
+createAfter(Packet const & packet, ForwardReadableRange const & range,
             typename boost::disable_if< boost::is_integral<ForwardReadableRange> >::type *)
 {
     return ConcretePacket(interpreter::createAfter(packet.ptr(), range));
@@ -247,14 +248,14 @@ createAfter(Packet packet, ForwardReadableRange const & range,
 
 template <class PacketType>
 prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createBefore(Packet packet)
+senf::ConcretePacket<PacketType>::createBefore(Packet const & packet)
 {
     return ConcretePacket(interpreter::createBefore(packet.ptr()));
 }
 
 template <class PacketType>
 prefix_ senf::ConcretePacket<PacketType>
-senf::ConcretePacket<PacketType>::createBefore(Packet packet, senf::NoInit_t)
+senf::ConcretePacket<PacketType>::createBefore(Packet const & packet, senf::NoInit_t)
 {
     return ConcretePacket(interpreter::createBefore(packet.ptr(), senf::noinit));
 }
@@ -272,19 +273,19 @@ senf::ConcretePacket<PacketType>::clone()
 // Field access
 
 template <class PacketType>
-prefix_ typename senf::ConcretePacket<PacketType>::Parser *
-senf::ConcretePacket<PacketType>::operator->()
+prefix_ typename senf::ConcretePacket<PacketType>::Parser
+senf::ConcretePacket<PacketType>::parser()
     const
 {
-    return ptr()->fields_p();
+    return ptr()->fields();
 }
 
 template <class PacketType>
-prefix_ typename senf::ConcretePacket<PacketType>::Parser
-senf::ConcretePacket<PacketType>::parser()
+prefix_ typename senf::ConcretePacket<PacketType>::ParserProxy
+senf::ConcretePacket<PacketType>::operator->()
     const
 {
-    return ptr()->fields();
+    return ParserProxy(parser());
 }
 
 // private members
index 3d51f78..d3b42a4 100644 (file)
@@ -137,7 +137,7 @@ namespace senf {
             \ref ConcretePacket for the %type specific interface\n
             \ref PacketData for the sequence interface\n
             \ref packetparser for a specification of the parser interface
-      */
+     */
     class Packet
         : public safe_bool<Packet>,
           public boost::equality_comparable<Packet>
@@ -148,7 +148,7 @@ namespace senf {
         
         typedef void type;              ///< Type of the packet.
         typedef senf::detail::packet::size_type size_type;
-                                        ///< Unsigned type to represent packet size
+        ///< Unsigned type to represent packet size
         typedef PacketInterpreterBase::factory_t factory_t; ///< Packet factory type (see below)
 
         ///////////////////////////////////////////////////////////////////////////
@@ -173,9 +173,9 @@ namespace senf {
 
         template <class PacketType>     
         Packet(ConcretePacket<PacketType> packet); ///< Copy-construct Packet from ConcretePacket
-                                        /**< This constructor allows to convert an arbitrary
-                                             ConcretePacket into a general Packet, loosing the
-                                             protocol specific interface. */
+        /**< This constructor allows to convert an arbitrary
+             ConcretePacket into a general Packet, loosing the
+             protocol specific interface. */
 
         ///@}
         ///////////////////////////////////////////////////////////////////////////
@@ -183,123 +183,123 @@ namespace senf {
         ///\name Interpreter chain access
         ///@{
 
-                                     Packet      next() const; 
-                                        ///< Get next packet in chain
-                                        /**< \throws InvalidPacketChainException if no next packet 
-                                             exists */
-                                     Packet      next(NoThrow_t) const; 
-                                        ///< Get next packet in chain
-                                        /**< \returns in - valid() packet if no next packet 
-                                             exists */
+        Packet      next() const; 
+        ///< Get next packet in chain
+        /**< \throws InvalidPacketChainException if no next packet 
+             exists */
+        Packet      next(NoThrow_t) const; 
+        ///< Get next packet in chain
+        /**< \returns in - valid() packet if no next packet 
+             exists */
         template <class OtherPacket> OtherPacket next() const; 
-                                        ///< Get next packet in chain and cast to \a OtherPacket
-                                        /**< \throws std::bad_cast if the next() packet is not of
-                                             type \a OtherPacket
-                                             \throws InvalidPacketChainException if no next packet
-                                                 exists */
+        ///< Get next packet in chain and cast to \a OtherPacket
+        /**< \throws std::bad_cast if the next() packet is not of
+             type \a OtherPacket
+             \throws InvalidPacketChainException if no next packet
+                 exists */
         template <class OtherPacket> OtherPacket next(NoThrow_t) const; 
-                                        ///< Get next packet in chain and cast to \a OtherPacket
-                                        /**< \throws std::bad_cast if the next() packet is not of
-                                             type \a OtherPacket
-                                             \returns in - valid() packet if no next packet
-                                                 exists */
+        ///< Get next packet in chain and cast to \a OtherPacket
+        /**< \throws std::bad_cast if the next() packet is not of
+             type \a OtherPacket
+             \returns in - valid() packet if no next packet
+                 exists */
         template <class OtherPacket> OtherPacket find() const;
-                                        ///< Search chain forward for packet of type \a OtherPacket
-                                        /**< The search will start with the current packet.
-                                             \throws InvalidPacketChainException if no packet of
-                                                 type \a OtherPacket can be found. */
+        ///< Search chain forward for packet of type \a OtherPacket
+        /**< The search will start with the current packet.
+             \throws InvalidPacketChainException if no packet of
+                 type \a OtherPacket can be found. */
         template <class OtherPacket> OtherPacket find(NoThrow_t) const;
-                                        ///< Search chain forward for packet of type \a OtherPacket
-                                        /**< The search will start with the current packet.
-                                             \returns in - valid() packet if no packet of type \a
-                                                 OtherPacket can be found. */
+        ///< Search chain forward for packet of type \a OtherPacket
+        /**< The search will start with the current packet.
+             \returns in - valid() packet if no packet of type \a
+                 OtherPacket can be found. */
         
-                                     Packet      prev() const; 
-                                        ///< Get previous packet in chain
-                                        /**< \throws InvalidPacketChainException if no previous
-                                             packet exists */
-                                     Packet      prev(NoThrow_t) const; 
-                                        ///< Get previous packet in chain
-                                        /**< \returns in - valid() packet if no previous packet
-                                             exists */
+        Packet      prev() const; 
+        ///< Get previous packet in chain
+        /**< \throws InvalidPacketChainException if no previous
+             packet exists */
+        Packet      prev(NoThrow_t) const; 
+        ///< Get previous packet in chain
+        /**< \returns in - valid() packet if no previous packet
+             exists */
         template <class OtherPacket> OtherPacket prev() const; 
-                                        ///< Get previous packet in chain and cast to \a OtherPacket
-                                        /**< \throws std::bad_cast, if the previous packet is not of
-                                             type \a OtherPacket
-                                             \throws InvalidPacketChainException if no previous
-                                                 packet exists */
+        ///< Get previous packet in chain and cast to \a OtherPacket
+        /**< \throws std::bad_cast, if the previous packet is not of
+             type \a OtherPacket
+             \throws InvalidPacketChainException if no previous
+                 packet exists */
         template <class OtherPacket> OtherPacket prev(NoThrow_t) const; 
-                                        ///< Get previous packet in chain and cast to \a OtherPacket
-                                        /**< \throws std::bad_cast, if the previous packet is not of
-                                             type \a OtherPacket
-                                             \returns in - valid() packet if no previous packet 
-                                                 exists */
+        ///< Get previous packet in chain and cast to \a OtherPacket
+        /**< \throws std::bad_cast, if the previous packet is not of
+             type \a OtherPacket
+             \returns in - valid() packet if no previous packet 
+                 exists */
         template <class OtherPacket> OtherPacket rfind() const;
-                                        ///< Search chain backwards for packet of type \a OtherPacket
-                                        /**< The search will start with the current packet.
-                                             \throws InvalidPacketChainException if no packet of
-                                                 type \a OtherPacket can be found. */
+        ///< Search chain backwards for packet of type \a OtherPacket
+        /**< The search will start with the current packet.
+             \throws InvalidPacketChainException if no packet of
+                 type \a OtherPacket can be found. */
         template <class OtherPacket> OtherPacket rfind(NoThrow_t) const;
-                                        ///< Search chain backwards for packet of type \a OtherPacket
-                                        /**< The search will start with the current packet.
-                                             \returns in - valid() packet if no packet of type \a
-                                                 OtherPacket can be found. */
+        ///< Search chain backwards for packet of type \a OtherPacket
+        /**< The search will start with the current packet.
+             \returns in - valid() packet if no packet of type \a
+                 OtherPacket can be found. */
 
 
-                                     Packet      first() const;
-                                        ///< Return first packet in chain
+        Packet      first() const;
+        ///< Return first packet in chain
         template <class OtherPacket> OtherPacket first() const;
-                                        ///< Return first packet in chain and cast
-                                        /**< \throws std::bad_cast if the first() packet is not of
-                                             type \a OtherPacket */
+        ///< Return first packet in chain and cast
+        /**< \throws std::bad_cast if the first() packet is not of
+             type \a OtherPacket */
 
-                                     Packet      last() const;
-                                        ///< Return last packet in chain
+        Packet      last() const;
+        ///< Return last packet in chain
         template <class OtherPacket> OtherPacket last() const;
-                                        ///< Return last packet in chain and cast
-                                        /**< \throws std::bad_cast if the last() packet is not of
-                                             type \a OtherPacket  */
+        ///< Return last packet in chain and cast
+        /**< \throws std::bad_cast if the last() packet is not of
+             type \a OtherPacket  */
 
 
         template <class OtherPacket> OtherPacket parseNextAs() const;
-                                        ///< Interpret payload of \c this as \a OtherPacket
-                                        /**< parseNextAs() will throw away the packet chain after
-                                             the current packet if necessary. It will then parse the
-                                             payload section of \c this packet as given by \a
-                                             OtherPacket. The new packet is added to the chain after
-                                             \c this.
-                                             \returns new packet instance sharing the same data and
-                                                 placed after \c this packet in the chain. */
-                                     Packet      parseNextAs(factory_t factory) const;
-                                        ///< Interpret payload of \c this as \a factory type packet
-                                        /**< parseNextAs() will throw away the packet chain after
-                                             the current packet if necessary. It will then parse the
-                                             payload section of \c this packet as given by \a
-                                             factory. The new packet is added to the chain after
-                                             \c this.
-                                             \returns new packet instance sharing the same data and
-                                                 placed after \c this packet in the chain. */
+        ///< Interpret payload of \c this as \a OtherPacket
+        /**< parseNextAs() will throw away the packet chain after
+             the current packet if necessary. It will then parse the
+             payload section of \c this packet as given by \a
+             OtherPacket. The new packet is added to the chain after
+             \c this.
+             \returns new packet instance sharing the same data and
+                 placed after \c this packet in the chain. */
+        Packet      parseNextAs(factory_t factory) const;
+        ///< Interpret payload of \c this as \a factory type packet
+        /**< parseNextAs() will throw away the packet chain after
+             the current packet if necessary. It will then parse the
+             payload section of \c this packet as given by \a
+             factory. The new packet is added to the chain after
+             \c this.
+             \returns new packet instance sharing the same data and
+                 placed after \c this packet in the chain. */
 
         template <class OtherPacket> bool        is() const;
-                                        ///< Check, whether \c this packet is of the given type
+        ///< Check, whether \c this packet is of the given type
         template <class OtherPacket> OtherPacket as() const;
-                                        ///< Cast current packet to the given type
-                                        /**< This operations returns a handle to the same packet
-                                             header/interpreter however cast to the given
-                                             ConcretePacket type.
-                                             \throws std::bad_cast if the current packet is not of
-                                                 type \a OtherPacket */
-
-        Packet append(Packet packet) const; ///< Append the given packet to \c this packet
-                                        /**< This operation will replace the payload section of \c
-                                             this packet with \a packet. This operation will replace
-                                             the packet chain after \c this packet with a clone of
-                                             \a packet and will replace the raw data of the payload
-                                             of \c this with the raw data of \a packet. \c this
-                                             packet will not share any date with \a packet.
-                                             \returns Packet handle to the cloned \a packet, placed
-                                                 after \c this in the packet/header/interpreter
-                                                 chain. */
+        ///< Cast current packet to the given type
+        /**< This operations returns a handle to the same packet
+             header/interpreter however cast to the given
+             ConcretePacket type.
+             \throws std::bad_cast if the current packet is not of
+                 type \a OtherPacket */
+
+        Packet append(Packet const & packet) const; ///< Append the given packet to \c this packet
+        /**< This operation will replace the payload section of \c
+             this packet with \a packet. This operation will replace
+             the packet chain after \c this packet with a clone of
+             \a packet and will replace the raw data of the payload
+             of \c this with the raw data of \a packet. \c this
+             packet will not share any date with \a packet.
+             \returns Packet handle to the cloned \a packet, placed
+                 after \c this in the packet/header/interpreter
+                 chain. */
 
         ///@}
 
@@ -325,9 +325,9 @@ namespace senf {
                                              struct.
 
                                              \code
-                                             struct MyAnnotation {
+                                                 struct MyAnnotation {
                                                  int value;
-                                             };
+                                                 };
 
                                              senf::Packet p (...);
                                             
@@ -346,11 +346,11 @@ namespace senf {
                                              lead to a program crash.
 
                                              \code
-                                             struct MyStringAnnotation : senf::ComplexAnnotation {
+                                                 struct MyStringAnnotation : senf::ComplexAnnotation {
                                                  std::string value;
-                                             };
+                                                 };
                                              \endcode
-                                             (This type is not POD since \c std::string is not POD)
+                                                 (This type is not POD since \c std::string is not POD)
 
                                              \see \ref packet_usage_annotation
 
@@ -379,9 +379,9 @@ namespace senf {
         ///\name Other methods
         ///@{
 
-        bool operator==(Packet other) const; ///< Check for packet identity
-                                        /**< Two packet handles compare equal if they really are the
-                                             same packet header in the same packet chain. */
+        bool operator==(Packet const & other) const; ///< Check for packet identity
+        /**< Two packet handles compare equal if they really are the
+             same packet header in the same packet chain. */
         bool boolean_test() const;      ///< Check, whether the packet is valid()
                                         /**< \see valid() */
         bool valid() const;             ///< Check, whether the packet is valid()
@@ -423,20 +423,20 @@ namespace senf {
                                              
                                              This call is equivalent to
                                              \code
-                                             p.finalizeTo(p.next<Other>())
+                                                 p.finalizeTo(p.next<Other>())
                                              \endcode */
 
-        void finalizeTo(Packet other);  ///< Update calculated fields
-                                        /**< The finalize() fammily of members will update
-                                             calculated packet fields: checksums, size fields and so
-                                             on. This includes any field, which can be set from
-                                             other information in the packet. Each concrete packet
-                                             type should document, which fields are set by
-                                             finalize().
+        void finalizeTo(Packet const & other);  ///< Update calculated fields
+        /**< The finalize() fammily of members will update
+             calculated packet fields: checksums, size fields and so
+             on. This includes any field, which can be set from
+             other information in the packet. Each concrete packet
+             type should document, which fields are set by
+             finalize().
 
-                                             finalizeTo(other) will automatically process all
-                                             packets/headers/interpreters beginning at \a other
-                                             backwards towards outer packets up to \c this. */
+             finalizeTo(other) will automatically process all
+             packets/headers/interpreters beginning at \a other
+             backwards towards outer packets up to \c this. */
 
         void finalizeAll();             ///< Update calculated fields
                                         /**< The finalize() fammily of members will update
@@ -449,35 +449,35 @@ namespace senf {
                                              finalizeAll() will automatically process all
                                              packets/headers/interpreters from the end of the chain
                                              (the most inner packet) backwards up to \c this. 
-                                             
+
                                              This call is equivalent to
                                              \code
-                                             p.finalizeTo(p.last())
+                                                 p.finalizeTo(p.last())
                                              \endcode 
-                                             
+
                                              Beware, that finalizeAll() will \e not finalize any
                                              headers before \c this, it will \e only process inner
                                              headers. */
 
         void dump(std::ostream & os) const; ///< Write out a printable packet representation
-                                        /**< This method is provided mostly to help debugging packet
-                                             problems. Each concrete packet should implement a dump
-                                             method writing out all fields of the packet in a
-                                             readable representation. dump() will call this member
-                                             for each packet/header/interpreter in the chain from \c
-                                             this packet up to the end of the chain. */
+        /**< This method is provided mostly to help debugging packet
+             problems. Each concrete packet should implement a dump
+             method writing out all fields of the packet in a
+             readable representation. dump() will call this member
+             for each packet/header/interpreter in the chain from \c
+             this packet up to the end of the chain. */
 
         TypeIdValue typeId() const;     ///< Get id of \c this packet
-                                        /**< This value is used e.g. in the packet registry to
-                                             associate packet types with other information.
-                                             \returns A type holding the same information as a
-                                                 type_info object, albeit assignable */
+        /**< This value is used e.g. in the packet registry to
+             associate packet types with other information.
+             \returns A type holding the same information as a
+                 type_info object, albeit assignable */
         factory_t factory() const;      ///< Return factory instance of \c this packet
-                                        /**< The returned factory instance can be used to create new
-                                             packets of the given type without knowing the concrete
-                                             type of the packet. The value may be stored away for
-                                             later use if needed. */
-        
+        /**< The returned factory instance can be used to create new
+             packets of the given type without knowing the concrete
+             type of the packet. The value may be stored away for
+             later use if needed. */
+
         ///@}
 
     protected:
@@ -488,9 +488,9 @@ namespace senf {
     private:
         Packet checkNext() const;
         Packet checkLast() const;
-        
+
         PacketInterpreterBase::ptr packet_;
-        
+
         template <class PacketType>
         friend class ConcretePacket;
         friend class PacketParserBase;
@@ -508,13 +508,13 @@ namespace senf {
 
         The new members provided by ConcretePacket over packet are mostly comprised of the packet
         constructors. These come in three major flavors:
-        
+
         \li The create() family of constructors will create completely new packets.
         \li The createAfter() family of constructors will create new packets (with new data for the
             packet) \e after a given existing packet.
         \li The createBefore()  family of constructors will create new packets (again with new data)
             \e before a given existing packet.
-        
+
         Whereas create() will create a completely new packet with it's own chain and data storage,
         createAfter() and createBefore() extend a packet with additional
         headers/interpreters. createAfter() will set the payload of the given packet to the new
@@ -524,10 +524,10 @@ namespace senf {
         createAfter() differs from Packet::parseNextAs() in that the former creates a new packet \e
         replacing any possibly existing data whereas the latter will interpret the already \e
         existing data as given by the type argument.
-        
+
         \see \ref PacketTypeBase for a specification of the interface to be provided by the \a
             PacketType policy class.
-      */
+     */
     template <class PacketType>
     class ConcretePacket 
         : public Packet
@@ -535,7 +535,7 @@ namespace senf {
     public:
         ///////////////////////////////////////////////////////////////////////////
         // Types
-        
+
         typedef PacketType type;
         typedef typename PacketType::parser Parser;
 
@@ -549,40 +549,40 @@ namespace senf {
         // no conversion constructors
 
         ConcretePacket();               ///< Create uninitialized packet handle
-                                        /**< An uninitialized handle is not valid(). It does not
-                                             allow any operation except assignment and checking for
-                                             validity. */
+        /**< An uninitialized handle is not valid(). It does not
+             allow any operation except assignment and checking for
+             validity. */
 
         static factory_t factory();     ///< Return factory for packets of specific type
-                                        /**< This \e static member is like Packet::factory() for a
-                                             specific packet of type \a PacketType */
+        /**< This \e static member is like Packet::factory() for a
+             specific packet of type \a PacketType */
 
         // Create completely new packet
 
         static ConcretePacket create(); ///< Create default initialized packet
-                                        /**< The packet will be initialized to it's default empty
-                                             state. */
+        /**< The packet will be initialized to it's default empty
+             state. */
         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] senf::noinit This parameter must always have the
-                                                 value \c senf::noinit. */
+        /**< This will create a completely empty and uninitialized
+             packet with <tt>size() == 0</tt>.
+             \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
-                                             with the given size. If the size parameter is smaller
-                                             than the minimum allowed packet size an exception will
-                                             be thrown.
-                                             \param[in] size Size of the packet to create in bytes.
-                                             \throws TruncatedPacketException if \a size is smaller
-                                                 than the smallest permissible size for this type of
-                                                 packet. */
+        /**< This member will create a default initialized packet
+             with the given size. If the size parameter is smaller
+             than the minimum allowed packet size an exception will
+             be thrown.
+             \param[in] size Size of the packet to create in bytes.
+             \throws TruncatedPacketException if \a size is smaller
+                 than the smallest permissible size for this type of
+                 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] senf::noinit This parameter must always have the
-                                                 value \c senf::noinit. */
+        ///< 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] senf::noinit This parameter must always have the
+                 value \c senf::noinit. */
 #ifndef DOXYGEN
         template <class ForwardReadableRange>
         static ConcretePacket create(
@@ -591,105 +591,112 @@ namespace senf {
 #else
         template <class ForwardReadableRange>
         static ConcretePacket create(ForwardReadableRange const & range); 
-                                        ///< Create packet from given data
-                                        /**< The packet will be created from a copy of the given
-                                             data. The data from the range will be copied directly
-                                             into the packet representation. The data will \e not be
-                                             validated in any way.
-                                             \param[in] range <a
-                                                 href="http://www.boost.org/libs/range/index.html">Boost.Range</a> 
-                                                 of data to construct packet from. */
+        ///< Create packet from given data
+        /**< The packet will be created from a copy of the given
+             data. The data from the range will be copied directly
+             into the packet representation. The data will \e not be
+             validated in any way.
+             \param[in] range <a
+                 href="http://www.boost.org/libs/range/index.html">Boost.Range</a> 
+                 of data to construct packet from. */
 #endif
 
         // Create packet as new packet after a given packet
 
-        static ConcretePacket createAfter(Packet packet); 
-                                        ///< Create default initialized packet after \a packet
-                                        /**< The packet will be initialized to it's default empty
-                                             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, 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] 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
-                                        /**< This member will create a default initialized packet
-                                             with the given size. If the size parameter is smaller
-                                             than the minimum allowed packet size an exception will
-                                             be thrown. 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] size Size of the packet to create in bytes.
-                                             \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, 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
-                                             header/interpreter after \a packet in that packets
-                                             interpreter chain.
-                                             \param[in] packet Packet to append new packet to.
-                                             \param[in] size Size of the packet to create in bytes
-                                             \param[in] senf::noinit This parameter must always have the
-                                                 value \c senf::noinit. */
+        static ConcretePacket createAfter(Packet const & packet); 
+        ///< Create default initialized packet after \a packet
+        /**< The packet will be initialized to it's default empty
+             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 const & 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] senf::noinit This parameter must always have the
+                 value \c senf::noinit. */
+        static ConcretePacket createAfter(Packet const & packet, size_type size);
+        ///< Create default initialized packet after \a packet
+        /**< This member will create a default initialized packet
+             with the given size. If the size parameter is smaller
+             than the minimum allowed packet size an exception will
+             be thrown. 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] size Size of the packet to create in bytes.
+             \throws TruncatedPacketException if \a size is smaller
+                 than the smallest permissible size for this type of
+                 packet. */
+        static ConcretePacket createAfter(Packet const & 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
+             header/interpreter after \a packet in that packets
+             interpreter chain.
+             \param[in] packet Packet to append new packet to.
+             \param[in] size Size of the packet to create in bytes
+             \param[in] senf::noinit This parameter must always have the
+                 value \c senf::noinit. */
 #ifndef DOXYGEN
         template <class ForwardReadableRange>
         static ConcretePacket createAfter(
-            Packet packet, 
+            Packet const & packet, 
             ForwardReadableRange const & range,
             typename boost::disable_if< boost::is_integral<ForwardReadableRange> >::type * = 0);
 #else
         template <class ForwardReadableRange>
-        static ConcretePacket createAfter(Packet packet, 
+        static ConcretePacket createAfter(Packet const & packet, 
                                           ForwardReadableRange const & range);
-                                        ///< Create packet from given data after \a packet
-                                        /**< The packet will be created from a copy of the given
-                                             data. The data from the range will be copied directly
-                                             into the packet representation. The data will \e not be
-                                             validated in any way.  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] range <a
-                                                 href="http://www.boost.org/libs/range/index.html">Boost.Range</a> 
-                                                 of data to construct packet from. */
+        ///< Create packet from given data after \a packet
+        /**< The packet will be created from a copy of the given
+             data. The data from the range will be copied directly
+             into the packet representation. The data will \e not be
+             validated in any way.  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] range <a
+                 href="http://www.boost.org/libs/range/index.html">Boost.Range</a> 
+                 of data to construct packet from. */
 #endif
 
         // Create packet as new packet (header) before a given packet
 
-        static ConcretePacket createBefore(Packet packet); 
-                                        ///< Create default initialized packet before \a packet
-                                        /**< The packet will be initialized to it's default empty
-                                             state. It will be prepended as previous
-                                             header/interpreter before \a packet in that packets
-                                             interpreter chain.
-                                             \param[in] packet Packet to prepend new packet to. */
-        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
-                                             \a packet in that packets interpreter chain.
-                                             \param[in] packet Packet to prepend new packet to. */
+        static ConcretePacket createBefore(Packet const & packet); 
+        ///< Create default initialized packet before \a packet
+        /**< The packet will be initialized to it's default empty
+             state. It will be prepended as previous
+             header/interpreter before \a packet in that packets
+             interpreter chain.
+             \param[in] packet Packet to prepend new packet to. */
+        static ConcretePacket createBefore(Packet const & 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
+             \a packet in that packets interpreter chain.
+             \param[in] packet Packet to prepend new packet to. */
         
         // Create a clone of the current packet
 
         ConcretePacket clone() const;
-
+         
         ///@}
         ///////////////////////////////////////////////////////////////////////////
-
+         
         // Field access
-
-        Parser * operator->() const;    ///< Access packet fields
+         
+        struct ParserProxy 
+        {
+            ParserProxy(Parser const & p) : p_ (p) {}
+            Parser * operator->() { return &p_; }
+            Parser p_;
+        };
+
+        ParserProxy operator->() const;    ///< Access packet fields
                                         /**< This operator allows to access the parsed fields of the
                                              packet using the notation <tt>packet->field()</tt>. The
                                              fields of the packet are specified by the PacketType's
index f542015..8dd19a9 100644 (file)
@@ -60,12 +60,6 @@ prefix_ Annotation & senf::PacketInterpreterBase::annotation()
 // senf::PacketInterpreter<PacketType>
 
 template <class PacketType>
-prefix_ senf::PacketInterpreter<PacketType>::~PacketInterpreter()
-{
-    parser_p()->~parser();
-}
-
-template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::factory_t
 senf::PacketInterpreter<PacketType>::factory()
 {
@@ -132,32 +126,6 @@ senf::PacketInterpreter<PacketType>::fields()
     return parser (data().begin(),&data());
 }
 
-template <class PacketType>
-prefix_ typename senf::PacketInterpreter<PacketType>::parser *
-senf::PacketInterpreter<PacketType>::fields_p()
-{
-    // This is somewhat awkward. We want to allow the user to access the packet's field using the
-    // 'operator->' member of the packet class (the handle). Now, 'operator->' *must* return a
-    // pointer to a non-dynamically allocated object. So where should it point to? We need to return
-    // a pointer to a parser instance, but parser instances are designed to be transient (they are
-    // invalidated whenever a packet's size is changed).
-
-    // What we do is the following: parserStorage_ is an (initialy uninitialized) storage area
-    // within the interpreter with enough space (and correct alignment) to take hold of a parser
-    // instance. In the constructor we use placement new to construct a parser in this area which we
-    // explicit dispose of in the destructor. Now, whenever the fields_p() member is called, we
-    // destroy the parser object and recreate it. 
-
-    // This does introduce one additional problem: It is not safe for multiple threads to
-    // concurrently read from the same packet. On the other hand, the packet classes are not
-    // syncronized in any way and are not safe to use from multiple threads anyways (e.g. the lazy
-    // packet chain makes some read-only operations change the packet which is not thread safe).
-
-    parser_p()->~parser();
-    new (parser_p()) parser (data().begin(),&data());
-    return parser_p();
-}
-
 ////////////////////////////////////////
 // private members
 
@@ -183,17 +151,13 @@ template <class PacketType>
 prefix_ senf::PacketInterpreter<PacketType>::PacketInterpreter(detail::PacketImpl * impl,
                                                                iterator b, iterator e, Append_t)
     : PacketInterpreterBase(impl,b,e,Append)
-{
-    new (parser_p()) parser (data().begin(),&data());
-}
+{}
 
 template <class PacketType>
 prefix_ senf::PacketInterpreter<PacketType>::PacketInterpreter(detail::PacketImpl * impl,
                                                                iterator b, iterator e, Prepend_t)
     : PacketInterpreterBase(impl,b,e,Prepend)
-{
-    new (parser_p()) parser (data().begin(),&data());
-}
+{}
 
 // PacketType access
 
@@ -218,13 +182,6 @@ prefix_ void senf::PacketInterpreter<PacketType>::init()
     return type::init(ConcretePacket<PacketType>(ptr(this)));
 }
 
-template <class PacketType>
-prefix_ typename senf::PacketInterpreter<PacketType>::parser *
-senf::PacketInterpreter<PacketType>::parser_p()
-{
-    return reinterpret_cast<parser *>(&parserStorage_);
-}
-
 ///////////////////////////////cti.e///////////////////////////////////////
 #undef prefix_
 
index 66fc03f..ac38e7d 100644 (file)
@@ -30,8 +30,6 @@
 #include "../boost/intrusive/ilist.hpp"
 #include <boost/optional.hpp>
 #include <boost/range.hpp>
-#include <boost/type_traits/aligned_storage.hpp>
-#include <boost/type_traits/alignment_of.hpp>
 #include "../Utils/intrusive_refcount.hh"
 #include "../Utils/pool_alloc_mixin.hh"
 #include "../Utils/Tags.hh"
@@ -258,8 +256,6 @@ namespace senf {
         // no copy
         // no conversion constructors
 
-        ~PacketInterpreter();
-
         static factory_t factory();
 
         // Create completely new packet
@@ -296,7 +292,6 @@ namespace senf {
         // Packet field access
 
         parser fields();
-        parser * fields_p();
 
         // PacketType access
 
@@ -373,11 +368,6 @@ namespace senf {
 
         static const FactoryImpl factory_;
 
-        parser * parser_p();
-
-        boost::aligned_storage< sizeof(parser), 
-                                boost::alignment_of<parser>::value > parserStorage_;
-
         friend class detail::packet::test::TestDriver;
         friend class PacketInterpreterBase;
         friend class FactoryImpl;
index 5687850..fa4096d 100644 (file)
@@ -66,14 +66,14 @@ prefix_ typename boost::optional<typename Tag::key_t> senf::PacketRegistry<Tag>:
 }
 
 template <class Tag>
-prefix_ typename Tag::key_t senf::PacketRegistry<Tag>::key(Packet packet)
+prefix_ typename Tag::key_t senf::PacketRegistry<Tag>::key(Packet const & packet)
 {
     return registry().key(packet.typeId());
 }
 
 template <class Tag>
 prefix_ typename boost::optional<typename Tag::key_t>
-senf::PacketRegistry<Tag>::key(Packet packet, NoThrow_t)
+senf::PacketRegistry<Tag>::key(Packet const & packet, NoThrow_t)
 {
     return registry().key(packet.typeId(),true);
 }
index 6164133..2311f3e 100644 (file)
@@ -152,7 +152,7 @@ namespace senf {
             \returns key of the packet
             \throws PacketTypeNotRegistered if the packet type is not found in the registry.
          */
-        static typename Tag::key_t key(Packet packet);
+        static typename Tag::key_t key(Packet const & packet);
 
         /** \brief Find key of a packet
 
@@ -163,7 +163,7 @@ namespace senf {
                 href="http://www.boost.org/libs/optional/doc/optional.html">boost::optional</a> or
                 an unbound optional, if the key is not found.
          */
-        static typename boost::optional<typename Tag::key_t> key(Packet packet, NoThrow_t);
+        static typename boost::optional<typename Tag::key_t> key(Packet const & packet, NoThrow_t);
 
         /** \brief Lookup a packet by it's key
 
index 8e5d4a6..caec158 100644 (file)
@@ -35,7 +35,7 @@
 
 template <class Self>
 prefix_ senf::PacketInterpreterBase::optional_range
-senf::PacketTypeMixin<Self,void>::nextPacketRange(Packet p)
+senf::PacketTypeMixin<Self,void>::nextPacketRange(Packet const & p)
 {
     typename Self::size_type sz (Self::initHeadSize());
     ///\idea This if condition could be replaced with a compile time switch by checking, wether
index 75be1a7..1b7e693 100644 (file)
@@ -46,7 +46,7 @@ prefix_ senf::PacketTypeBase::factory_t senf::PacketTypeBase::factory()
 
 template <class Self, class Registry>
 prefix_ senf::PacketInterpreterBase::optional_range
-senf::PacketTypeMixin<Self,Registry>::nextPacketRange(Packet p)
+senf::PacketTypeMixin<Self,Registry>::nextPacketRange(Packet const & p)
 {
     // Call the member defined in the specialization below
     return PacketTypeMixin<Self>::nextPacketRange(p);
@@ -54,7 +54,7 @@ senf::PacketTypeMixin<Self,Registry>::nextPacketRange(Packet p)
 
 template <class Self, class Registry>
 prefix_ senf::PacketInterpreterBase::factory_t
-senf::PacketTypeMixin<Self,Registry>::nextPacketType(Packet p)
+senf::PacketTypeMixin<Self,Registry>::nextPacketType(Packet const & p)
 {
     if (p.data().size() < Self::initSize())
         return Self::no_factory();
@@ -68,14 +68,14 @@ prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin<Self,Regist
 }
 
 template <class Self, class Registry>
-prefix_ void senf::PacketTypeMixin<Self,Registry>::init(Packet p)
+prefix_ void senf::PacketTypeMixin<Self,Registry>::init(Packet const & p)
 {
     p.as< ConcretePacket<Self> >()->init();
 }
 
 template <class Self, class Registry>
 prefix_ typename senf::PacketTypeMixin<Self,Registry>::optional_key_t
-senf::PacketTypeMixin<Self,Registry>::key(Packet p)
+senf::PacketTypeMixin<Self,Registry>::key(Packet const & p)
 {
     return p ? PacketRegistry<Registry>::key(p, nothrow) : optional_key_t();
 }
@@ -97,7 +97,7 @@ prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin<Self,void>:
 }
 
 template <class Self>
-prefix_ void senf::PacketTypeMixin<Self,void>::init(Packet p)
+prefix_ void senf::PacketTypeMixin<Self,void>::init(Packet const & p)
 {
     p.as< ConcretePacket<Self> >()->init();
 }
index e97380b..931ef4b 100644 (file)
@@ -312,7 +312,7 @@ namespace senf {
         typedef typename Registry::key_t key_t;
         typedef boost::optional<key_t> optional_key_t;
 
-        static optional_key_t key (Packet p); ///< Find key of packet from registry
+        static optional_key_t key (Packet const & p); ///< Find key of packet from registry
                                         /**< key() will query the registry to find the key of the
                                              given packet. Whereas \c nextPacketKey() as implemented
                                              by the mixin user will provide the registry key of the
@@ -333,10 +333,10 @@ namespace senf {
         ///\name PacketType interface implementation
         ///@{
 
-        static PacketInterpreterBase::optional_range nextPacketRange (Packet p);
-        static PacketInterpreterBase::factory_t      nextPacketType  (Packet p);
+        static PacketInterpreterBase::optional_range nextPacketRange (Packet const & p);
+        static PacketInterpreterBase::factory_t      nextPacketType  (Packet const & p);
         static PacketInterpreterBase::size_type      initSize        ();
-        static void                                  init            (Packet p);
+        static void                                  init            (Packet const & p);
         
         ///@}
     };
@@ -347,9 +347,9 @@ namespace senf {
     class PacketTypeMixin<Self,void>
     {
     public:
-        static PacketInterpreterBase::optional_range nextPacketRange (Packet p);
+        static PacketInterpreterBase::optional_range nextPacketRange (Packet const & p);
         static PacketInterpreterBase::size_type      initSize        ();
-        static void                                  init            (Packet p);
+        static void                                  init            (Packet const & p);
     };
 
 #   endif
index f6839be..3c7fd8e 100644 (file)
@@ -92,6 +92,22 @@ ConstVariableAttributor(QueryOverload & queryOverload)
     : queryOverload_ (queryOverload)
 {}
 
+template <class Variable>
+prefix_ senf::console::OverloadedCommandNode &
+senf::console::ConstVariableAttributor<Variable>::node()
+    const
+{
+    return queryOverload_.node();
+}
+
+template <class Variable>
+prefix_ senf::console::ConstVariableAttributor<Variable>::
+operator senf::console::OverloadedCommandNode &()
+    const
+{
+    return node();
+}
+
 ///////////////////////////////////////////////////////////////////////////
 // senf::console::VariableAttributor<Variable>
 
index 2ce1dd2..13fb787 100644 (file)
@@ -84,6 +84,9 @@ namespace console {
         ConstVariableAttributor doc(std::string const & doc);
         ConstVariableAttributor formatter(Formatter formatter);
 
+        OverloadedCommandNode & node() const; ///< Return the node object
+        operator OverloadedCommandNode & () const; ///< Automatically convert to node object
+
     protected:
         explicit ConstVariableAttributor(QueryOverload & queryOverload);
 
@@ -100,8 +103,8 @@ namespace console {
         variables type to set the variable and another one taking no arguments and just querying the
         current variable value.
         \code
-        int var;
-        ScopedDirectory<> dir;
+            int var;
+            ScopedDirectory<> dir;
 
         dir.add("var", var);
         \endcode
@@ -118,12 +121,12 @@ namespace console {
         boost::cref(). Such a variable cannot be changed only queried. Therefore, it does not have
         the parser() and typeName() attributes.
         \code
-        dir.add("const_var", boost::cref(var))
+            dir.add("const_var", boost::cref(var))
         \endcode
 
         \ingroup console_commands
      */
-   template <class Variable>
+    template <class Variable>
     class VariableAttributor
         : public ConstVariableAttributor<Variable>
     {
@@ -139,36 +142,36 @@ namespace console {
 
         VariableAttributor doc(std::string const & doc); ///< Set documentation of the variable
         VariableAttributor formatter(Formatter formatter); ///< Set formatter
-                                        /**< The \a formatter must be a callable with a signature
-                                             compatible with
-                                             \code
-                                             void formatter(Variable const & value, std::ostream & os);
-                                             \endcode
-                                             The \a formatter takes the return value of the call \a
-                                             value and writes it properly formated to \a os. */
+        /**< The \a formatter must be a callable with a signature
+             compatible with
+             \code
+                 void formatter(Variable const & value, std::ostream & os);
+             \endcode
+                 The \a formatter takes the return value of the call \a
+                 value and writes it properly formated to \a os. */
        
         VariableAttributor parser(Parser parser); ///< Set argument parser
-                                        /**< The parser is an arbitrary callable object with
-                                             the signature
-                                             \code
-                                                 void parser(senf::console::ParseCommandInfo::TokensRange const & tokens, value_type & out);
-                                             \endcode
-
-                                             where \c value_type is the type of the overload
-                                             parameter. The parser must read and parse the complete
-                                             \a tokens range and return the parsed value in \a
-                                             out. If the parser fails, it must raise a
-                                             senf::console::SyntaxErrorException. */
+        /**< The parser is an arbitrary callable object with
+             the signature
+             \code
+                 void parser(senf::console::ParseCommandInfo::TokensRange const & tokens, value_type & out);
+             \endcode
+
+             where \c value_type is the type of the overload
+             parameter. The parser must read and parse the complete
+             \a tokens range and return the parsed value in \a
+             out. If the parser fails, it must raise a
+             senf::console::SyntaxErrorException. */
         VariableAttributor typeName(std::string const & name); ///< Set name of the variable type
         VariableAttributor onChange(OnChangeHandler handler); ///< Set change callback
-                                        /**< The \a handler callback is called, whenever the value
-                                             of the variable is changed. The new value has already
-                                             been set, when the callback is called, the old value is
-                                             passed to the callback. The callback must have a
-                                             signature compatible to
-                                             \code
-                                             void handler(Variable const & oldValue);
-                                             \endcode */
+        /**< The \a handler callback is called, whenever the value
+             of the variable is changed. The new value has already
+             been set, when the callback is called, the old value is
+             passed to the callback. The callback must have a
+             signature compatible to
+             \code
+                 void handler(Variable const & oldValue);
+             \endcode */
  
     protected:
 
index 9bc58cd..bd3954a 100644 (file)
@@ -79,11 +79,11 @@ BOOST_AUTO_UNIT_TEST(variables)
                       "\n"
                       "Current blorg limit\n");
 
-    dir.add("refvar", boost::ref(var))
+    senf::console::CommandNode & refvar (dir.add("refvar", boost::ref(var))
         .doc("Current blorg limit")
         .formatter(&testFormatter)
         .parser(&testParser)
-        .typeName("number");
+        .typeName("number"));
 
     dir.add("crefvar", boost::cref(var))
         .doc("Current blorg limit")