From: tho Date: Thu, 3 Nov 2011 14:48:03 +0000 (+0000) Subject: Packets: internal Interpreter pointer enhancement (call by ref instead by value) X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=3b799c202bbbbcf8a43649e91b022b8c69e6a9f8;p=senf.git Packets: internal Interpreter pointer enhancement (call by ref instead by value) git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1821 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/Packet.cci b/senf/Packets/Packet.cci index f35c1c4..c988387 100644 --- a/senf/Packets/Packet.cci +++ b/senf/Packets/Packet.cci @@ -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 diff --git a/senf/Packets/PacketImpl.hh b/senf/Packets/PacketImpl.hh index 7df4942..ad0b7e8 100644 --- a/senf/Packets/PacketImpl.hh +++ b/senf/Packets/PacketImpl.hh @@ -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 { diff --git a/senf/Packets/PacketInterpreter.ct b/senf/Packets/PacketInterpreter.ct index e733736..1225872 100644 --- a/senf/Packets/PacketInterpreter.ct +++ b/senf/Packets/PacketInterpreter.ct @@ -78,15 +78,14 @@ prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::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 prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr packet, +senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr const & packet, size_type size) { if (size < initSize()) @@ -99,7 +98,7 @@ senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr pack template prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr packet, +senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr const & packet, size_type size, senf::NoInit_t) { optional_range r (packet->nextPacketRange()); @@ -117,7 +116,7 @@ senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr pack template template prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr packet, +senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr const & packet, ForwardReadableRange const & range) { optional_range r (packet->nextPacketRange()); @@ -137,7 +136,7 @@ senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr pack template prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createBefore(PacketInterpreterBase::ptr packet) +senf::PacketInterpreter::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::createBefore(PacketInterpreterBase::ptr pac template prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t) +senf::PacketInterpreter::createBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) { if (packet->prev()) packet->impl().truncateInterpretersBackwards(packet->prev().get()); @@ -158,7 +157,7 @@ senf::PacketInterpreter::createBefore(PacketInterpreterBase::ptr pac template prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createInsertBefore(PacketInterpreterBase::ptr packet) +senf::PacketInterpreter::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::createInsertBefore(PacketInterpreterBase::p template prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createInsertBefore(PacketInterpreterBase::ptr packet, +senf::PacketInterpreter::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 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::FactoryImpl::create(size_type size, senf::N template prefix_ typename senf::PacketInterpreterBase::ptr -senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet) +senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterBase::ptr const & packet) const { return senf::PacketInterpreter::createAfter(packet); @@ -311,7 +310,7 @@ senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterB template prefix_ typename senf::PacketInterpreterBase::ptr -senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet, +senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) const { @@ -320,7 +319,7 @@ senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterB template prefix_ typename senf::PacketInterpreterBase::ptr -senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet, +senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterBase::ptr const & packet, size_type size) const { @@ -329,7 +328,7 @@ senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterB template prefix_ typename senf::PacketInterpreterBase::ptr -senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterBase::ptr packet, +senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterBase::ptr const & packet, size_type size, senf::NoInit_t) const { @@ -341,7 +340,7 @@ senf::PacketInterpreter::FactoryImpl::createAfter(PacketInterpreterB template prefix_ typename senf::PacketInterpreterBase::ptr senf::PacketInterpreter::FactoryImpl:: -createBefore(PacketInterpreterBase::ptr packet) +createBefore(PacketInterpreterBase::ptr const & packet) const { return senf::PacketInterpreter::createBefore(packet); @@ -350,7 +349,7 @@ createBefore(PacketInterpreterBase::ptr packet) template prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreter::FactoryImpl:: -createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t) +createBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) const { return senf::PacketInterpreter::createBefore(packet,senf::noinit); @@ -359,7 +358,7 @@ createBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t) template prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreter::FactoryImpl:: -createInsertBefore(PacketInterpreterBase::ptr packet) +createInsertBefore(PacketInterpreterBase::ptr const & packet) const { return senf::PacketInterpreter::createInsertBefore(packet); @@ -368,7 +367,7 @@ createInsertBefore(PacketInterpreterBase::ptr packet) template prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreter::FactoryImpl:: -createInsertBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t) +createInsertBefore(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) const { return senf::PacketInterpreter::createInsertBefore(packet,senf::noinit); @@ -378,7 +377,7 @@ createInsertBefore(PacketInterpreterBase::ptr packet, senf::NoInit_t) template prefix_ typename senf::PacketInterpreterBase::ptr -senf::PacketInterpreter::FactoryImpl::parseNext(PacketInterpreterBase::ptr packet, PacketInterpreterBase::optional_range const & range) +senf::PacketInterpreter::FactoryImpl::parseNext(PacketInterpreterBase::ptr const & packet, PacketInterpreterBase::optional_range const & range) const { if (!range) diff --git a/senf/Packets/PacketInterpreter.cti b/senf/Packets/PacketInterpreter.cti index 469d617..bafdf9e 100644 --- a/senf/Packets/PacketInterpreter.cti +++ b/senf/Packets/PacketInterpreter.cti @@ -103,14 +103,14 @@ senf::PacketInterpreter::create(ForwardReadableRange const & range) template prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr packet) +senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr const & packet) { return createAfter(packet, initSize()); } template prefix_ typename senf::PacketInterpreter::ptr -senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr packet, senf::NoInit_t) +senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) { return createAfter(packet, 0, senf::noinit); } @@ -157,7 +157,7 @@ senf::PacketInterpreter::create(detail::PacketImpl * impl, iterator template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::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 prefix_ senf::PacketInterpreter::PacketInterpreter(detail::PacketImpl * impl, iterator b, iterator e, - PacketInterpreterBase::ptr before) + PacketInterpreterBase::ptr const & before) : PacketInterpreterBase(impl,b,e,before) {} diff --git a/senf/Packets/PacketInterpreter.hh b/senf/Packets/PacketInterpreter.hh index cc49812..953c187 100644 --- a/senf/Packets/PacketInterpreter.hh +++ b/senf/Packets/PacketInterpreter.hh @@ -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 - 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 - 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; };