The Vish Visualization Shell 0.3
Vish
Classes | Public Member Functions | List of all members
Wizt::VStateCreator< ObjectState > Struct Template Reference

This is an experimental class to easy creation of context-relative object states. More...

#include <ocean/plankton/VObjectState.hpp>

Inheritance diagram for Wizt::VStateCreator< ObjectState >:
Wizt::VStateCreatorBase

Classes

struct  MyState
 

Public Member Functions

RefPtr< VStateCreatorBase::StatenewState () const override
 Implementation of the virtual object state creation function.
 
- Public Member Functions inherited from Wizt::VStateCreatorBase
RefPtr< State > & getState (const WeakPtr< ValuePool > &VP) const
 Retrieve a pointer to a state object for the given context.
 
RefPtr< InterfaceBasehasLocalInterface (const type_info &InterfaceType) const
 Check whether any of the local object states has an interface of the given type.
 
RefPtr< StatemyState (const WeakPtr< ValuePool > &Context) const
 Retrieve a state for the current context, possibly creating one.
 
void setState (const WeakPtr< ValuePool > &, const RefPtr< State > &st) const
 Set a state object for a given context.
 

Detailed Description

template<class ObjectState>
struct Wizt::VStateCreator< ObjectState >

This is an experimental class to easy creation of context-relative object states.

The template parameter is a class providing local variables. Deriving from this class reliefs the child class from implementing the virtual newState() function. It is sufficient to derive a Vish object (virtually) from a VStateCreator<UserState> where UserState is a user-defined structure. It will be dynamically create by the newState() function.

Using this mechanism, the local state class must be defined before the derived Vish object is defined; the local state class cannot be a nested class. However, such classes may reside in an anonymous namespace if the Vish object is defined only within a .cpp file as well.

A problem with this class may occur when an a class hierarchy defines different local states, then it becomes unclear which implementation will be used for creating a state.