Copy property handles
When creating a copy for a property or value handle, the copy can be created on the access node level or on the handle level. An access node copy (cursorCopy()) creates a new and independent cursor (access node) for the same property. A handle copy creates a new property handle, which shares the cursor (access node) with its origin, i.e. original and copy handlerefer to the same property node and the state of the property handles is identical. Whatever is selected in the property original handle (see example HandleCopy() below) is selected in the handle copy, which refers to the same access node.
Access nodes have got a reference count and the access node will be destroyed when destroying the last handle referring to it.
In the CursorCopy() example, a new and independent access node is created and placed at the same position in the handle hierarchy as its origin.
void HandleCopy ( PropertyHandle &person ) {
Property p1(person); // passing handle pointer to get a handle copy
p1.get(0);
printf("Same instance s% = %s", p1.value("pid").toString(),
person.value("pid").toString());
p1.Close(); // cursor in p1 is still allive
person.Close(); // cursor is destroyed - last reference closed
}
void CursorCopy ( PropertyHandle &person ) {
Property p1;
p1.copyCursor(person); // get a cursor (access node) copy
person.Get(0);
p1.Get(1);
printf("Different instance s% = %s", p1.value("pid").toString(),
person.value("pid").toString());
person.Close(); // p1 cursor is destroyed - loosing its origin
}