35 static std::atomic<int> cnt(0);
70 m_being_modified =
true;
72 std::unique_lock<std::mutex> lk(m_cs);
75 const auto it = registeredClasses.find(className);
76 if (it != registeredClasses.cend())
78 if (it->second != &
id)
81 "[MRPT class registry] Warning: overwriting already " 82 "registered className=`%s` with different " 83 "`TRuntimeClassId`!\n",
87 registeredClasses[className] = &
id;
89 m_being_modified =
false;
95 bool has_to_unlock =
false;
102 if (has_to_unlock) m_cs.unlock();
108 std::unique_lock<std::mutex> lk(m_cs);
110 std::vector<const TRuntimeClassId*> ret;
112 it != registeredClasses.end(); ++it)
113 ret.push_back(it->second);
146 if ((*ptrToPtr) !=
nullptr)
192 std::vector<const TRuntimeClassId*>
res;
194 for (
const auto&
c : lst)
196 if (
c->derivedFrom(parent_id) &&
c != parent_id)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
std::map< std::string, const TRuntimeClassId * > TClassnameToRuntimeId
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
static CClassRegistry & Instance()
The unique access point point to the singleton instance.
void registerAllPendingClasses()
Register all pending classes - to be called just before de-serializing an object, for example...
std::vector< const mrpt::utils::TRuntimeClassId * > getAllRegisteredClasses()
Returns a list with all the classes registered in the system through mrpt::utils::registerClass.
GLsizei GLsizei GLuint * obj
void(* TRegisterFunction)()
TClassnameToRuntimeId registeredClasses
const TRuntimeClassId * Get(const std::string &className)
A thread-safe template queue for object passing between threads; for a template argument of T...
GLsizei const GLchar ** string
const TRuntimeClassId * findRegisteredClass(const std::string &className)
Return info about a given class by its name, or nullptr if the class is not registered.
CThreadSafeQueue< TRegisterFunction > & pending_class_registers()
std::atomic< bool > m_being_modified
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
volatile bool pending_class_registers_modified
Set to true if pending_class_registers() has been called after registerAllPendingClasses().
A singleton with the central registry for CSerializable run-time classes: users do not use this class...
void Add(const std::string &className, const TRuntimeClassId &id)
void registerClass(const mrpt::utils::TRuntimeClassId *pNewClass)
Register a class into the MRPT internal list of "CSerializable" descendents.
std::vector< const TRuntimeClassId * > getListOfAllRegisteredClasses()
std::vector< const TRuntimeClassId * > getAllRegisteredClassesChildrenOf(const TRuntimeClassId *parent_id)
Like getAllRegisteredClasses(), but filters the list to only include children clases of a given base ...
A structure that holds runtime class type information.
void registerClassCustomName(const char *customName, const TRuntimeClassId *pNewClass)
Mostly for internal use within mrpt sources, to handle exceptional cases with multiple serialization ...
std::atomic< int > & pending_class_registers_count()