MIRA
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Accessor< Getter, Setter > Class Template Reference

The Accessor class is used as an adapter to reduce the code bloat within the reflection and serialization implementations. More...

#include <serialization/Accessor.h>

Inheritance diagram for Accessor< Getter, Setter >:
Inheritance graph
[legend]

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)
 
Accessoroperator= (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_typeget () 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
 

Detailed Description

template<typename Getter, typename Setter>
class mira::Accessor< Getter, Setter >

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:

  1. read directly, write directly
  2. read directly, write via a setter
  3. read via a getter, write directly
  4. read via a getter, write via a setter

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.

Member Typedef Documentation

◆ value_type

the underlying type (as STL conform typedef)

Constructor & Destructor Documentation

◆ Accessor() [1/2]

Accessor ( const Getter getter,
const Setter setter 
)
inline

◆ Accessor() [2/2]

Accessor ( const Getter getter)
inline

Member Function Documentation

◆ operator=()

Accessor& operator= ( const value_type value)
inline

mimic the assignment behavior of underlying type, e.g. accessor = 1234;

◆ operator GetReturnValueType()

operator GetReturnValueType ( ) const
inline

cast operator to mimic cast behavior of underlying value type; applies the getter, e.g.

int val = mygetter;

◆ get()

const value_type& get ( ) const
inlineinherited

◆ reflectRead()

void reflectRead ( Reflector &  r)
inlineinherited

Member Data Documentation

◆ GetReturnValueType

decltype(std::declval<GetterPart>().get()) typedef GetReturnValueType

the type that is returned by the get() method of the GetterPart.

◆ isDirectGetter

const bool isDirectGetter
staticinherited

The documentation for this class was generated from the following file: