RefleX
Build DDS Applications in Modern C++ without IDL
|
Macros to adapt user-defined types (classes, structs, and enums) to allow RefleX to extract type-specific information at compile-time. More...
Go to the source code of this file.
Macros | |
#define | REFLEX_STATIC_STRING_BOUND |
Static bound for string types. Default 256. More... | |
#define | REFLEX_STATIC_CONTAINER_BOUND |
Static bound for container types. Default 256. More... | |
#define | REFLEX_ENUM_DEF_CUSTOM(EnumType, Name, Size) |
Adapt and customize a C++ native enumeration for use with RefleX. More... | |
#define | REFLEX_ENUM_MEMBER_DEF_CUSTOM(EnumType, Index, Name, Ordinal) |
Adapt and customize a C++ native enumeration item names and ordinals for use with RefleX. More... | |
#define | REFLEX_STRUCT_NAME_DEF_CUSTOM(FullyQualifiedType, Name) |
Adapt and customize a std::tuple type for use with RefleX. More... | |
#define | REFLEX_STRUCT_MEMBER_DEF_CUSTOM(FullyQualifiedType, Index, Name, Flags) |
Adapt and customize members of a std::tuple type for use with RefleX. More... | |
#define | REFLEX_ADAPT_ENUM(EnumType, Attributes) |
Adapt a C++ native enumeration for use with RefleX. More... | |
#define | REFLEX_ADAPT_STRUCT(Type, Attributes) |
Adapt a native C++ struct/class for use with RefleX. More... | |
#define | REFLEX_ADAPT_VALUETYPE(Type, Base, Attributes) |
Adapt a C++ struct/class hierarchy for use with RefleX. More... | |
#define | REFLEX_OPTIONAL (DDS_TYPECODE_NONKEY_MEMBER) |
Indicate in REFLEX_ADAPT_STRUCT that a member is optional. More... | |
#define | REFLEX_KEY (DDS_TYPECODE_KEY_MEMBER) |
Indicate in REFLEX_ADAPT_STRUCT that a member is key. More... | |
#define | REFLEX_REQUIRED (DDS_TYPECODE_NONKEY_REQUIRED_MEMBER) |
Indicate in REFLEX_ADAPT_STRUCT that a member is required. More... | |
#define | REFLEX_EXTENDS(X) X |
Indicate the base struct/class in REFLEX_ADAPT_VALUETYPE. More... | |
Macros to adapt user-defined types (classes, structs, and enums) to allow RefleX to extract type-specific information at compile-time.
#define REFLEX_ADAPT_ENUM | ( | EnumType, | |
Attributes | |||
) |
Adapt a C++ native enumeration for use with RefleX.
Consider the following native C++ enumeration called FillKind.
It may be adapted as follows.
The above declarations results into an X-Types typecode representing an enumeration named FillKind that matches the C++ native declaration.
EnumType | The fully qualified type of the native C++ enumeration. |
Attributes | A list of parenthesis describing the enumeration items and their ordinals. Parenthesis are not separated by comma. |
#define REFLEX_ADAPT_STRUCT | ( | Type, | |
Attributes | |||
) |
Adapt a native C++ struct/class for use with RefleX.
Consider the following native C++ struct called ShapeType.
It may be adapted as follows.
The above declarations results into an X-Types typecode representing an struct type named ShapeType that matches the C++ native declaration. The namespaces are ignored and the resulting typecode has EXTENSIBLE_EXTENSIBILITY. The default bounds for strings and containers are REFLEX_STATIC_STRING_BOUND and REFLEX_STATIC_CONTAINER_BOUND.
If the type of a member contains a comma, such as in std::pair or std::tuple, such types must be typedef-ed so that commas are no longer needed.
If the type is a class, getters may be used instead of the actual member names. The name of the getter is used to define the member name. The getter name should include the trailing parenthesis as in color(), x(), y(), and shapesize().
Type | The fully qualified type of the native C++ struct/class. |
Attributes | A list of parenthesis describing the members (the type and the member name). Parenthesis are not separated by comma. |
#define REFLEX_ADAPT_VALUETYPE | ( | Type, | |
Base, | |||
Attributes | |||
) |
Adapt a C++ struct/class hierarchy for use with RefleX.
Type | The fully qualified type of the C++ struct/class. |
Base | The fully qualified type of the C++ struct/class that Type inherits from. |
Attributes | A list of parenthesis describing the members (the type and the member name). Parenthesis are not separated by comma. |
#define REFLEX_ENUM_DEF_CUSTOM | ( | EnumType, | |
Name, | |||
Size | |||
) |
Adapt and customize a C++ native enumeration for use with RefleX.
REFLEX_ENUM_DEF_CUSTOM and REFLEX_ENUM_MEMBER_DEF_CUSTOM are always used together and they allow customization of enumeration type-name, item names and ordinals that are not possible with REFLEX_ADAPT_ENUM .
Consider the following native C++ enumeration called FillKind.
REFLEX_ENUM_DEF_CUSTOM and REFLEX_ENUM_MEMBER_DEF_CUSTOM may be used as follows.
The above declarations results in to an X-Types typecode representing an enumeration named FillKindStyle as follows.
EnumType | Fully qualified type of the native C++ enumeration. |
Name | The target name of the enumeration. This may be different from the name of the native C++ enumeration. |
Size | The number of items in the C++ native enumeration. |
#define REFLEX_ENUM_MEMBER_DEF_CUSTOM | ( | EnumType, | |
Index, | |||
Name, | |||
Ordinal | |||
) |
Adapt and customize a C++ native enumeration item names and ordinals for use with RefleX.
See REFLEX_ENUM_DEF_CUSTOM and REFLEX_ENUM_MEMBER_DEF_CUSTOM for more information.
EnumType | The fully qualified type of the enumeration to be adapted. |
Index | The index of the member. Starts at 0. |
Name | The target name of the member |
Ordinal | The integer value of the enumeration item. |
#define REFLEX_EXTENDS | ( | X | ) | X |
Indicate the base struct/class in REFLEX_ADAPT_VALUETYPE.
#define REFLEX_KEY (DDS_TYPECODE_KEY_MEMBER) |
Indicate in REFLEX_ADAPT_STRUCT that a member is key.
#define REFLEX_OPTIONAL (DDS_TYPECODE_NONKEY_MEMBER) |
Indicate in REFLEX_ADAPT_STRUCT that a member is optional.
#define REFLEX_REQUIRED (DDS_TYPECODE_NONKEY_REQUIRED_MEMBER) |
Indicate in REFLEX_ADAPT_STRUCT that a member is required.
#define REFLEX_STATIC_CONTAINER_BOUND |
Static bound for container types. Default 256.
#define REFLEX_STATIC_STRING_BOUND |
Static bound for string types. Default 256.
#define REFLEX_STRUCT_MEMBER_DEF_CUSTOM | ( | FullyQualifiedType, | |
Index, | |||
Name, | |||
Flags | |||
) |
Adapt and customize members of a std::tuple type for use with RefleX.
See REFLEX_STRUCT_NAME_DEF_CUSTOM and REFLEX_ADAPT_STRUCT for more information.
FullyQualifiedType | The fully qualified type of the type to be adapted. |
Index | The index of the member. Starts at 0. |
Name | The target name of the member |
Flags | One of REFLEX_KEY, REFLEX_REQUIRED, and REFLEX_OPTIONAL |
#define REFLEX_STRUCT_NAME_DEF_CUSTOM | ( | FullyQualifiedType, | |
Name | |||
) |
Adapt and customize a std::tuple type for use with RefleX.
By default, std::tuple types do not require any adaptations to use with RefleX. Adaptations might be desirable to allow more descriptive (human-readable) names for tuple types and members.
Without customization, a std::tuple maps to "DefaultTupleNameN" where N is unique for each std::tuple type. The member names default to "m0", "m1", "m2" etc. REFLEX_STRUCT_NAME_DEF_CUSTOM and REFLEX_STRUCT_MEMBER_DEF_CUSTOM allow customization of the typename and member names. They are always used together.
Consider the following std::tuple definition.
Without any customization, ShapeTypeTuple maps to the following X-Types struct type. Note that there is no key attribute specified.
With REFLEX_STRUCT_NAME_DEF_CUSTOM and REFLEX_STRUCT_MEMBER_DEF_CUSTOM the name and the members of the ShapeTypeTuple can be easily customized.
The above declarations results in to an X-Types typecode representing a struct named ShapeType as follows.
FullyQualifiedType | The fully qualified type of the C++ tuple type. |
Name | The target name of the tuple type. |