Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Packets / PacketInterpreter.cc
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief PacketInterpreter non-inline non-template implementation */
25
26 //#include "PacketInterpreter.ih"
27
28 // Custom includes
29 #include "Packets.hh"
30
31 //#include "PacketInterpreter.mpp"
32 #define prefix_
33 //-/////////////////////////////////////////////////////////////////////////////////////////////////
34
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36 // senf::PacketInterpreterBase
37
38 // structors and default members
39
40 prefix_  senf::PacketInterpreterBase::~PacketInterpreterBase()
41 {}
42
43 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::clone()
44 {
45     detail::PacketImpl::Guard p (new detail::PacketImpl(begin(),end()));
46     ptr pi (appendClone(p.p,begin(),p.p->begin()));
47     for (ptr i (next()); i; i = i->next())
48         i->appendClone(p.p,begin(),p.p->begin());
49     pi->impl().assignAnnotations( impl());
50     return pi;
51 }
52
53 // Interpreter chain access
54
55 prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::append(ptr packet)
56 {
57     if (next())
58         impl().truncateInterpreters(next().get());
59
60     optional_range r (nextPacketRange());
61     if (!r)
62         throw InvalidPacketChainException();
63
64     ptr rv (packet->appendClone(&impl(), *r));
65     rv->data().resize(packet->data().size());
66     std::copy(packet->data().begin(), packet->data().end(), rv->data().begin());
67
68     for (ptr p (packet->next()) ; p ; p = p->next())
69         p->appendClone(&impl(), packet->data().begin(), rv->data().begin());
70
71     return rv;
72 }
73
74 prefix_ void senf::PacketInterpreterBase::reparse()
75 {
76     if (next())
77         impl().truncateInterpreters(next().get());
78 }
79
80 // Access to the abstract interface
81
82 prefix_ void senf::PacketInterpreterBase::dump(std::ostream & os)
83 {
84     try {
85         if (detail::AnnotationRegistry::instance().begin()
86             != detail::AnnotationRegistry::instance().end()) {
87             os << "Annotations:\n";
88             impl().dumpAnnotations(os);
89         }
90         v_dump(os);
91         for (ptr i (next()); i; i = i->next())
92             i->v_dump(os);
93     }
94     catch (senf::Exception & e) {
95         os << "[Exception: " << e.message() << "]\n";
96     }
97 }
98
99 prefix_ void senf::PacketInterpreterBase::finalizeThis()
100 {
101     v_finalize();
102 }
103
104 prefix_ void senf::PacketInterpreterBase::finalizeTo(ptr other)
105 {
106     for (ptr i (other); i.get() != this && i.get(); i = i->prev())
107         i->finalizeThis();
108     finalizeThis();
109 }
110
111 // reference/memory management
112
113 prefix_ void senf::PacketInterpreterBase::add_ref()
114 {
115     if (impl_ && !refcount())
116         impl_->add_ref();
117     intrusive_refcount_t<PacketInterpreterBase>::add_ref();
118 }
119
120 prefix_ void senf::PacketInterpreterBase::release()
121 {
122     if (impl_ && refcount()==1)
123         // This call will set impl_ to 0 if we just removed the last reference ...
124         impl_->release();
125     if (intrusive_refcount_t<PacketInterpreterBase>::release() && !impl_)
126         delete this;
127 }
128
129 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130 // senf::PacketInterpreterBase::Factory
131
132 prefix_  senf::PacketInterpreterBase::Factory::~Factory()
133 {}
134
135 //-/////////////////////////////////////////////////////////////////////////////////////////////////
136 #undef prefix_
137 //#include "PacketInterpreter.mpp"
138
139 \f
140 // Local Variables:
141 // mode: c++
142 // fill-column: 100
143 // c-file-style: "senf"
144 // indent-tabs-mode: nil
145 // ispell-local-dictionary: "american"
146 // compile-command: "scons -u test"
147 // comment-column: 40
148 // End: