Free Electron
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
fe::ext::Relay< SIZE, TYPE, BASE > Class Template Reference

Collection of accessors for a Record. More...

#include <Relay.h>

Inheritance diagram for fe::ext::Relay< SIZE, TYPE, BASE >:
Inheritance graph
[legend]

Public Types

enum  { e_totalSize =BASE::e_size+SIZE }
 

Public Member Functions

WeakRecord bind (WeakRecord record)
 Bind all accessors to a given record. More...
 
virtual void bind (sp< Scope > spScope)
 
BWORD check (U32 index) const
 Check if the bound Record supports the attribute. More...
 
template<typename T >
BWORD checkType (U32 index) const
 Verify that the attribute is the given type. More...
 
template<typename T >
T & access (U32 index) const
 Return a reference to the entry without checking. More...
 
template<typename T >
safeGet (U32 index) const
 Return the value of an entry, if supported. More...
 
template<typename T >
get (U32 index) const
 Return the value of an entry, bypassing checks. More...
 
template<typename T >
void safeSet (U32 index, T value)
 Set the value of an entry, if supported. More...
 
template<typename T >
void set (U32 index, T value)
 Set the value of an entry, bypassing checks. More...
 
String print (U32 index) const
 Returns a string representation of the entry's state. More...
 
void dump (void) const
 Logs all entries with state. More...
 
virtual Record createRecord (void)
 Create a new Record. More...
 
virtual Record createRecordAndBind (void)
 (convenience) Create and bind a new Record More...
 
sp< Scopescope (void)
 Returns the currently bound scope. More...
 
sp< Layout > layout (void)
 Returns a Layout with the attributes of this relay. More...
 
WeakRecordrecord (void)
 Returns the currently bound record. More...
 
void initializeRecursively (Record &rRecord)
 

Static Public Member Functions

static void populate (sp< Layout > &rspLayout)
 Populate the given Layout with this Relay's attributes. More...
 
static const char * typeAt (U32 index)
 Returns the attribute's type. More...
 
static const char * nameAt (U32 index)
 Returns the attribute's name. More...
 

Protected Member Functions

void createAndSetComponent (U32 index, String componentName)
 Construct and insert a Component into the given slot. More...
 
void createAndSetRecordGroup (U32 index)
 Construct and insert a RecordGroup Component into the given slot. More...
 

Private Member Functions

void prepare (void)
 
sp< Layout > createLayout (void)
 Create or extend a layout. More...
 
virtual void initialize (void)
 

Private Attributes

WeakRecord m_record
 
Accessor< I32 > m_pAccessorArray [e_totalSize]
 
hp< Scopem_hpScope
 
hp< Layout > m_hpLayout
 

Detailed Description

template<int SIZE, typename TYPE, typename BASE = NoRelay>
class fe::ext::Relay< SIZE, TYPE, BASE >

Collection of accessors for a Record.

A Relay is somewhat like a C++ class with only virtual data members.

A Relay can inherit attributes from one other Relay through the optional BASE template parameter. Any number of Relays can be chained together in this manner.

Usage is usually done by deriving from Relay into a simple subclass:

namespace
{
static const char* gs_myAttributes[]=
{
"F32", "MyF32",
"I32", "MyI32"
};
}
class MyRelay: public fe::Relay<2,MyRelay>
{
public:
enum
{
e_myF32,
e_myI32,
e_size
};
static
const char* layoutName(void) { return "base"; }
static
const char** attributes(void) { return gs_myAttributes; }
};

Because of the anonymous namespace, this can be defined as such in a shared header.

The enumeration is purely for the convenience of users of your relay. The enumeration's entries should be aligned with the rows in the attribute array.

Member Function Documentation

◆ access()

template<int SIZE, typename TYPE , typename BASE >
template<typename T >
T & fe::ext::Relay< SIZE, TYPE, BASE >::access ( U32  index) const
inline

Return a reference to the entry without checking.

◆ bind()

template<int SIZE, typename TYPE , typename BASE >
WeakRecord fe::ext::Relay< SIZE, TYPE, BASE >::bind ( WeakRecord  record)
inline

Bind all accessors to a given record.

A Relay can be rebound to different records, but caution is neccessary if you switch to a record in a different Scope.

◆ check()

template<int SIZE, typename TYPE , typename BASE >
BWORD fe::ext::Relay< SIZE, TYPE, BASE >::check ( U32  index) const
inline

Check if the bound Record supports the attribute.

◆ checkType()

template<int SIZE, typename TYPE , typename BASE >
template<typename T >
BWORD fe::ext::Relay< SIZE, TYPE, BASE >::checkType ( U32  index) const
inline

