Choosing a design pattern for a class that might change it's internal attributes

Posted by the_drow on Stack Overflow See other posts from Stack Overflow or by the_drow
Published on 2010-04-30T02:29:38Z Indexed on 2010/04/30 2:37 UTC
Read the original article Hit count: 224

I have a class that holds arbitrary state and it's defined like this:

class AbstractFoo
{
};

template <class StatePolicy>
class Foo : public StatePolicy, public AbstractFoo
{
};

The state policy contains only protected attributes that represent the state.
The state might be the same for multiple behaviors and they can be replaced at runtime.
All Foo objects have the same interface to abstract the state itself and to enable storing Foo objects in containers.
I would like to find the least verbose and the most maintainable way to express this.

© Stack Overflow or respective owner

Related posts about c++

Related posts about design-patterns