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.
{
...
typedef GenericTLVParserRegistry<MyTLVParserBase> Registry;
};
struct MyConcreteTLVParser : public MyTLVParserBase
{
....
static const type_t::value_type typeId = 0x42;
void dump(std::ostream & os)
const;
};
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.