Verify that the attribute is the given type.

◆ createAndSetComponent()

template<int SIZE, typename TYPE , typename BASE >
void fe::ext::Relay< SIZE, TYPE, BASE >::createAndSetComponent ( U32  index,
String  componentName 
)
inlineprotected

Construct and insert a Component into the given slot.

The componentName is passed to Registry::create().

◆ createAndSetRecordGroup()

template<int SIZE, typename TYPE , typename BASE >
void fe::ext::Relay< SIZE, TYPE, BASE >::createAndSetRecordGroup ( U32  index)
inlineprotected

Construct and insert a RecordGroup Component into the given slot.

◆ createLayout()

template<int SIZE, typename TYPE , typename BASE >
sp< Layout > fe::ext::Relay< SIZE, TYPE, BASE >::createLayout ( void  )
inlineprivate

Create or extend a layout.

The layout is populated by attributes of this relay.

◆ createRecord()

template<int SIZE, typename TYPE , typename BASE >
Record fe::ext::Relay< SIZE, TYPE, BASE >::createRecord ( void  )
inlinevirtual

Create a new Record.

In addition to creating the record in the scope, this calls any Relay-based initialization.

Implements fe::ext::CoreRelay.

◆ createRecordAndBind()

template<int SIZE, typename TYPE , typename BASE = NoRelay>
virtual Record fe::ext::Relay< SIZE, TYPE, BASE >::createRecordAndBind ( void  )
inlinevirtual

(convenience) Create and bind a new Record

Implements fe::ext::CoreRelay.

◆ dump()

template<int SIZE, typename TYPE , typename BASE >
void fe::ext::Relay< SIZE, TYPE, BASE >::dump ( void  ) const
inline

Logs all entries with state.

◆ get()

template<int SIZE, typename TYPE , typename BASE >
template<typename T >
T fe::ext::Relay< SIZE, TYPE, BASE >::get ( U32  index) const
inline

Return the value of an entry, bypassing checks.

Since there is no function argument that uses the typename, you have to supply the template argument explicitly.

◆ layout()

template<int SIZE, typename TYPE , typename BASE >
sp< Layout > fe::ext::Relay< SIZE, TYPE, BASE >::layout ( void  )
inline

Returns a Layout with the attributes of this relay.

◆ nameAt()

template<int SIZE, typename TYPE , typename BASE >
const char * fe::ext::Relay< SIZE, TYPE, BASE >::nameAt ( U32  index)
inlinestatic

Returns the attribute's name.

◆ populate()

template<int SIZE, typename TYPE , typename BASE >
void fe::ext::Relay< SIZE, TYPE, BASE >::populate ( sp< Layout > &  rspLayout)
inlinestatic

Populate the given Layout with this Relay's attributes.

◆ print()

template<int SIZE, typename TYPE , typename BASE >
String fe::ext::Relay< SIZE, TYPE, BASE >::print ( U32  index) const
inline

Returns a string representation of the entry's state.

References fe::Accessor< T >::queryAttribute().

◆ record()

template<int SIZE, typename TYPE , typename BASE = NoRelay>
WeakRecord& fe::ext::Relay< SIZE, TYPE, BASE >::record ( void  )
inline

Returns the currently bound record.

◆ safeGet()

template<int SIZE, typename TYPE , typename BASE >
template<typename T >
T fe::ext::Relay< SIZE, TYPE, BASE >::safeGet ( U32  index) const
inline

Return the value of an entry, if supported.

Since there is no function argument that uses the typename, you have to supply the template argument explicitly.

◆ safeSet()

template<int SIZE, typename TYPE , typename BASE >
template<typename T >
void fe::ext::Relay< SIZE, TYPE, BASE >::safeSet ( U32  index,
value 
)
inline

Set the value of an entry, if supported.

◆ scope()

template<int SIZE, typename TYPE , typename BASE = NoRelay>
sp<Scope> fe::ext::Relay< SIZE, TYPE, BASE >::scope ( void  )
inline

Returns the currently bound scope.

◆ set()

template<int SIZE, typename TYPE , typename BASE >
template<typename T >
void fe::ext::Relay< SIZE, TYPE, BASE >::set ( U32  index,
value 
)
inline

Set the value of an entry, bypassing checks.

◆ typeAt()

template<int SIZE, typename TYPE , typename BASE >
const char * fe::ext::Relay< SIZE, TYPE, BASE >::typeAt ( U32  index)
inlinestatic

Returns the attribute's type.


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