Class CObject
Defined in File CObject.h
Class Documentation
-
class CObject
Virtual base to provide a compiler-independent RTTI system.
Each class named
Foowill 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 ofstd::make_shared<>to create objects, to avoid memory alignment problems caused by classes containing Eigen vectors or matrices. Example:Or using the shorter auxiliary static methodFoo::Ptr o = std::make_shared<Foo>();
::Create()for conciseness or to keep compatibility with MRPT 1.5.* code bases:If a special memory allocator is needed, useFoo::Ptr o = Foo::Create();
Foo::CreateAlloc(alloc,...);.See also
RTTI classes and functions for polymorphic hierarchies
Public Types
Public Functions
-
inline virtual const mrpt::rtti::TRuntimeClassId *GetRuntimeClass() const
Returns information about the class of an object in runtime.
-
virtual CObject *clone() const = 0
Returns a deep copy (clone) of the object, indepently of its class.
-
virtual ~CObject() = default
Public Static Functions
-
static const mrpt::rtti::TRuntimeClassId &GetRuntimeClassIdStatic()
Protected Static Functions
-
static mrpt::rtti::TRuntimeClassId *_GetBaseClass()
Protected Static Attributes
-
static constexpr mrpt::rtti::TRuntimeClassId runtimeClassId = {"CObject", nullptr, nullptr}