// $Id$
//
-// Copyright (C) 2006
+// Copyright (C) 2006
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// TODO: Add parameterless create() method
#ifndef HH_PacketRegistryImpl_
#define HH_PacketRegistryImpl_ 1
//#include "PacketRegistry.mpp"
///////////////////////////////hh.p////////////////////////////////////////
-namespace satcom {
-namespace pkf {
+namespace senf {
+
namespace impl { template <class key> class PacketRegistryImpl; }
The PacketRegistry provides a generic facility to associate an
arbitrary key with Packets. Example keys are Ethertype or IP
protocols.
-
+
Every PacketRegistry is identified by a type tag:
\code
struct SomeTag {
Normally, packet classes are registered statically and not
procedurally. To this end, the RegistrationProxy is provided:
\code
- PacketRegistry<SomeTag>::RegistrationProxy<SomePacket>
+ PacketRegistry<SomeTag>::RegistrationProxy<SomePacket>
registerSomePacket (key_of_somePacket);
\endcode
This global variable declaration will register \c SomePacket
constructor during global construction time.
The PacketRegistry's purpose is mostly to assist in
- implementing the \v v_nextInterpreter() member of packet
+ implementing the v_nextInterpreter() member of packet
facades. This is further supported by the PacketRegistryMixin
class.
+
+ \todo Add parameterless create() method
*/
template <class Tag>
class PacketRegistry
{
public:
- // TODO: This fails to work within a library since the linker will
- // remove all unused object files ...
/** \brief Statically register a packet type in a PacketRegistry
+
+ \fixme This fails to work within a library since the linker will
+ remove all unused object files ...
*/
template <class OtherPacket>
struct RegistrationProxy
{
RegistrationProxy(typename Tag::key_t key);
};
-
+
/** \brief Register new packet type
-
+
Register \c OtherPacket in the packet registry \c Tag
under the given \c key.
static void registerPacket(typename Tag::key_t key);
/** \brief Find key of a packet
-
+
Return the key of \c OtherPacket as registered in the \c
Tag registry
*/
template <class InputIterator>
static Packet::ptr create(typename Tag::key_t key, InputIterator b, InputIterator e);
-
+
private:
typedef impl::PacketRegistryImpl<typename Tag::key_t> Registry;
static Registry & registry();
-
+
template <class T, class D> friend class PacketRegistryMixin;
};
This mixin class provides a new registerInterpreter
implementation which can be used besides the methods provided
- bei satcom::pkf::Packet to add a new interpreter to the
+ bei senf::Packet to add a new interpreter to the
interpreter chain.
\code
{
protected:
/** \brief add interpreter to interpreter chain
-
+
This method is used by v_nextInterpreter() to add a new
interpreter to the interpreter chain (see the Packet
reference for more). Instead of specifying the type of
packet to use as a template argument it is specified using
the \c key value from the \c Tag registry
*/
- void registerInterpreter(typename Tag::key_t key,
+ void registerInterpreter(typename Tag::key_t key,
Packet::iterator b, Packet::iterator e) const;
};
struct PacketTypeNotRegistered : public std::exception
{ virtual char const * what() const throw() { return "packet type not registered"; } };
-}}
+}
///////////////////////////////hh.e////////////////////////////////////////
//#include "PacketRegistry.cci"
\f
// Local Variables:
// mode: c++
-// c-file-style: "satcom"
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
// End: