Herqq

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

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:

List of all members.

## Public Member Functions
| HClonable ()
virtual | ~HClonable ()
virtual HClonable * | clone () const
## Protected Member Functions
virtual void | doClone (HClonable *target) const
virtual HClonable * | newInstance () const =0

## Detailed Description

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

Remarks:
  This class is thread-safe.

## Constructor & Destructor Documentation

HClonable | ( |  | ) |

Creates a new instance.

virtual ~HClonable | ( |  | ) | `[virtual]`

Destroys the instance.

## Member Function Documentation

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".
     }

Parameters:

  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();
     }

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.

virtual 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.