// $Id$ // // Copyright (C) 2007 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file \brief Packet inline non-template implementation */ // Custom includes #include #define prefix_ inline //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::Packet // protected members prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr const & packet) : packet_(packet) {} prefix_ senf::PacketInterpreterBase::ptr const & senf::Packet::ptr() const { SENF_ASSERT(packet_, "Invalid operation (dereferencing) on in-valid() Packet"); return packet_; } // public structors prefix_ senf::Packet::Packet() {} // public members prefix_ senf::Packet senf::Packet::clone() const { return Packet(ptr()->clone()); } // Interpreter chain access prefix_ senf::Packet senf::Packet::next(NoThrow_t) const { PacketInterpreterBase::ptr p (ptr()->next()); if (p) return Packet(p); PacketInterpreterBase::optional_range r (ptr()->nextPacketRange()); return (r && ! r->empty()) ? getNext() : Packet(); } prefix_ senf::Packet senf::Packet::next() const { Packet p (next(nothrow)); if (!p) throw InvalidPacketChainException(); return p; } prefix_ senf::Packet senf::Packet::prev(NoThrow_t) const { return Packet(ptr()->prev()); } prefix_ senf::Packet senf::Packet::prev() const { Packet p (prev(nothrow)); if (!p) throw InvalidPacketChainException(); return p; } prefix_ senf::Packet senf::Packet::first() const { return Packet(ptr()->first()); } prefix_ senf::Packet senf::Packet::last() const { Packet p (ptr()->last()); return p.next(nothrow) ? getLast() : p; } prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory) const { return Packet(ptr()->parseNextAs(factory)); } prefix_ senf::Packet senf::Packet::append(Packet const & packet) const { return Packet(ptr()->append(packet.ptr())); } // Data access prefix_ senf::PacketData & senf::Packet::data() const { return ptr()->data(); } prefix_ senf::Packet::size_type senf::Packet::size() const { return data().size(); } // Other methods prefix_ bool senf::Packet::operator==(Packet const & other) const { return ptr() == other.ptr(); } prefix_ void senf::Packet::finalizeThis() { ptr()->finalizeThis(); } prefix_ void senf::Packet::finalizeTo(Packet const & other) { ptr()->finalizeTo(other.ptr()); } prefix_ void senf::Packet::finalizeAll() { ptr()->finalizeTo(last().ptr()); } prefix_ void senf::Packet::dump(std::ostream & os) const { last(); // Make sure the packet is complete ptr()->dump(os); } prefix_ senf::TypeIdValue senf::Packet::typeId() const { return ptr()->typeId(); } prefix_ senf::Packet::factory_t senf::Packet::factory() const { return ptr()->factory(); } prefix_ unsigned long senf::Packet::id() const { return reinterpret_cast(&ptr()->impl()); } prefix_ bool senf::Packet::boolean_test() const { return packet_ && packet_->valid(); } prefix_ bool senf::Packet::valid() const { return *this; } prefix_ bool senf::Packet::is_shared() const { return ptr()->is_shared() || (ptr()->impl().refcount() > 1); } prefix_ void senf::Packet::reparse() const { return ptr()->reparse(); } prefix_ void senf::Packet::clearAnnotations() { return ptr()->clearAnnotations(); } template prefix_ Parser senf::operator<<(Parser target, ConcretePacket const & packet) { target << packet.parser(); return target; } //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // comment-column: 40 // End: