32 const auto pos = ret.rfind(
"::");
33 if (pos != std::string::npos)
35 return ret.substr(pos + 2);
48 static std::atomic<int> cnt(0);
83 m_being_modified=
true;
85 std::unique_lock<std::mutex> lk(m_cs);
88 const auto it = registeredClasses.find(className);
89 if (it != registeredClasses.cend()) {
90 if (it->second != &
id) {
91 std::cerr <<
mrpt::format(
"[MRPT class registry] Warning: overwriting already registered className=`%s` with different `TRuntimeClassId`!\n", className.c_str());
94 registeredClasses[className] = &
id;
96 m_being_modified=
false;
105 bool has_to_unlock =
false;
106 if (m_being_modified)
109 has_to_unlock =
true;
112 if (has_to_unlock) m_cs.unlock();
118 std::unique_lock<std::mutex> lk(m_cs);
120 std::vector<const TRuntimeClassId*> ret;
122 ret.push_back( it->second );
159 if((*ptrToPtr)!=NULL)
203 std::vector<const TRuntimeClassId*>
res;
205 for (
const auto &
c : lst) {
206 if (
c->derivedFrom(parent_id) &&
c!=parent_id) {
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
static std::string stripNamespace(const std::string &n)
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...
GLuint const GLchar * name
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()