Herqq
|
This class defines an interface for cloning instances of polymorphic classes. More...
#include <HClonable>
Public Member Functions | |
HClonable () | |
virtual | ~HClonable () |
virtual HClonable * | clone () const |
Protected Member Functions | |
virtual void | doClone (HClonable *target) const |
virtual HClonable * | newInstance () const =0 |
This class defines an interface for cloning instances of polymorphic classes.
HClonable | ( | ) |
Creates a new instance.
virtual ~HClonable | ( | ) | [virtual] |
Destroys the instance.
virtual void doClone | ( | HClonable * | target | ) | const [protected, virtual] |
Clones the contents of this to the target
object.
Every derived class that introduces member variables that should be copied as part of a cloning operation should override this method. The implementation should be something along these lines:
void MyClonable::doClone(HClonable* target) const { MyClonable* myClonable = dynamic_cast<MyClonable*>(target); if (!myClonable) { return; } BaseClassOfMyClonable::doClone(target); // copy the variables introduced in *this* MyClonable // instance to "myClonable". }
target | specifies the target object to which the contents of this instance are cloned. |
Reimplemented in HControlPointConfiguration, HDeviceConfiguration, and HDeviceHostConfiguration.
HDeviceHostConfiguration * newInstance | ( | ) | const [protected, pure virtual] |
Creates a new instance.
This method is used as part of object cloning. Because of that, it is important that every concrete (non-abstract) descendant class overrides this method regardless of the type location in the inheritance tree:
MyClonable* MyClonable::newInstance() const { return new MyClonable(); }
Implemented in HControlPointConfiguration, HDeviceConfiguration, and HDeviceHostConfiguration.
virtual HClonable* clone | ( | ) | const [virtual] |
Returns a deep copy of the instance.
Reimplemented in HControlPointConfiguration, HDeviceConfiguration, HDeviceHostConfiguration, HDeviceModelInfoProvider, and HDeviceModelCreator.