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

TLV parser registration facility. More...

#include <senf/Packets/GenericTLV.hh>

Inheritance diagram for senf::GenericTLVParserRegistry< BaseParser, Keytype >:

Classes

struct  RegistrationProxy
 

Public Types

typedef GenericTLVParserBase< BaseParser > GenericTLVParser
 
typedef Map::const_iterator const_iterator
 

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
 
const_iterator begin () const
 
const_iterator end () const
 

Additional Inherited Members

- Protected Member Functions inherited from senf::singleton< GenericTLVParserRegistry< BaseParser, Keytype > >
 singleton ()
 
 ~singleton ()
 
- Static Protected Member Functions inherited from senf::singleton< GenericTLVParserRegistry< BaseParser, Keytype > >
static Self & instance ()
 
static bool alive ()
 

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
        GenericTLVParserBase for the general TLV class structure \n
        IPv6OptionParser::Registry, WLANInfoElementParser::Registry,
        MIHBaseTLVParser::Registry

Definition at line 227 of file GenericTLV.hh.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 259 of file GenericTLV.hh.

◆ GenericTLVParser

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

Definition at line 248 of file GenericTLV.hh.

Member Function Documentation

◆ begin()

template<class BaseParser , class Keytype = typename BaseParser::type_t::value_type>
const_iterator senf::GenericTLVParserRegistry< BaseParser, Keytype >::begin ( ) const

◆ bytes() [1/2]

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

◆ bytes() [2/2]

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

◆ dump() [1/2]

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

◆ dump() [2/2]

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

◆ end()

template<class BaseParser , class Keytype = typename BaseParser::type_t::value_type>
const_iterator senf::GenericTLVParserRegistry< BaseParser, Keytype >::end ( ) const

◆ isRegistered() [1/2]

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

◆ isRegistered() [2/2]

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

◆ registerParser()

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

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