Clone
TheClonemethod clones the specified persistent object or storage unit.
ODID Clone (in ODDraftKey key, in ODID fromObjectID, in ODID toObjectID, in ODID scope);
key- The draft key of the current cloning transaction.
fromObjectID- The ID of the persistent object or storage unit to be cloned.
toObjectID- The ID of the destination persistent object or storage unit, or
kODNULLIDto create a new storage unit in the destination draft.scope- The ID of the frame that defines the scope of this cloning operation.
- return value
- The ID of the destination persistent object or storage unit. (The ID of a persistent object is the same as the ID of its storage unit.)
DISCUSSION
The following summary describes how to use theClonemethod.
The
- You start a cloning transaction by calling this draft object's
BeginClonemethod, which returns the draft key identifying the cloning transaction.- Next, call this draft object's
Clonemethod, passing as parameters the draft key returned by theBeginClonemethod, the ID of the object to be cloned, the ID of the destination storage unit, and the frame object specifying the scope.- Finally, call this draft object's
EndClonemethod, passing as a parameter the draft key returned by theBeginClonemethod. TheEndClonemethod commits the cloning transaction and performs the data transfer.
keyparameter is the draft key of the current cloning transaction, which was returned by a call to this draft object'sBeginClonemethod and passed to the calling object'sCloneIntomethod.The
fromObjectIDparameter identifies the object to be cloned. If a persistent object exists with the specified ID, that persistent object is cloned; otherwise, the storage unit with the specified ID is cloned.The
toObjectIDparameter specifies the ID of the destination storage unit. If thetoObjectIDparameter is null, a new destination storage unit is created in the destination draft.If the object being cloned has persistent references to other objects, the
scopeparameter determines which of the referenced objects are within the scope of this cloning operation. Typically, thescopeparameter is the ID of a frame and only those objects embedded in that frame are within scope. In the rare case in which thescopeparameter iskODIDAll, all referenced objects are within scope.This method passes its
keyparameter, the destination storage unit, and itsscopeparameter to theCloneIntomethod of the persistent object or storage unit being cloned. If that persistent object or storage unit has persistent references, itsCloneIntomethod clones any persistently referenced objects that are within the scope of this cloning operation. Objects referenced by strong persistent references are strongly cloned by recursive calls to theClonemethod; objects referenced by weak persistent references are weakly cloned by calls to theWeakClonemethod.You must not use the returned ID until the end of the current cloning transaction. Furthermore, before you try to access the persistent object or storage unit with the corresponding ID, you must call the
IsValidIDmethod to verify that the ID is still valid.EXCEPTIONS
kODErrInvalidDraftKey- The specified draft key is not the draft key for the current cloning transaction.
kODErrInvalidID- The
toObjectIDparameter did not specify a valid destination object or storage unit.SEE ALSO
TheODDraftKeytype (page 902).
TheODIDtype (page 899).
TheODDraft::AbortClonemethod (page 151).
TheODDraft::BeginClonemethod (page 159).
TheODDraft::EndClonemethod (page 171).
TheODDraft::IsValidIDmethod (page 175).
TheODDraft::WeakClonemethod (page 185).
TheODPersistentObject::CloneIntomethod (page 557).
TheODStorageUnit::CloneIntomethod (page 673).
"Clone" on page 323 in OpenDoc Programmer's Guide.
"The CloneInto Method of Your Part Editor" on page 327 in OpenDoc Programmer's Guide.