Zen API
|
kStatus kObject_Clone | ( | kObject * | object, |
kObject | source, | ||
kAlloc | objectAllocator, | ||
kAlloc | valueAllocator, | ||
kObject | context = kNULL |
||
) |
Constructs a new object by copying an existing object, including any aggregated child elements.
If the source object is an object collection (e.g. kArrayList<kString>), any aggregated child objects are also cloned. In this case, the kObject_Dispose method can be used to free the cloned collection and its associated elements.
This method will fail if the source object (or an aggregated child element) does not support cloning.
The valueAllocator argument can be used to specify a separate memory allocator to be used for for value-array allocations. This feature can be used to allocate primitive arrays with special requirements (e.g., Cuda device memory). Support for this feature is typically provided only by classes that implement contiguous array-based collections (e.g., kArray2); other classes will ignore the valueAllocator argument and use the objectAllocator argument for all allocations. Collections that do support the valueAllocator agument will only use this allocator when allocating primitive value arrays; reference arrays (e.g., kArray2<kObject>) will be allocated with the objectAllocator argument. Consult the documentation for individual collections classes to determine whether separate valueAllocator arguments are supported.
To support cloning, derived classes should override the kObject_VClone method.
object | Receives the constructed object. |
source | Source object. |
objectAllocator | Object memory allocator (or kNULL for default). |
valueAllocator | Value memory allocator (or kNULL for default). |
context | Context for copy operation (allocator specific; not usually required). |