2.3.4. Object construction and destruction

Recall that TxCore objects can be recoverable; recoverable and persistent; or neither. Additionally each object possesses a unique internal name. These attributes can only be set when that object is constructed. Thus LockManager provides two protected constructors for use by derived classes, each of which fulfils a distinct purpose:
LockManager ()
This constructor allows the creation of new objects, that is, no prior state is assumed to exist.
LockManager (int ObjectType, ObjectName attr)
As above, this constructor allows the creation of new objects, that is, no prior state is assumed to exist. The ObjectType parameter determines whether an object is simply recoverable (indicated by RECOVERABLE); recoverable and persistent (indicated by ANDPERSISTENT) or neither (NEITHER). If an object is marked as being persistent then the state of the object will be stored in one of the object stores. The shared parameter only has meaning if it is RECOVERABLE; if attr is not null and the object model is SINGLE (the default behaviour) then the recoverable state of the object is maintained within the object itself (i.e., it has no external representation), otherwise an in-memory (volatile) object store is used to store the state of the object between atomic actions.
Constructors for new persistent objects should make use of atomic actions within themselves. This will ensure that the state of the object is automatically written to the object store either when the action in the constructor commits or, if an enclosing action exists, when the appropriate top-level action commits. Later examples in this chapter illustrate this point further.
LockManager(Uid objUid)
This constructor allows access to an existing persistent object, whose internal name is given by the objUid parameter. Objects constructed using this operation will normally have their prior state (identified by objUid) loaded from an object store automatically by the system.
LockManager(Uid objUid, ObjectName attr)
As above, this constructor allows access to an existing persistent object, whose internal name is given by the objUid parameter. Objects constructed using this operation will normally have their prior state (identified by objUid) loaded from an object store automatically by the system. If the attr parameter is not null, and the object model is SINGLE (the default behaviour), then the object will not be reactivated at the start of each top-level transaction.
The destructor of a programmer-defined class must invoke the inherited operation terminate to inform the state management mechanism that the object is about to be destroyed otherwise unpredictable results may occur.
Because LockManager inherits from StateManager, it will pass any supplied ObjectName instance to the StateManager class. As such, it is possible to set the StateManager object model as described earlier.