Packets: internal Interpreter pointer enhancement (call by ref instead by value)
tho [Thu, 3 Nov 2011 14:48:03 +0000 (14:48 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1821 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/Packet.cci
senf/Packets/PacketImpl.hh
senf/Packets/PacketInterpreter.ct
senf/Packets/PacketInterpreter.cti
senf/Packets/PacketInterpreter.hh

index f35c1c4..c988387 100644 (file)
@@ -203,12 +203,12 @@ prefix_ bool senf::Packet::is_shared()
 prefix_ void senf::Packet::reparse()
     const
 {
-    return ptr()->reparse();
+    ptr()->reparse();
 }
 
 prefix_ void senf::Packet::clearAnnotations()
 {
-    return ptr()->clearAnnotations();
+    ptr()->clearAnnotations();
 }
 
 template <class PacketType, class Parser>
index 7df4942..ad0b7e8 100644 (file)
@@ -185,7 +185,7 @@ namespace detail {
             \internal
 
             The Guard will keep the PacketImpl instance alive during a members execution time
-            It the refcount should drop to 0, PacketImpl will be deleted after the member
+            If the refcount should drop to 0, PacketImpl will be deleted after the member
             has completed executing.
          */
         struct Guard {
index e733736..1225872 100644 (file)
@@ -78,15 +78,14 @@ prefix_ typename senf::PacketInterpreter<PacketType>::ptr
 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));
-    return pi;
+    return create(p.p,p.p->begin(),p.p->end(),Append);
 }
 
 // Create packet as new packet after a given packet
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr packet,
+senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr const & packet,
                                                  size_type size)
 {
     if (size < initSize())
@@ -99,7 +98,7 @@ senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr pack
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr packet,
+senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr const & packet,
                                                  size_type size, senf::NoInit_t)
 {
     optional_range r (packet->nextPacketRange());
@@ -117,7 +116,7 @@ senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr pack
 template <class PacketType>
 template <class ForwardReadableRange>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr packet,
+senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr const & packet,
                                                  ForwardReadableRange const & range)
 {
     optional_range r (packet->nextPacketRange());
@@ -137,7 +136,7 @@ senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr pack
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr packet)
+senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr const & packet)
 {
     ptr pi (createBefore(packet, senf::noinit));
     pi->data().insert(pi->data().begin(),initHeadSize(),byte(0x00u));
@@ -148,7 +147,7 @@ senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr pac
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t)
+senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t)
 {
     if (packet->prev())
         packet->impl().truncateInterpretersBackwards(packet->prev().get());
@@ -158,7 +157,7 @@ senf::PacketInterpreter<PacketType>::createBefore(PacketInterpreterBase::ptr pac
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createInsertBefore(PacketInterpreterBase::ptr packet)
+senf::PacketInterpreter<PacketType>::createInsertBefore(PacketInterpreterBase::ptr const & packet)
 {
     ptr pi (createInsertBefore(packet, senf::noinit));
     pi->data().insert(pi->data().begin(),initHeadSize(),byte(0x00u));
@@ -169,7 +168,7 @@ senf::PacketInterpreter<PacketType>::createInsertBefore(PacketInterpreterBase::p
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createInsertBefore(PacketInterpreterBase::ptr packet,
+senf::PacketInterpreter<PacketType>::createInsertBefore(PacketInterpreterBase::ptr const & packet,
                                                         senf::NoInit_t)
 {
     return create(&packet->impl(),packet->data().begin(),packet->data().end(),packet);
@@ -253,7 +252,7 @@ senf::PacketInterpreterBase::Factory::create(ForwardReadableRange const & range)
 
 template <class ForwardReadableRange>
 prefix_ senf::PacketInterpreterBase::ptr
-senf::PacketInterpreterBase::Factory::createAfter(PacketInterpreterBase::ptr packet,
+senf::PacketInterpreterBase::Factory::createAfter(PacketInterpreterBase::ptr const & packet,
                                                   ForwardReadableRange const & range)
     const
 {
@@ -303,7 +302,7 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::create(size_type size, senf::N
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreterBase::ptr
-senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet)
+senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr const & packet)
     const
 {
     return senf::PacketInterpreter<PacketType>::createAfter(packet);
@@ -311,7 +310,7 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterB
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreterBase::ptr
-senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet,
+senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr const & packet,
                                                               senf::NoInit_t)
     const
 {
@@ -320,7 +319,7 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterB
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreterBase::ptr
-senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet,
+senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr const & packet,
                                                               size_type size)
     const
 {
@@ -329,7 +328,7 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterB
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreterBase::ptr
-senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet,
+senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterBase::ptr const & packet,
                                                               size_type size, senf::NoInit_t)
     const
 {
@@ -341,7 +340,7 @@ senf::PacketInterpreter<PacketType>::FactoryImpl::createAfter(PacketInterpreterB
 template <class PacketType>
 prefix_ typename senf::PacketInterpreterBase::ptr
 senf::PacketInterpreter<PacketType>::FactoryImpl::
-createBefore(PacketInterpreterBase::ptr packet)
+createBefore(PacketInterpreterBase::ptr const & packet)
     const
 {
     return senf::PacketInterpreter<PacketType>::createBefore(packet);
@@ -350,7 +349,7 @@ createBefore(PacketInterpreterBase::ptr packet)
 template <class PacketType>
 prefix_ senf::PacketInterpreterBase::ptr
 senf::PacketInterpreter<PacketType>::FactoryImpl::
-createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t)
+createBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t)
     const
 {
     return senf::PacketInterpreter<PacketType>::createBefore(packet,senf::noinit);
@@ -359,7 +358,7 @@ createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t)
 template <class PacketType>
 prefix_ senf::PacketInterpreterBase::ptr
 senf::PacketInterpreter<PacketType>::FactoryImpl::
-createInsertBefore(PacketInterpreterBase::ptr packet)
+createInsertBefore(PacketInterpreterBase::ptr const & packet)
     const
 {
     return senf::PacketInterpreter<PacketType>::createInsertBefore(packet);
@@ -368,7 +367,7 @@ createInsertBefore(PacketInterpreterBase::ptr packet)
 template <class PacketType>
 prefix_ senf::PacketInterpreterBase::ptr
 senf::PacketInterpreter<PacketType>::FactoryImpl::
-createInsertBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t)
+createInsertBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t)
     const
 {
     return senf::PacketInterpreter<PacketType>::createInsertBefore(packet,senf::noinit);
@@ -378,7 +377,7 @@ createInsertBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t)
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreterBase::ptr
-senf::PacketInterpreter<PacketType>::FactoryImpl::parseNext(PacketInterpreterBase::ptr packet, PacketInterpreterBase::optional_range const & range)
+senf::PacketInterpreter<PacketType>::FactoryImpl::parseNext(PacketInterpreterBase::ptr const & packet, PacketInterpreterBase::optional_range const & range)
     const
 {
     if (!range)
index 469d617..bafdf9e 100644 (file)
@@ -103,14 +103,14 @@ senf::PacketInterpreter<PacketType>::create(ForwardReadableRange const & range)
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr packet)
+senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr const & packet)
 {
     return createAfter(packet, initSize());
 }
 
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
-senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr packet, senf::NoInit_t)
+senf::PacketInterpreter<PacketType>::createAfter(PacketInterpreterBase::ptr const & packet, senf::NoInit_t)
 {
     return createAfter(packet, 0, senf::noinit);
 }
@@ -157,7 +157,7 @@ senf::PacketInterpreter<PacketType>::create(detail::PacketImpl * impl, iterator
 template <class PacketType>
 prefix_ typename senf::PacketInterpreter<PacketType>::ptr
 senf::PacketInterpreter<PacketType>::create(detail::PacketImpl * impl, iterator b, iterator e,
-                                            PacketInterpreterBase::ptr before)
+                                            PacketInterpreterBase::ptr const & before)
 {
     return ptr(new PacketInterpreter(impl,b,e,before));
 }
@@ -178,7 +178,7 @@ template <class PacketType>
 prefix_
 senf::PacketInterpreter<PacketType>::PacketInterpreter(detail::PacketImpl * impl, iterator b,
                                                        iterator e,
-                                                       PacketInterpreterBase::ptr before)
+                                                       PacketInterpreterBase::ptr const & before)
     : PacketInterpreterBase(impl,b,e,before)
 {}
 
index cc49812..953c187 100644 (file)
@@ -102,26 +102,26 @@ namespace senf {
 
             // Create packet as new packet after a given packet
 
-            virtual ptr createAfter(PacketInterpreterBase::ptr packet) 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,
+            virtual ptr createAfter(PacketInterpreterBase::ptr const & packet) const = 0;
+            virtual ptr createAfter(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) const = 0;
+            virtual ptr createAfter(PacketInterpreterBase::ptr const & packet, size_type size) const = 0;
+            virtual ptr createAfter(PacketInterpreterBase::ptr const & packet, size_type size,
                                     senf::NoInit_t) const = 0;
             template <class ForwardReadableRange>
-            ptr createAfter(PacketInterpreterBase::ptr packet,
+            ptr createAfter(PacketInterpreterBase::ptr const & packet,
                             ForwardReadableRange const & range) const;
 
             // Create packet as new packet (header) const before a given packet
 
-            virtual ptr createBefore(PacketInterpreterBase::ptr packet) const = 0;
-            virtual ptr createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t) const = 0;
+            virtual ptr createBefore(PacketInterpreterBase::ptr const & packet) const = 0;
+            virtual ptr createBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) const = 0;
 
-            virtual ptr createInsertBefore(PacketInterpreterBase::ptr packet) const = 0;
-            virtual ptr createInsertBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t) const = 0;
+            virtual ptr createInsertBefore(PacketInterpreterBase::ptr const & packet) const = 0;
+            virtual ptr createInsertBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) const = 0;
 
             // Parse next packet in chain
 
-            virtual ptr parseNext(ptr packet, PacketInterpreterBase::optional_range const & range) const = 0;
+            virtual ptr parseNext(ptr const & packet, PacketInterpreterBase::optional_range const & range) const = 0;
         };
 
         typedef Factory const * factory_t;
@@ -136,7 +136,7 @@ namespace senf {
 
         virtual ~PacketInterpreterBase();
 
-        static                             factory_t no_factory();
+        static factory_t no_factory();
 
         ptr clone();
 
@@ -288,21 +288,21 @@ namespace senf {
 
         // Create packet as new packet after a given packet
 
-        static ptr createAfter(PacketInterpreterBase::ptr packet);
-        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, senf::NoInit_t);
+        static ptr createAfter(PacketInterpreterBase::ptr const & packet);
+        static ptr createAfter(PacketInterpreterBase::ptr const & packet, senf::NoInit_t);
+        static ptr createAfter(PacketInterpreterBase::ptr const & packet, size_type size);
+        static ptr createAfter(PacketInterpreterBase::ptr const & packet, size_type size, senf::NoInit_t);
         template <class ForwardReadableRange>
-        static ptr createAfter(PacketInterpreterBase::ptr packet,
+        static ptr createAfter(PacketInterpreterBase::ptr const & packet,
                                ForwardReadableRange const & range);
 
         // Create packet as new packet (header) before a given packet
 
-        static ptr createBefore(PacketInterpreterBase::ptr packet);
-        static ptr createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t);
+        static ptr createBefore(PacketInterpreterBase::ptr const & spacket);
+        static ptr createBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t);
 
-        static ptr createInsertBefore(PacketInterpreterBase::ptr packet);
-        static ptr createInsertBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t);
+        static ptr createInsertBefore(PacketInterpreterBase::ptr const & packet);
+        static ptr createInsertBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t);
 
         // Create a clone of the current packet
 
