COMMS
Template library intended to help with implementation of communication protocols.
|
Contains definition of comms::Field class. More...
#include <type_traits>
#include "comms/util/access.h"
#include "comms/details/FieldBase.h"
#include "comms/details/macro_common.h"
#include "comms/details/fields_access.h"
#include "comms/details/field_alias.h"
Go to the source code of this file.
Classes | |
class | comms::Field< TOptions > |
Base class to all the field classes. More... | |
Namespaces | |
namespace | comms |
Main namespace for all classes / functions of COMMS library. | |
Macros | |
#define | COMMS_FIELD_ALIAS(f_, ...) COMMS_DO_ALIAS(field_, f_, __VA_ARGS__) |
Generate convinience alias access member functions for other member fields. | |
#define | COMMS_FIELD_MEMBERS_ACCESS(...) |
Add convenience access enum and functions to the members of composite fields, such as comms::field::Bundle or comms::field::Bitfield. | |
#define | COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE(...) |
Similar to COMMS_FIELD_MEMBERS_ACCESS(), but dedicated for non-template classes. | |
#define | COMMS_FIELD_MEMBERS_NAMES(...) |
Provide names for member fields of composite fields, such as comms::field::Bundle or comms::field::Bitfield. | |
Contains definition of comms::Field class.
#define COMMS_FIELD_ALIAS | ( | f_, | |
... | |||
) | COMMS_DO_ALIAS(field_, f_, __VA_ARGS__) |
Generate convinience alias access member functions for other member fields.
Same as COMMS_MSG_FIELD_ALIAS() but applicable to comms::field::Bundle field.
#define COMMS_FIELD_MEMBERS_ACCESS | ( | ... | ) |
Add convenience access enum and functions to the members of composite fields, such as comms::field::Bundle or comms::field::Bitfield.
Very similar to COMMS_FIELD_MEMBERS_NAMES(), but does NOT require definition of Base inner member type (for some compilers) and does NOT define inner Field_* types for used member fields.
[in] | ... | List of fields' names. |
#define COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE | ( | ... | ) |
Similar to COMMS_FIELD_MEMBERS_ACCESS(), but dedicated for non-template classes.
The COMMS_FIELD_MEMBERS_ACCESS() macro is a generic one, which can be used in any class (template, or non-template). However, some compilers (such as g++-4.9 and below, clang-4.0 and below) may fail to compile it even though it uses valid C++11 constructs. If the compilation fails and the class it is being used in is NOT a template one, please use COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE() instead.
#define COMMS_FIELD_MEMBERS_NAMES | ( | ... | ) |
Provide names for member fields of composite fields, such as comms::field::Bundle or comms::field::Bitfield.
The fields of "composite" types, such as comms::field::Bundle or comms::field::Bitfield keep their members bundled in std::tuple and provide access to them via value() member functions. The access to the specific member field can be obtained using std::get later on:
However, it would be convenient to provide names and easier access to the member fields. The COMMS_FIELD_MEMBERS_NAMES() macro does exactly that when used inside the field class definition. Just inherit from the "composite" field and use the macro inside with the names for the member fields:
NOTE that there is a required to have Base member type that specifies base class used.
Usage of the COMMS_FIELD_MEMBERS_NAMES() is equivalent to having the following types and functions definitions:
NOTE, that provided names member1, member2, and member3, have found their way to the following definitions:
See Bitfield Fields and Bundle Fields for more examples and details
[in] | ... | List of member fields' names. |