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 |
HClonable | ( | ) |
Creates a new instance.
~HClonable | ( | ) | [virtual] |
Destroys the instance.
void doClone | ( | HClonable * | target ) | const [protected, virtual] |
Clones the contents of this to the target
object.
Every derived class has to override this method. Further, 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.
virtual HClonable* 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 descendant class overrides this method:
MyClonable* MyClonable::newInstance() const { return new MyClonable(); }
Implemented in HControlPointConfiguration, HDeviceConfiguration, and HDeviceHostConfiguration.
HClonable * clone | ( | ) | const [virtual] |
Returns a deep copy of the instance.
Reimplemented in HControlPointConfiguration, HDeviceConfiguration, HDeviceHostConfiguration, HDeviceModelInfoProvider, and HDeviceModelCreator.