MIRA
|
The Accessor class is used as an adapter to reduce the code bloat within the reflection and serialization implementations. More...
#include <serialization/Accessor.h>
Public Types | |
typedef GetterPart::value_type | value_type |
the underlying type (as STL conform typedef) More... | |
Public Member Functions | |
Accessor (const Getter &getter, const Setter &setter) | |
Accessor (const Getter &getter) | |
Accessor & | operator= (const value_type &value) |
mimic the assignment behavior of underlying type, e.g. accessor = 1234; More... | |
operator GetReturnValueType () const | |
cast operator to mimic cast behavior of underlying value type; applies the getter, e.g. More... | |
const value_type & | get () const |
void | reflectRead (Reflector &r) |
Public Attributes | |
decltype(std::declval< GetterPart >().get()) typedef | GetReturnValueType |
the type that is returned by the get() method of the GetterPart. More... | |
Static Public Attributes | |
static const bool | isDirectGetter |
The Accessor class is used as an adapter to reduce the code bloat within the reflection and serialization implementations.
An accessor allows reading and writing access to data/member variable. It abstracts from the actual underlying access to that data, which may be a direct access or an access using getters and setters. In total there are 4 cases how to access data:
All these cases can be reduced to a single case, if this Accessor class is used as an abstraction layer.
It provides an assignment operator to mimic direct writing access and it provides a cast operator to mimic direct reading access (even if getters and setters are used).
This class puts together the AccessorGetterPart and AccessorSetterPart.
typedef GetterPart::value_type value_type |
the underlying type (as STL conform typedef)
|
inline |
mimic the assignment behavior of underlying type, e.g. accessor = 1234;
|
inline |
cast operator to mimic cast behavior of underlying value type; applies the getter, e.g.
int val = mygetter;
|
inlineinherited |
|
inlineinherited |
decltype(std::declval<GetterPart>().get()) typedef GetReturnValueType |
the type that is returned by the get() method of the GetterPart.
|
staticinherited |