32 static std::atomic<int> cnt(0);
67 std::unique_lock<std::mutex> lk(
m_cs);
73 if (it->second != &
id)
76 "[MRPT class registry] Warning: overwriting already " 77 "registered className=`%s` with different " 78 "`TRuntimeClassId`!\n",
91 const std::string& className,
const bool allow_ignore_namespace)
94 bool has_to_unlock =
false;
105 ret = itEntry->second;
107 else if (allow_ignore_namespace)
110 const auto itEntry2 =
115 ret = itEntry2->second;
118 if (has_to_unlock)
m_cs.unlock();
124 std::unique_lock<std::mutex> lk(
m_cs);
126 std::vector<const TRuntimeClassId*> ret;
128 ret.push_back(registeredClasse.second);
136 const auto pos = ret.rfind(
"::");
137 if (pos != std::string::npos)
139 return ret.substr(pos + 2);
172 if (ptrToPtr !=
nullptr)
189 std::string(pNewClass->
className), *pNewClass);
195 "[mrpt::rtti::registerClass] Warning: Invoked with a nullptr " 221 std::vector<const TRuntimeClassId*>
225 std::vector<const TRuntimeClassId*> res;
227 for (
const auto& c : lst)
229 if (c->derivedFrom(parent_id) && c != parent_id)
241 const std::string& className,
const bool allow_ignore_namespace)
void registerAllPendingClasses()
Register all pending classes - to be called just before de-serializing an object, for example...
std::vector< const TRuntimeClassId * > getListOfAllRegisteredClasses()
std::string std::string format(std::string_view fmt, ARGS &&... args)
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.
bool get(TRegisterFunction &ret)
Retrieve the next message in the queue, or nullptr if there is no message.
std::atomic< bool > m_being_modified
const TRuntimeClassId * Get(const std::string &className, const bool allow_ignore_namespace)
static std::string stripNamespace(const std::string &n)
const TRuntimeClassId * findRegisteredClass(const std::string &className, const bool allow_ignore_namespace=true)
Return info about a given class by its name, or nullptr if the class is not registered.
void registerClassCustomName(const char *customName, const TRuntimeClassId *pNewClass)
Mostly for internal use within mrpt sources, to handle exceptional cases with multiple serialization ...
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
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...
std::map< std::string, const TRuntimeClassId * > TClassnameToRuntimeId
std::atomic< int > & pending_class_registers_count()
static CClassRegistry & Instance()
The unique access point point to the singleton instance.
TClassnameToRuntimeId m_ns_classes
void(*)() TRegisterFunction
void registerClass(const mrpt::rtti::TRuntimeClassId *pNewClass)
Register a class into the MRPT internal list of "CObject" descendents.
void Add(const std::string &className, const TRuntimeClassId &id)
TClassnameToRuntimeId m_no_ns_classes
std::vector< const mrpt::rtti::TRuntimeClassId * > getAllRegisteredClasses()
Returns a list with all the classes registered in the system through mrpt::rtti::registerClass.
queue_register_functions_t & pending_class_registers()