Public Member Functions | Protected Member Functions

HClonable Class Reference
[Common]

This class defines an interface for cloning instances of polymorphic classes. More...

#include <HClonable>

Inheritance diagram for HClonable:
HControlPointConfiguration HDeviceConfiguration HDeviceHostConfiguration HDeviceModelCreator HDeviceModelInfoProvider

List of all members.

Public Member Functions

 HClonable ()
virtual ~HClonable ()
virtual HClonableclone () const

Protected Member Functions

virtual void doClone (HClonable *target) const
virtual HClonablenewInstance () const =0

Detailed Description

Remarks:
This class is thread-safe.

Constructor & Destructor Documentation

HClonable (  )

Creates a new instance.

~HClonable (  ) [virtual]

Destroys the instance.


Member Function Documentation

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".
 }
Parameters:
targetspecifies 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();
 }
Remarks:
  • the object has to be heap-allocated and
  • the ownership of the object is passed to the caller.

Implemented in HControlPointConfiguration, HDeviceConfiguration, and HDeviceHostConfiguration.

HClonable * clone (  ) const [virtual]

Returns a deep copy of the instance.

Returns:
a deep copy of the instance.
Remarks:
  • the ownership of the returned object is transferred to the caller.

Reimplemented in HControlPointConfiguration, HDeviceConfiguration, HDeviceHostConfiguration, HDeviceModelInfoProvider, and HDeviceModelCreator.