namespace mrpt::rtti

Overview

namespace rtti {

// namespaces

namespace mrpt::rtti::internal;

// typedefs

typedef std::map<std::string, const TRuntimeClassId*> TClassnameToRuntimeId;
typedef void(*)() TRegisterFunction;

// structs

template <>
struct CLASS_ID_impl<std::monostate>;

template <typename T>
struct CLASS_ID_impl;

template <typename T>
struct IS_CLASS_impl;

struct TRuntimeClassId;
struct queue_register_functions_t;

// classes

class CClassRegistry;
class CListOfClasses;
class CObject;

// global variables

bool pending_class_registers_modified = false;

// global functions

void registerClass(const mrpt::rtti::TRuntimeClassId* pNewClass);
void registerClassCustomName(const char* customName, const TRuntimeClassId* pNewClass);
std::vector<const mrpt::rtti::TRuntimeClassId*> getAllRegisteredClasses();
std::vector<const TRuntimeClassId*> getAllRegisteredClassesChildrenOf(const TRuntimeClassId* parent_id);
const TRuntimeClassId* findRegisteredClass(const std::string& className, const bool allow_ignore_namespace = true);
void registerAllPendingClasses();
mrpt::rtti::CObject::Ptr classFactory(const std::string& className);
void registerAllClasses_mrpt_rtti();
std::atomic<int>& pending_class_registers_count();
queue_register_functions_t& pending_class_registers();

} // namespace rtti

Global Variables

bool pending_class_registers_modified = false

Set to true if pending_class_registers() has been called after registerAllPendingClasses().

Startup value is false.

Global Functions

void registerClass(const mrpt::rtti::TRuntimeClassId* pNewClass)

Register a class into the MRPT internal list of “CObject” descendents.

Used internally in the macros DEFINE_SERIALIZABLE, etc…

See also:

getAllRegisteredClasses

void registerClassCustomName(const char* customName, const TRuntimeClassId* pNewClass)

Mostly for internal use within mrpt sources, to handle exceptional cases with multiple serialization names for backward compatibility (CMultiMetricMaps, CImage,…)

For internal use within mrpt sources, and only in exceptional cases (CMultiMetricMaps, CImage,…)

std::vector<const mrpt::rtti::TRuntimeClassId*> getAllRegisteredClasses()

Returns a list with all the classes registered in the system through mrpt::rtti::registerClass.

See also:

registerClass, findRegisteredClass

std::vector<const TRuntimeClassId*> getAllRegisteredClassesChildrenOf(const TRuntimeClassId* parent_id)

Like getAllRegisteredClasses(), but filters the list to only include children clases of a given base one.

See also:

getAllRegisteredClasses(), getAllRegisteredClassesChildrenOf()

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.

The list of registered “namespaces::class_name” will be looked up first. If no match is found, and allow_ignore_namespace=true, then a second search will be performed looking for a match of the class name without the namespace part. Note that this is enabled by default since namespaces were not used while serializing classes in MRPT older than v2.0, so this option allows reading from older datasets transparently. It could be set to false if it is ensured that only mrpt2 datasets will be read.

Parameters:

className

The name of the class to look up

[i]

allow_ignore_namespace See discussion above

See also:

registerClass, getAllRegisteredClasses

void registerAllPendingClasses()

Register all pending classes - to be called just before de-serializing an object, for example.

After calling this method, pending_class_registers_modified is set to false until pending_class_registers() is invoked.

mrpt::rtti::CObject::Ptr classFactory(const std::string& className)

Creates an object given by its registered name.

See also:

findRegisteredClass(), registerClass()