Packets: optimized intrusive_ptr access; optimized PacketTypeMixin member parameters
tho [Tue, 3 Aug 2010 10:40:43 +0000 (10:40 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1657 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/Packet.cci
senf/Packets/Packet.cti
senf/Packets/Packet.hh
senf/Packets/PacketParser.hh
senf/Packets/PacketType.ct
senf/Packets/PacketType.cti
senf/Packets/PacketType.hh

index 9773af8..54b65f1 100644 (file)
 
 // protected members
 
-prefix_  senf::Packet::Packet(PacketInterpreterBase::ptr packet)
+prefix_  senf::Packet::Packet(PacketInterpreterBase::ptr const & packet)
     : packet_(packet)
 {}
 
-prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr()
+prefix_ senf::PacketInterpreterBase::ptr const & senf::Packet::ptr()
     const
 {
     SENF_ASSERT(packet_, "Invalid operation (dereferencing) on in-valid() Packet");
index 9ba8a4b..ecb8baa 100644 (file)
@@ -37,7 +37,7 @@
 // conversion constructors
 
 template <class PacketType>
-prefix_ senf::Packet::Packet(ConcretePacket<PacketType> packet)
+prefix_ senf::Packet::Packet(ConcretePacket<PacketType> const & packet)
     : packet_(packet.ptr())
 {}
 
@@ -312,7 +312,7 @@ senf::ConcretePacket<PacketType>::operator->()
 // private members
 
 template <class PacketType>
-prefix_ senf::ConcretePacket<PacketType>::ConcretePacket(typename interpreter::ptr packet_)
+prefix_ senf::ConcretePacket<PacketType>::ConcretePacket(typename interpreter::ptr const & packet_)
     : Packet(packet_)
 {}
 
index db53195..25d0f56 100644 (file)
@@ -171,7 +171,8 @@ namespace senf {
         // conversion constructors
 
         template <class PacketType>
-        Packet(ConcretePacket<PacketType> packet); ///< Copy-construct Packet from ConcretePacket
+        Packet(ConcretePacket<PacketType> const & packet);
+                                        ///< Copy-construct Packet from ConcretePacket
                                         /**< This constructor allows to convert an arbitrary
                                              ConcretePacket into a general Packet, loosing the
                                              protocol specific interface. */
@@ -489,9 +490,9 @@ namespace senf {
         ///@}
 
     protected:
-        explicit Packet(PacketInterpreterBase::ptr packet);
+        explicit Packet(PacketInterpreterBase::ptr const & packet);
 
-        PacketInterpreterBase::ptr ptr() const;
+        PacketInterpreterBase::ptr const & ptr() const;
 
     private:
         Packet checkNext() const;
@@ -752,7 +753,7 @@ namespace senf {
     private:
         typedef PacketInterpreter<PacketType> interpreter;
 
-        ConcretePacket(typename interpreter::ptr packet_);
+        ConcretePacket(typename interpreter::ptr const & packet_);
 
         typename interpreter::ptr ptr() const;
 
index 93311c0..56b20d9 100644 (file)
@@ -296,7 +296,7 @@ namespace senf {
             senf::safe_data_iterator safe_i_;
             mutable PacketParserBase const * parser_;
 
-            ParserProtector( PacketParserBase const * parser);
+            ParserProtector(PacketParserBase const * parser);
             ParserProtector(ParserProtector const & other_);
             ~ParserProtector();
         };
index 2358810..ab69324 100644 (file)
 
 template <class Self>
 prefix_ senf::PacketInterpreterBase::optional_range
-senf::PacketTypeMixin<Self,void>::nextPacketRange(Packet const & p)
+senf::PacketTypeMixin<Self,void>::nextPacketRange(ConcretePacket<Self> const & p)
 {
     typename Self::size_type sz (Self::initHeadSize());
     ///\idea This if condition could be replaced with a compile time switch by checking, wether
     /// (the function address) Self::initHeadSize is different from PacketTypeBase::initHeadSize
     if (sz == PacketTypeBase::size_type(-1)) {
-        typename Self::size_type headsz (bytes(p.as< ConcretePacket<Self> >().parser()));
+        typename Self::size_type headsz (bytes(p.parser()));
         return p.data().size() < headsz ?
             PacketTypeBase::no_range() :
             PacketInterpreterBase::optional_range(
index fe4bdce..4caed76 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 const & p)
+senf::PacketTypeMixin<Self,Registry>::nextPacketRange(ConcretePacket<Self> const & p)
 {
     // Call the member defined in the specialization below
     return PacketTypeMixin<Self>::nextPacketRange(p);
@@ -54,11 +54,11 @@ senf::PacketTypeMixin<Self,Registry>::nextPacketRange(Packet const & p)
 
 template <class Self, class Registry>
 prefix_ senf::PacketInterpreterBase::factory_t
-senf::PacketTypeMixin<Self,Registry>::nextPacketType(Packet const & p)
+senf::PacketTypeMixin<Self,Registry>::nextPacketType(ConcretePacket<Self> const & p)
 {
     if (p.data().size() < Self::initSize())
         return Self::no_factory();
-    return lookup( Self::nextPacketKey(p.as< ConcretePacket<Self> >()) );
+    return lookup( Self::nextPacketKey(p) );
 }
 
 template <class Self, class Registry>
@@ -68,9 +68,9 @@ prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin<Self,Regist
 }
 
 template <class Self, class Registry>
-prefix_ void senf::PacketTypeMixin<Self,Registry>::init(Packet const & p)
+prefix_ void senf::PacketTypeMixin<Self,Registry>::init(ConcretePacket<Self> const & p)
 {
-    p.as< ConcretePacket<Self> >()->init();
+    p->init();
 }
 
 template <class Self, class Registry>
@@ -98,9 +98,9 @@ prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin<Self,void>:
 }
 
 template <class Self>
-prefix_ void senf::PacketTypeMixin<Self,void>::init(Packet const & p)
+prefix_ void senf::PacketTypeMixin<Self,void>::init(ConcretePacket<Self> const & p)
 {
-    p.as< ConcretePacket<Self> >()->init();
+    p->init();
 }
 
 ///////////////////////////////cti.e///////////////////////////////////////
index c6b4cfc..2c6fd01 100644 (file)
@@ -333,10 +333,10 @@ namespace senf {
         ///\name PacketType interface implementation
         ///@{
 
-        static PacketInterpreterBase::optional_range nextPacketRange (Packet const & p);
-        static PacketInterpreterBase::factory_t      nextPacketType  (Packet const & p);
+        static PacketInterpreterBase::optional_range nextPacketRange (ConcretePacket<Self> const & p);
+        static PacketInterpreterBase::factory_t      nextPacketType  (ConcretePacket<Self> const & p);
         static PacketInterpreterBase::size_type      initSize        ();
-        static void                                  init            (Packet const & p);
+        static void                                  init            (ConcretePacket<Self> const & p);
 
         ///@}
     };
@@ -347,9 +347,9 @@ namespace senf {
     class PacketTypeMixin<Self,void>
     {
     public:
-        static PacketInterpreterBase::optional_range nextPacketRange (Packet const & p);
+        static PacketInterpreterBase::optional_range nextPacketRange (ConcretePacket<Self> const & p);
         static PacketInterpreterBase::size_type      initSize        ();
-        static void                                  init            (Packet const & p);
+        static void                                  init            (ConcretePacket<Self> const & p);
     };
 
 #   endif