/* * ManipulableClone.hpp * * Created on: Jan 6, 2011 * Author: heber */ #ifndef MANIPULABLECLONE_HPP_ #define MANIPULABLECLONE_HPP_ /** \section (ManipulableClone Howto) * * Prototypes serves as templates in object creation, i.e. new objects are * created by coping the prototype. Therefore each prototypical type has to * implement a clone() function. Here, we go one step further: In order to * allow for changing member variables a clone contains which is not possible * by member functions but only through ythe constructor, you may instantiate * a ManipulableClone, i.e. implement a manipulatedclone(set) function which * uses a parameter struct \a set containing new values to be used in the * constructor call. * * By inheriting this pattern and implementing the clone function you make * sure that the prototypes, e.g. to be stored in a factory table, can be * safely copied (the factory just calls clone of the prototype) and can * be handed out by the abstract and common interface. * *

Howto class as follows: * * @code * class Prototype1 : * public IPrototype, * public ManipulableClone * { * public: * IPrototype clone() * { * ... do something to clone the class ... * }; * IPrototype clone(const ParameterSet &_params) * { * ... do something to clone the class ... * ... while using _params ... * }; * }; * @endcode * * Note that ParameterSet should be a structure containing public member * values. * */ template class ManipulableClone { public: virtual ~ManipulableClone() {}; virtual interface* clone() const = 0; virtual ManipulableClone* manipulatedclone(const parameterset &_parameters) const = 0; }; #endif /* MANIPULABLECLONE_HPP_ */