|
ADTF
|
The Data Definiton Language (DDL) is to describe memory content in a formal way.
So, it is possible to provide functionality, executables and utilities those are able to access, process and display data in a generic way.
The DDL will have some advantages over other ways to describe data like IDL (Interface Description Language), Protocol Buffers or FlatBuffers:
There are also some disadvantages on DDL:
JSON, break the users code and confuse them.The most important stream type instance within ADTF uses the default stream meta type adtf/default (see also stream type for a common definition).
This stream meta type is define in adtf::mediadescription::stream_meta_type_default. It will use 3 important properties:
md_struct: adtf::mediadescription::stream_meta_type_default::strMDStructPropertymd_definitions: adtf::mediadescription::stream_meta_type_default::strMDDefinitionsPropertymd_data_serialized: adtf::mediadescription::stream_meta_type_default::strMDDataSerializedmd_struct and md_definitions. > See i.e. the compatibiliy functionality: adtf/defaultIn ADTF 2 the DDL file (.dat.description) was an optional side-by-side file description next to the ADTF DAT File (.dat), it described the content of the ADTF DAT file.
Since the ADTFDAT file (.adtfdat) in ADTF 3 contains the complete DDL description if "adtf/default" stream meta type is used, only the units, datatypes, enums and structs tags are relevant.
Within ADTF 3 we do not use the streammetatypes or streams tags anymore which are mentioned within DDL Specification.
It is possible to create a DDL Description file (.description) before you define any structured data within your code.
We recommend using the DDL Editor from DDL Utility standalone or redeployed within ADTF Configuration Editor packages.
ADTF provides a tool that creates C++ headers containing structure definitions and access classes from a given DDL Description file (.description).
If you are using the adtf_add_filter, adtf_add_streaming_service, adtf_add_system_service CMake macros, you only need to specify your .description file within the sources of your target:
This will generate a header file (.h) named after your .description file, that you can include in your source files.
In the above case:
You may use following code within your filter if the DDL file contains any valid complex type (struct type) named tMyType:
If you want the structure definitions to be generated in a namespace use the "MD_NAMESPACE" argument:
If for some reasons you cannot use these macros, there is the adtf_md_generate_cpp CMake macro provided that will add header generation to existing targets.
The executable of the tool is accessible via the imported adtf::mdgen CMake target.
A non target based CMake macro is provided via adtf_md_generate_from_description.
An example of the usage of the generation facilities can be found at Example Demo Code Generation.
To describe the MD Generator Tool of the above chapter in more detail we need to tell, that it will create exactly two header files and one cpp-file.
mytypes_description.h: Containing the generated structs, enums out of the description filemytypes.h: Containing the md_sample_data template specializations to access the generated string description and the data of one sample via comfortable access functionsmytypes.cpp: Implementation of the access functionsIt is possible to use additional MD_ARGUMENTS within the CMake macro.
Instead of using the stdtypes (bool, int8_t, uint8_t, ... ) in generated header files this will lead to a usage of adtftypes (tBool, tInt8, tUInt8, ...):
Instead of using enum class for enumerations in generated header files this will lead to a usage of enum only:
Instead of using the global namepace qualifier for each type usage this will drop the leading :::
Instead of using alignment for positioning the elements, this will use padding bytes only:
ADTF provides a additional toolset that creates a description out of struct definitions within a simple C++ header and the necessary access classes.
To do so there are 3 tools provided:
castxml tool that is able to parse a C++ header file and write them into a xml-based temporary castxml fileheader2ddl tool using this castxml file and generates the .description fileadtf_mdgen that generates the access classes for the given .description fileIf you are using the adtf_add_filter, adtf_add_streaming_service, adtf_add_system_service CMake macros, you only need to specify your header files to generate descriptions for within the MD_HEADERS of your target:
This will generate the temporary castxml and .description file within your build folder.
The adtf_mdgen will generate the necessary access template classes within a header, that you can include in your source files. In the above case:
Now you can use following code within your filter like the the example under MD Generator Tool with a complex type named tMyType:
If for some reasons you cannot use these macros, there is the adtf_md_generate_cpp CMake macro provided that will add header generation to existing targets.
A non target based CMake macro is provided via adtf_md_generate_from_header.
An example of the usage of the generation facilities can be found at Example Demo Description Generation.
To describe the MD Generator Tool of the above chapter in more detail we need to tell, that it will create exactly two header files and one cpp-file.
mytypes.h: MD_HEADERS source file containing the "hand written" structure definitions to generate the description formytypes.castxml: Generated, temporary castxml type information based on clang parsermytypes.description: Generated, temporary DDL media description file with the struct definitions out of mytypes.hmytypes_mdgen.h: Generated file containing the md sample access functions for the structs, enums out of mytypes.hmytypes_mdgen.cpp: Implementation of the access functionsIt is possible to use MD_HEADERS_ARGUMENTS also combined with the MD_ARGUMENTS like described above within the CMake macro.
Instead generating all struct types only a description for the type tMyType is generated:
Instead of using the adtftypes (tBool, tInt8, tUInt8, ...) in generated description files this will lead to a forced usage of stdtypes (bool, int8_t, uint8_t, ... ):
Instead of using the current platform dependent byte order with the generated description, use the given one: LE or BE
It is also possible to read a file in code and create the description while runtime dynamically. To do so, please use the ddl::DDFile functionality.
It is possible to use the structure API provided via this ddl package. It will create the necessary DDL description while runtime and compile-time:
It is possible to use the type-reflection API provided via DDL package. It will create the necessary DDL description while runtime and compile-time:
This is a very old fashioned way to create your own DDL Decription. We do not recommend to use that, but for completeness it is specified here:
The DDL describes the data layout in two separate representations:
alignment, type information and arraysize are relevant attributes.byteorder attribute is absolutely not relevant here, because the values exists always in the same byteorder as the platform and the used compiler for that binary.bytepos, byteorder, type and arraysize are relevant attributes only.We separate these representations to access the values in a fast way in memory, when deserialized and the deserialized representation will assure that data are described in such a formal way to use it on every single platform.
It enables exchanging data between different architectures (big endian, little endian) and processors (Intel, ARM) vie network and file.
Reading access via md_sample_data:
Please note, that you are encouraged to use the adtf::mediadescription::md_sample_data template to access sample data via Media Descriptions (DDL), instead of using a decoder directly.
Reading access via DDLDecoder:
To read data from a sample you only need to use the adtf::mediadescription::cStaticSampleDecoder or adtf::mediadescription::cSampleDecoder.
See also ADTF Codecs and Sample Codecs.
Writing access via output_sample_data:
If you're generating output samples, please use the adtf::streaming::output_sample_data template with your structure definition.
There is no need to fill samples via a codec.
Writing access via DDLCodec:
To write data to a sample you can use the adtf::mediadescription::cStaticSampleCodec or adtf::mediadescription::cSampleCodec. See also ADTF Codecs and Sample Codecs.