#include <senf/Packets/GenericTLV.hh>
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;
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.
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 |
typedef GenericTLVParserBase<BaseParser> senf::GenericTLVParserRegistry< BaseParser, Keytype >:: | ||||
GenericTLVParser | ||||
Definition at line 279 of file GenericTLV.hh.
senf::PacketParserBase::size_type senf::GenericTLVParserRegistry< BaseParser, Keytype >:: | ||||
bytes | ( | GenericTLVParser const & | parser, | |
Keytype const & | key | ) | ||
Definition at line 146 of file GenericTLV.ct.
senf::PacketParserBase::size_type senf::GenericTLVParserRegistry< BaseParser, Keytype >:: | ||||
bytes | ( | GenericTLVParser const & | parser | ) |
Definition at line 134 of file GenericTLV.ct.
void senf::GenericTLVParserRegistry< BaseParser, Keytype >:: | ||||
dump | ( | GenericTLVParser const & | parser, | |
Keytype const & | key, | |||
std::ostream & | os | ) | ||
Definition at line 124 of file GenericTLV.ct.
void senf::GenericTLVParserRegistry< BaseParser, Keytype >:: | ||||
dump | ( | GenericTLVParser const & | parser, | |
std::ostream & | os | ) | ||
Definition at line 114 of file GenericTLV.ct.
bool senf::GenericTLVParserRegistry< BaseParser, Keytype >:: | ||||
isRegistered | ( | Keytype const & | key | ) |
Definition at line 148 of file GenericTLV.cti.
bool senf::GenericTLVParserRegistry< BaseParser, Keytype >:: | ||||
isRegistered | ( | GenericTLVParserBase< BaseParser > const & | parser | ) |
void senf::GenericTLVParserRegistry< BaseParser, Keytype >:: | ||||
registerParser | () | |||
Definition at line 97 of file GenericTLV.ct.