@@ -328,12 +328,12 @@ namespace senf {
         PacketInterpreter(detail::PacketImpl * impl, iterator b, iterator e, Append_t);
         PacketInterpreter(detail::PacketImpl * impl, iterator b, iterator e, Prepend_t);
         PacketInterpreter(detail::PacketImpl * impl, iterator b, iterator e,
-                          PacketInterpreterBase::ptr before);
+                          PacketInterpreterBase::ptr const & before);
 
         static ptr create(detail::PacketImpl * impl, iterator b, iterator e, Append_t);
         static ptr create(detail::PacketImpl * impl, iterator b, iterator e, Prepend_t);
         static ptr create(detail::PacketImpl * impl, iterator b, iterator e,
-                          PacketInterpreterBase::ptr before);
+                          PacketInterpreterBase::ptr const & before);
 
         // PacketType access
 
@@ -371,32 +371,32 @@ namespace senf {
 
             // Create packet as new packet after a given packet
 
-            virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr packet)
+            virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr const & packet)
                 const;
-            virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr packet,
+            virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr const & packet,
                                                            senf::NoInit_t) const;
-            virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr packet,
+            virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr const & packet,
                                                            size_type size) const;
-            virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr packet,
+            virtual PacketInterpreterBase::ptr createAfter(PacketInterpreterBase::ptr const & packet,
                                                            size_type size, senf::NoInit_t) const;
 
             // Create packet as new packet (header) before a given packet
 
