38 static std::atomic<int> cnt(0);
73 m_being_modified=
true;
75 std::unique_lock<std::mutex> lk(m_cs);
78 const auto it = registeredClasses.find(className);
79 if (it != registeredClasses.cend()) {
80 if (it->second != &
id) {
81 std::cerr <<
mrpt::format(
"[MRPT class registry] Warning: overwriting already registered className=`%s` with different `TRuntimeClassId`!\n", className.c_str());
84 registeredClasses[className] = &
id;
86 m_being_modified=
false;
92 bool has_to_unlock =
false;
99 if (has_to_unlock) m_cs.unlock();
105 std::unique_lock<std::mutex> lk(m_cs);
107 std::vector<const TRuntimeClassId*> ret;
109 ret.push_back( it->second );
146 if((*ptrToPtr)!=NULL)
190 std::vector<const TRuntimeClassId*>
res;
192 for (
const auto &
c : lst) {
193 if (
c->derivedFrom(parent_id) &&
c!=parent_id) {
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
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 BASE_IMPEXP registerAllPendingClasses()
Register all pending classes - to be called just before de-serializing an object, for example...
std::vector< const mrpt::utils::TRuntimeClassId * > BASE_IMPEXP getAllRegisteredClasses()
Returns a list with all the classes registered in the system through mrpt::utils::registerClass.
std::map< std::string, const TRuntimeClassId * > TClassnameToRuntimeId
GLsizei GLsizei GLuint * obj
void BASE_IMPEXP registerClassCustomName(const char *customName, const TRuntimeClassId *pNewClass)
Mostly for internal use within mrpt sources, to handle exceptional cases with multiple serialization ...
void(* TRegisterFunction)()
const TRuntimeClassId BASE_IMPEXP * findRegisteredClass(const std::string &className)
Return info about a given class by its name, or NULL if the class is not registered.
TClassnameToRuntimeId registeredClasses
const TRuntimeClassId * Get(const std::string &className)
This namespace provides multitask, synchronization utilities.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
A thread-safe template queue for object passing between threads; for a template argument of T...
GLsizei const GLchar ** string
CThreadSafeQueue< TRegisterFunction > BASE_IMPEXP & pending_class_registers()
std::atomic< bool > m_being_modified
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
volatile bool BASE_IMPEXP pending_class_registers_modified
Set to true if pending_class_registers() has been called after registerAllPendingClasses(). Startup value is false.
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 BASE_IMPEXP registerClass(const mrpt::utils::TRuntimeClassId *pNewClass)
Register a class into the MRPT internal list of "CSerializable" descendents.
std::vector< const TRuntimeClassId * > getListOfAllRegisteredClasses()
A structure that holds runtime class type information.
std::vector< const TRuntimeClassId * > BASE_IMPEXP getAllRegisteredClassesChildrenOf(const TRuntimeClassId *parent_id)
Like getAllRegisteredClasses(), but filters the list to only include children clases of a given base ...
std::atomic< int > BASE_IMPEXP & pending_class_registers_count()