VISH
0.2
|
This is an experimental class to easy creation of context-relative object states. More...
#include </home/werner/origo/vish/ocean/plankton/VObjectState.hpp>
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.