3.5.6. Fast DDS-Gen for data types source code generation¶
eProsima Fast DDS comes with a built-in source code generation tool, Fast DDS-Gen, which eases the process of translating an IDL specification of a data type to a functional implementation. Thus, this tool automatically generates the source code of a data type defined using IDL. A basic use of the tool is described below. To learn about all the features that Fast DDS offers, please refer to Fast DDS-Gen section.
184.108.40.206. Basic usage¶
Fast DDS can be executed by calling fastrtpsgen on Linux or fastrtpsgen.bat on Windows.
The IDL file containing the data type definition is given with the
fastrtpsgen [<options>] <IDLfile> [<IDLfile> ...]
fastrtpsgen.bat [<options>] <IDLfile> [<IDLfile> ...]
Among the available arguments defined in Usage, the main Fast DDS-Gen options for data type source code generation are the following:
-replace: It replaces existing files in case the data type files have been previously generated.
-help: It lists the currently supported platforms and Visual Studio versions.
-typeobject: It builds additional files for
TypeObjectgeneration and management (see TypeObject).
-example: It generates a basic example of a DDS application and the files to build it for the given
platform. Thus, Fast DDS-Gen tool can generate a sample application using the provided data type, together with a Makefile, to compile it on Linux distributions, and a Visual Studio project for Windows. To see an example of this please refer to tutorial Building a publish/subscribe application.
220.127.116.11. Output files¶
Fast DDS-Gen outputs several files. Assuming the IDL file had the name “Mytype”, and none of the above options have been defined, these files are:
MyType.cxx/.h: Type definition.
MyTypePubSubType.cxx/.h: Serialization and deserialization source code for the data type. It also defines the
getKey()member function of the
MyTypePubSubTypeclass in case the topic implements keys (see Data types with a key).
-typeobject argument was used, MyType.cxx is modified to register the
TypeObject representation in
TypeObjectFactory, and these files will also be generated:
MyTypeTypeObject.cxx/.h: TypeObject representation for MyType IDL.