The %ListOfObjects class represents a list of references to objects,
each of which is associated with a numeric position in the list.
The first element in the list is stored at position 1.
The objects referred to must be registered.
They can be either persistent objects or non-id objects.
Internally, a %ListOfObjects object contains two lists:
one for holding the OID values for the objects referred to
(or their serialized state in the case of a list of non-id objects);
and another for holding the OREF values for any objects that have been
explicitly referred to, and hence "swizzled" into memory. Swizzling
(loading an object into memory and generating an OREF value for it)
happens automatically whenever the user refers to an object within the list.
For example, if list is an %ListOfObjects object containing a list of
Doctor objects (that is a list of OID values for Doctor objects stored
in the database) then the following code fragment will automatically load
the Doctor object at location 7 in the list into memory and generate an
OREF value referring to the in-memory version of the Doctor object.
This OREF value can then be used to access the properties and methods of the Doctor object:
Alternatively, we could use cascading dot syntax:
When the %ListOfObjects object is closed (removed from memory)
it will close (call %Close on) all the references it has swizzled into memory.
These classes can be used 'stand alone' to store a collection.
This parameter determines how the collection object stores OID values.
If this parameter is set to 0, then partially-formed OID values, containing only an ID number,
are used. If this parameter is set to 1, then fully-formed OID values, containing both a class
name and an ID number, are used.
parameter ELEMENTTYPE = %RegisteredObject;
The type (class name) of the elements stored in the collection.
Overrides %SerialObject implementation. Scans objects for modifications in the related list (Element)
and the terminated relationship list (DeleteOref). Modified/Scheduled to delete objects are added to
the save graph.
method %SerializeObject(ByRef serial As %Binary, partial As %Integer = 0) as %Status [ Language = objectscript ]
Inherited description: This method retrieves all of the serial values for referenced objects and places them into the instance variables,
Validates, Normalizes, and serializes the object (with a save of the persistent image if persistent).
This method is not meant to be called directly. It is called by %Save and by %GetSwizzleObject.
Removes the element at position key in the list.
The elements following position key are moved to fill in the resulting gap.
RemoveAt returns the OID value of the removed element or null string ("")
if no element was removed. It also has a success output argument that
returns true if the item was removed and false if it was not.