Go to the documentation of this file.
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 registerClass(const mrpt::rtti::TRuntimeClassId *pNewClass)
Register a class into the MRPT internal list of "CObject" descendents.
const TRuntimeClassId * Get(const std::string &className, const bool allow_ignore_namespace)
A structure that holds runtime class type information.
void registerAllPendingClasses()
Register all pending classes - to be called just before de-serializing an object, for example.
A singleton with the central registry for CSerializable run-time classes: users do not use this class...
std::vector< const mrpt::rtti::TRuntimeClassId * > getAllRegisteredClasses()
Returns a list with all the classes registered in the system through mrpt::rtti::registerClass.
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.
TClassnameToRuntimeId m_ns_classes
std::atomic< bool > m_being_modified
std::vector< const TRuntimeClassId * > getAllRegisteredClassesChildrenOf(const TRuntimeClassId *parent_id)
Like getAllRegisteredClasses(), but filters the list to only include children clases of a given base ...
void(*)() TRegisterFunction
queue_register_functions_t & pending_class_registers()
TClassnameToRuntimeId m_no_ns_classes
bool pending_class_registers_modified
Set to true if pending_class_registers() has been called after registerAllPendingClasses().
static CClassRegistry & Instance()
The unique access point point to the singleton instance.
bool get(TRegisterFunction &ret)
Retrieve the next message in the queue, or nullptr if there is no message.
std::map< std::string, const TRuntimeClassId * > TClassnameToRuntimeId
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.
void Add(const std::string &className, const TRuntimeClassId &id)
std::string std::string format(std::string_view fmt, ARGS &&... args)
std::vector< const TRuntimeClassId * > getListOfAllRegisteredClasses()
std::atomic< int > & pending_class_registers_count()
Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020 | |