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

This is a "wrapper" around a normal C++ variable. More...

#include "Variables.hpp"

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

Public Member Functions

 VarT (const char *Name, const T &Value, const char *Flags[]=NULL)
 The constructor. More...
 
const T & Get () const
 Returns the value of this variable. More...
 
virtual void Set (const T &v)
 Sets the value of this variable to the given value v. More...
 
virtual void GetChoices (ArrayT< std::string > &Strings, ArrayT< T > &Values) const
 This method returns a list of acceptable input values for this variable, along with a string representation of each. More...
 
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
 
template<>
void Serialize (cf::Network::OutStreamT &Stream) const
 Stores the value of this variable in the given Stream. More...
 
template<>
void Serialize (cf::Network::OutStreamT &Stream) const
 Stores the value of this variable in the given Stream. More...
 
template<>
void Serialize (cf::Network::OutStreamT &Stream) const
 Stores the value of this variable in the given Stream. More...
 
template<>
void Serialize (cf::Network::OutStreamT &Stream) const
 Stores the value of this variable in the given Stream. More...
 
template<>
void Deserialize (cf::Network::InStreamT &Stream)
 Restores the value of this variable from the given Stream. More...
 
template<>
void Deserialize (cf::Network::InStreamT &Stream)
 Restores the value of this variable from the given Stream. More...
 
template<>
void Deserialize (cf::Network::InStreamT &Stream)
 Restores the value of this variable from the given Stream. More...
 
template<>
void Deserialize (cf::Network::InStreamT &Stream)
 Restores the value of this variable from the given Stream. More...
 
- 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::VarT< T >

This is a "wrapper" around a normal C++ variable.

It can be used in place of a normal 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.

User code can derive from this class and override the Set() method in order to customize the behaviour.

See Also
TypeSys Variables Overview

Constructor & Destructor Documentation

template<class T>
cf::TypeSys::VarT< T >::VarT ( const char *  Name,
const T &  Value,
const char *  Flags[] = NULL 
)
inline

The constructor.

Member Function Documentation

template<>
void cf::TypeSys::VarT< Vector2fT >::Deserialize ( cf::Network::InStreamT Stream)
virtual

Restores the value of this variable from the given Stream.

See Serialize() for additional details.

Implements cf::TypeSys::VarBaseT.

template<>
void cf::TypeSys::VarT< Vector3fT >::Deserialize ( cf::Network::InStreamT Stream)
virtual

Restores the value of this variable from the given Stream.

See Serialize() for additional details.

Implements cf::TypeSys::VarBaseT.

template<>
void cf::TypeSys::VarT< Vector3dT >::Deserialize ( cf::Network::InStreamT Stream)
virtual

Restores the value of this variable from the given Stream.

See Serialize() for additional details.

Implements cf::TypeSys::VarBaseT.

template<>
void cf::TypeSys::VarT< BoundingBox3dT >::Deserialize ( cf::Network::InStreamT Stream)
virtual

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::VarT< T >::Deserialize ( Network::InStreamT Stream)
virtual

Restores the value of this variable from the given Stream.

See Serialize() for additional details.

Implements cf::TypeSys::VarBaseT.

template<class T>
const T& cf::TypeSys::VarT< T >::Get ( ) const
inline

Returns the value of this variable.

template<class T>
virtual void cf::TypeSys::VarT< T >::GetChoices ( ArrayT< std::string > &  Strings,
ArrayT< T > &  Values 
) const
inlinevirtual

This method returns a list of acceptable input values for this variable, along with a string representation of each.

The relevancy of the returned tuples is limited: They are intended to create helpful user interfaces in our graphical editors and to provide extra information in scripts, but if Set() is called with a value that is not in Values, it will work and is not an error. If the method returns no tuples at all, it means that user input is free and any value is acceptable.

Reimplemented in cf::GuiSys::ComponentTextT::VarTextAlignVerT, cf::GameSys::ComponentMoverT::VarTrajFuncT, cf::GuiSys::ComponentTextT::VarTextAlignHorT, cf::GameSys::ComponentMoverT::VarOtherEntitiesT, cf::GameSys::ComponentMoverT::VarDestActivatedT, cf::GuiSys::ComponentTextT::VarFontNameT, and cf::GameSys::ComponentPointLightT::VarShadowTypeT.

template<>
void cf::TypeSys::VarT< Vector2fT >::Serialize ( cf::Network::OutStreamT Stream) const
virtual

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.

template<>
void cf::TypeSys::VarT< Vector3fT >::Serialize ( cf::Network::OutStreamT Stream) const
virtual

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.

template<>
void cf::TypeSys::VarT< Vector3dT >::Serialize ( cf::Network::OutStreamT Stream) const
virtual

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.

template<>
void cf::TypeSys::VarT< BoundingBox3dT >::Serialize ( cf::Network::OutStreamT Stream) const
virtual

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.

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

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.

template<class T>
virtual void cf::TypeSys::VarT< T >::Set ( const T &  v)
inlinevirtual

Sets the value of this variable to the given value v.

Derived classes can override this method to add "side-effects", such as updating graphical resources. In some cases, side-effects can even affect other variables (siblings). For example, setting a new model name in ComponentModelT not only updates the internal (private) model resource, but it can also imply updates (resets or clamps) to the animation and skin number variables.

Reimplemented in cf::GuiSys::ComponentTextT::VarFontNameT.


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