-            virtual PacketInterpreterBase::ptr createBefore(PacketInterpreterBase::ptr packet)
+            virtual PacketInterpreterBase::ptr createBefore(PacketInterpreterBase::ptr const & packet)
                 const;
-            virtual PacketInterpreterBase::ptr createBefore(PacketInterpreterBase::ptr packet,
+            virtual PacketInterpreterBase::ptr createBefore(PacketInterpreterBase::ptr const & packet,
                                                             senf::NoInit_t)
                 const;
 
-            virtual PacketInterpreterBase::ptr createInsertBefore(PacketInterpreterBase::ptr packet)
+            virtual PacketInterpreterBase::ptr createInsertBefore(PacketInterpreterBase::ptr const & packet)
                 const;
-            virtual PacketInterpreterBase::ptr createInsertBefore(PacketInterpreterBase::ptr packet,
+            virtual PacketInterpreterBase::ptr createInsertBefore(PacketInterpreterBase::ptr const & packet,
                                                                   senf::NoInit_t)
                 const;
 
             // Parse next packet in chain
 
-            virtual PacketInterpreterBase::ptr parseNext(PacketInterpreterBase::ptr packet, PacketInterpreterBase::optional_range const & range)
+            virtual PacketInterpreterBase::ptr parseNext(PacketInterpreterBase::ptr const & packet, PacketInterpreterBase::optional_range const & range)
                 const;
         };