senf::GenericTLVParserRegistry< BaseParser, Keytype > Class Template Reference

TLV parser registration facility. More...

#include <senf/Packets/GenericTLV.hh>

Inheritance diagram for senf::GenericTLVParserRegistry< BaseParser, Keytype >:
Inheritance graph
[legend]

List of all members.


Detailed Description

template<class BaseParser, class Keytype = typename BaseParser::type_t::value_type>
class senf::GenericTLVParserRegistry< BaseParser, Keytype >

TLV parser registration facility.

The GenericTLVParserRegistry provides a generic facility to globally register concrete TLV parser by the type value. The concrete TLV parser must therefore provide a typeId member. See GenericTLVParserBase for details about the assumed class structure.

Every registry is identified by the base tlv parser class. Parsers can be registered statically only:

GenericTLVParserRegistry<MyTLVParserBase>::RegistrationProxy<ConcreteTLVParser>
    registerConcreteTLVParser;
This global variable declaration will register ConcreteTLVParser. The variable registerConcreteTLVParser is a dummy. It's only function is to force the call of it's constructor during global construction time. This static registration only works when the symbol is included into the final binary.

To simplify the registration the SENF_PACKET_TLV_REGISTRY_REGISTER macro can be used. The ConreteTLVParser must therefore provide a Registry typedef pointing to the GenericTLVParserRegistry; typically you put this typedef to the TLVBaseParser class.

struct MyTLVParserBase : public senf::PacketParserBase
{
    ...
    typedef GenericTLVParserRegistry<MyTLVParserBase> Registry;
};
struct MyConcreteTLVParser : public MyTLVParserBase
{
    ....
    static const type_t::value_type typeId = 0x42;
    void dump(std::ostream & os) const;
};

// register MyConcreteTLVParser to the MyTLVParserBase-Registry with the type id 0x42:
SENF_PACKET_TLV_REGISTRY_REGISTER( MyConcreteTLVParser );

The registry provides a dump() member to dump an instance of a generic TLV parser. If the type value of the given TLV parser is registered the generic tlv will be casted to the registered concrete TLV parser and the dump member from this parser will be called.

See also:
GenericTLVParserBase for the general TLV class structure
IPv6OptionParser::Registry, WLANInfoElementParser::Registry, MIHBaseTLVParser::Registry

Definition at line 259 of file GenericTLV.hh.


Classes

struct   RegistrationProxy

Public Types

typedef GenericTLVParserBase
< BaseParser > 
GenericTLVParser

Public Member Functions

template<typename Parser >
void  registerParser ()
bool  isRegistered (GenericTLVParserBase< BaseParser > const &parser) const
bool  isRegistered (Keytype const &key) const
void  dump (GenericTLVParser const &parser, std::ostream &os) const
void  dump (GenericTLVParser const &parser, Keytype const &key, std::ostream &os) const
PacketParserBase::size_type  bytes (GenericTLVParser const &parser) const
PacketParserBase::size_type  bytes (GenericTLVParser const &parser, Keytype const &key) const

Member Typedef Documentation

template<class BaseParser , class Keytype = typename BaseParser::type_t::value_type>
typedef GenericTLVParserBase<BaseParser> senf::GenericTLVParserRegistry< BaseParser, Keytype >::
GenericTLVParser

Definition at line 279 of file GenericTLV.hh.


Member Function Documentation

template<class BaseParser , class Keytype >
senf::PacketParserBase::size_type senf::GenericTLVParserRegistry< BaseParser, Keytype >::
bytes ( GenericTLVParser const &  parser,
Keytype const &  key )

Definition at line 146 of file GenericTLV.ct.

template<class BaseParser , class Keytype >
senf::PacketParserBase::size_type senf::GenericTLVParserRegistry< BaseParser, Keytype >::
bytes ( GenericTLVParser const &  parser )

Definition at line 134 of file GenericTLV.ct.

template<class BaseParser , class Keytype >
void senf::GenericTLVParserRegistry< BaseParser, Keytype >::
dump ( GenericTLVParser const &  parser,
Keytype const &  key,
std::ostream &  os )

Definition at line 124 of file GenericTLV.ct.

template<class BaseParser , class Keytype >
void senf::GenericTLVParserRegistry< BaseParser, Keytype >::
dump ( GenericTLVParser const &  parser,
std::ostream &  os )

Definition at line 114 of file GenericTLV.ct.

template<class BaseParser , class Keytype >
bool senf::GenericTLVParserRegistry< BaseParser, Keytype >::
isRegistered ( Keytype const &  key )

Definition at line 148 of file GenericTLV.cti.

template<class BaseParser , class Keytype = typename BaseParser::type_t::value_type>
bool senf::GenericTLVParserRegistry< BaseParser, Keytype >::
isRegistered ( GenericTLVParserBase< BaseParser > const &  parser )

template<class BaseParser , class Keytype >
template<typename Parser >
void senf::GenericTLVParserRegistry< BaseParser, Keytype >::
registerParser ()

Definition at line 97 of file GenericTLV.ct.


The documentation for this class was generated from the following files: