Special object instance service functions
There are some update functions, which are difficult to implement in an application and which requires deep knowledge about the system. Thus, the following functions have been provided as additional service functions.
Sometimes, object instances are considered as having a name (usually the primary key). Usually, the name can be changed by changing the appropriate key component attributes. In order to provide generic rename facilities, which works without knowledge of key component attributes, rename() might be called.
Generic key update is also provided by different key functions (Key(), accessKey(), primaryKey() or currentKey()).
In order to create a duplicate of an instance in a collection, duplicate() might be called. The function works similar as the copy() function, but within the same collection.Moreover, the function maintains auto numbers (__AUTOIDENT) when being defined as index key.
Moving an instance is supported, since this is difficult to achieve without special support. Moving an instance from one collection to another one will maintain the instance identity, i.e it is still the same instance, which is stored in the new collection.
Moving instances is the only way of transferring instances from an owning or depending collection to another collection. When moving an instance, it will be removed completely from its set hierarchy, i.e. not only from the current collection, but also from all its supersets. The instance will also be removed from all subset, but not inserted to subsets of the target collection. Afterwards, it will be inserted to the set hierarchy for the target collection, i.e. to the target collection and all its supersets.
Typically, move() is called in drag and drop move actions in order to move an instance within an application but also between applications or even different databases. When moving an instance between different databases or object spaces, the instance identity (LOID) will change.
Moving instances up and down in a collection is, usually, a matter of changing key values. This has to be done by the application programmer. In unordered collections, however, moving up and down cannot be achieved by changing key values.
moveUp() and moveDown() provide the facility of moving instances in an unordered collection. Besides, you may call these functions for collections with an auto-number index (__AUTOIDENT). In the last case, the automatic number assigned to the instances will changed by the function in order to reposition the instance in the collection.
// move down count rows
... fragment ( Property &cars, int count ) {
changeAccessKey("ik_AUTOIDENT");
if ( cars.positioned() )
while ( count-- > 0 )
cars.moveDown();
}