10 #ifndef mm_messages_REGISTRY_HPP_ 11 #define mm_messages_REGISTRY_HPP_ 41 template<
int ID,
typename T>
42 static bool add(
const std::string &description=
"") {
43 if (
ids().insert( std::pair<int, std::string>(ID, description)).second) {
45 #ifdef MM_DEBUG_REGISTRY 46 std::cout <<
"Registering message packet.............[" << ID <<
" : '" << description <<
"']" << std::endl;
50 #ifdef MM_DEBUG_REGISTRY 51 std::cout <<
"Registering message packet failed......[" << ID <<
" : '" << description <<
"']" << std::endl;
57 return (
ids().find(
id) !=
ids().end());
62 return (ids_by_type<T>().find(
id) != ids_by_type<T>().end());
68 ids_by_type<T>().insert(
id);
76 static std::set<int>
ids;
79 static std::map<int, std::string>&
ids() {
80 static std::map<int, std::string> complete_id_set;
81 return complete_id_set;
96 template<
int ID,
typename T>
99 bool result = MessageRegistry::add<ID, T>(description);
101 std::stringstream ss;
102 ss <<
"registry already holds id '" << ID <<
"' (our packet desc: '" << description <<
"')" << std::endl;
125 #define MM_REGISTER_IMP_2(uuid) unused_packet_info_##uuid 126 #define MM_REGISTER_IMP_1(id, T, Description, uuid) \ 127 namespace mm_messages_registry_entries { \ 128 const mm_messages::RegistryEntry<id, T> MM_REGISTER_IMP_2(uuid)(Description); \ 130 #define MM_REGISTER_PACKET_INFO(id, T, Description) MM_REGISTER_IMP_1(id, T, Description, __COUNTER__) static std::map< int, std::string > & ids()
Short description of this file.
Short description of this file.
static bool isRegistered(const int &id)
Library instantiable variable for registration purposes.
static std::set< int > & ids_by_type()
static bool isRegisteredWithType(const int &id)
static void add_by_type(const int &id)
static bool add(const std::string &description="")
RegistryEntry(const std::string &description="")