File: lib_mrpt_rtti.md

package info (click to toggle)
mrpt 1%3A2.5.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 87,448 kB
  • sloc: cpp: 551,662; ansic: 38,702; xml: 3,914; python: 2,547; sh: 404; makefile: 237
file content (41 lines) | stat: -rw-r--r-- 1,234 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
\defgroup mrpt_rtti_grp [mrpt-rtti]

Runtime Type Information (RTTI) library, providing compiler-independent class
registry, class factory, and inheritance information.

[TOC]

# Library mrpt-rtti


This library is part of MRPT and can be installed in Debian-based systems with:

		sudo apt install libmrpt-rtti-dev

Read also [how to import MRPT into your CMake scripts](mrpt_from_cmake.html).

Any class with RTTI support has to be derived from mrpt::rtti::CObject, either
directly or via a hierarchy of inheriting classes.
Class factory by name enables deserialization of polymorphic classes in the
library \ref mrpt_serialization_grp.

All classes defined in each MRPT module are automatically registered when
loading the module (if dynamically linked).

## Example #1: defining new user classes

See: \ref rtti_example1/test.cpp
\snippet rtti_example1/test.cpp example-define-class
\snippet rtti_example1/test.cpp example-define-class-test
Output:
\include rtti_example1/console-ex1.out

## Example #2: using the class factory

See: \ref rtti_example1/test.cpp
\snippet rtti_example1/test.cpp example-define-class
\snippet rtti_example1/test.cpp example-factory
Output:
\include rtti_example1/console-ex2.out

# Library contents