Cafu Engine
cf::TypeSys::VarArrayT< T > Class Template Reference

This is a "wrapper" around a normal C++ variable specifically of type ArrayT<T>. More...

#include "Variables.hpp"

Inheritance diagram for cf::TypeSys::VarArrayT< T >:

Public Member Functions

 VarArrayT (const char *Name, unsigned int InitSize, const T &InitValue, const char *Flags[]=NULL)
 The constructor. More...
const ArrayT< T > & Get () const
unsigned int Size () const
void Clear ()
void Overwrite ()
void PushBack (const T Element)
const T & operator[] (unsigned int i) const
T & operator[] (unsigned int i)
void Serialize (Network::OutStreamT &Stream) const
 Stores the value of this variable in the given Stream. More...
void Deserialize (Network::InStreamT &Stream)
 Restores the value of this variable from the given Stream. More...
void accept (VisitorT &Visitor)
void accept (VisitorConstT &Visitor) const
- Public Member Functions inherited from cf::TypeSys::VarBaseT
 VarBaseT (const char *Name, const char *Flags[])
const char * GetName () const
const char ** GetFlags () const
bool HasFlag (const char *Flag) const
const char * GetFlag (const char *Flag, unsigned int Nr, const char *Default=NULL) const
virtual std::string GetExtraMessage () const
 Sometimes actions on variables generate extra messages that are relevant to the user. More...

Detailed Description

template<class T>
class cf::TypeSys::VarArrayT< T >

This is a "wrapper" around a normal C++ variable specifically of type ArrayT<T>.

This class is similar to VarT< ArrayT<T> >, but was invented because working with VarT< ArrayT<T> >s is actually difficult in practice:

  • Setting individual elements of the array or modifying the array itself (e.g. pushing back another element) via the VarT::Set() method is cumbersome.
  • Adding a non-const Get() method to VarT< ArrayT<T> > was not desired, because it would break the accounting for side-effects that is guaranteed by the VarT::Set() method.
  • (Arrays seem to need side-effects as little as lists of pre-made choices.)

Therefore, VarArrayT<T> was made to have an interface that is easier to use and more efficient when working with arrays, and consciously omits the "possible side-effects" feature that VarT::Set() has.

It can be used in place of a normal ArrayT variable whenever the functionality described in TypeSys Variables Overview is desired, for example in the member variables of component classes of game entities and GUI windows.

See Also
TypeSys Variables Overview

Constructor & Destructor Documentation

template<class T>
cf::TypeSys::VarArrayT< T >::VarArrayT ( const char *  Name,
unsigned int  InitSize,
const T &  InitValue,
const char *  Flags[] = NULL 

The constructor.

Member Function Documentation

template<class T >
void cf::TypeSys::VarArrayT< T >::Deserialize ( Network::InStreamT Stream)

Restores the value of this variable from the given Stream.

See Serialize() for additional details.

Implements cf::TypeSys::VarBaseT.

template<class T >
void cf::TypeSys::VarArrayT< T >::Serialize ( Network::OutStreamT Stream) const

Stores the value of this variable in the given Stream.

An implementation may also store additional data, so that Deserialize() is able to recover from side- effects where restoring the value of the variable alone does not suffice. For example, consider the side-effects of setting a new model name in a ComponentModelT as described at VarT::Set(): restoring the previous model name will properly restore the internal model resource, but not undo any clamps or resets that setting the new name caused for the animation and skin numbers. Thus, the implementation of this method for the model name would also store the values of the affected sibling variables, so that Deserialize() can implement a proper restore / "undo".

Implements cf::TypeSys::VarBaseT.

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