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",
90 bool has_to_unlock =
false;
97 if (has_to_unlock)
m_cs.unlock();
103 std::unique_lock<std::mutex> lk(
m_cs);
105 std::vector<const TRuntimeClassId*> ret;
107 ret.push_back(registeredClasse.second);
136 if (ptrToPtr !=
nullptr)
159 "[mrpt::rtti::registerClass] Warning: Invoked with a nullptr " 185 std::vector<const TRuntimeClassId*>
189 std::vector<const TRuntimeClassId*>
res;
191 for (
const auto&
c : lst)
193 if (
c->derivedFrom(parent_id) &&
c != parent_id)
void registerAllPendingClasses()
Register all pending classes - to be called just before de-serializing an object, for example...
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 ...
TClassnameToRuntimeId registeredClasses
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.
GLsizei GLsizei GLuint * obj
std::atomic< bool > m_being_modified
const TRuntimeClassId * Get(const std::string &className)
GLsizei const GLchar ** string
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.
const TRuntimeClassId * findRegisteredClass(const std::string &className)
Return info about a given class by its name, or nullptr if the class is not registered.
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::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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.
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)
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()