MRPT  1.9.9
rtti_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <mrpt/rtti/CObject.h>
11 #include <gtest/gtest.h>
12 
13 namespace MyNS
14 {
16 {
17  public:
20 };
21 }
22 
24 
26 {
28 }
29 
30 TEST(rtti, CObject_CLASSID)
31 {
32  EXPECT_TRUE(
35 }
36 
37 TEST(rtti, MyDerived1_CLASSID)
38 {
39  using namespace std;
40  const auto cid_myd1 = CLASS_ID(MyNS::MyDerived1);
41  EXPECT_TRUE(std::string(cid_myd1->className) == std::string("MyDerived1"));
42 
43  const auto cid_cobj = CLASS_ID(mrpt::rtti::CObject);
44  EXPECT_TRUE(cid_myd1->getBaseClass() == cid_cobj);
45 
46  // RTTI IS_DERIVED()
47  {
49  EXPECT_TRUE(IS_DERIVED(p, MyNS::MyDerived1));
50  EXPECT_TRUE(IS_DERIVED(p, mrpt::rtti::CObject));
51  }
52 }
53 
54 TEST(rtti, Factory)
55 {
56  do_register();
58  EXPECT_TRUE(p);
59 }
IMPLEMENTS_MRPT_OBJECT(CMultiObjMotionOpt_Scalarization, CMultiObjectiveMotionOptimizerBase, mrpt::nav) CMultiObjMotionOpt_Scalarization
STL namespace.
The virtual base class of all MRPT classes with a unified RTTI system.
Definition: CObject.h:141
TEST(rtti, CObject_CLASSID)
#define IS_DERIVED(ptrObj, class_name)
Evaluates to true if a pointer to an object (derived from mrpt::rtti::CObject) is an instance of the ...
Definition: CObject.h:108
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Definition: CObject.h:84
#define DEFINE_MRPT_OBJECT(class_name)
This declaration must be inserted in all CObject classes definition, within the class declaration...
Definition: CObject.h:175
GLsizei const GLchar ** string
Definition: glext.h:4101
#define CLASS_ID_NAMESPACE(class_name, namespaceName)
Definition: CObject.h:87
static const mrpt::rtti::TRuntimeClassId & GetRuntimeClassIdStatic()
Definition: CObject.cpp:19
void registerClass(const mrpt::rtti::TRuntimeClassId *pNewClass)
Register a class into the MRPT internal list of "CObject" descendents.
void do_register()
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLfloat GLfloat p
Definition: glext.h:6305
[example-define-class]
mrpt::rtti::CObject::Ptr classFactoryPtr(const std::string &className)
Like classFactory() but returns a smart pointer.
Definition: CObject.cpp:116
std::shared_ptr< CObject > Ptr
Definition: CObject.h:148



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020