class mrpt::rtti::CObject
Overview
Virtual base to provide a compiler-independent RTTI system.
Each class named Foo will have associated smart pointer types:
Foo::Ptr=>std::shared_ptr<Foo>(the most commonly-used one)Foo::ConstPtr=>std::shared_ptr<const Foo>Foo::UniquePtr=>std::unique_ptr<Foo>Foo::ConstUniquePtr=>std::unique_ptr<const Foo>
It is recommended to use MRPT-defined std::make_shared<> instead of std::make_shared<> to create objects, to avoid memory alignment problems caused by classes containing Eigen vectors or matrices. Example:
Foo::Ptr o = std::make_shared<Foo>();
Or using the shorter auxiliary static method ::Create() for conciseness or to keep compatibility with MRPT 1.5.* code bases:
Foo::Ptr o = Foo::Create();
If a special memory allocator is needed, use Foo::CreateAlloc(alloc,...);.
See also:
#include <mrpt/rtti/CObject.h> class CObject { public: // typedefs typedef std::shared_ptr<CObject> Ptr; typedef std::shared_ptr<const CObject> ConstPtr; // methods static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; }; // direct descendants class CMultiObjectiveMotionOptimizerBase; class CSerializable;
Methods
virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const
Returns information about the class of an object in runtime.