e4_UniqueID and SubTypes
Author: Jacob Levy

Type-Safe Unique Identifiers

e4Graph entities are identified by type-safe unique identifiers that are guaranteed to be unique in the storage containing the entity. These unique identifiers can be compared to determine if the corresponding entities are the same. They can also be used to retrieve the corresponding entity from its storage using e.g. e4_Storage::GetNodeFromID().

Unique identifiers are valid only while the storage containing the represented instance is open. When the storage is closed or goes out of scope, and is later reopened, any retained unique identifiers for entities within that storage may no longer be valid. If the storage is reopened and a unique identifier is obtained for the same entity as represented by a retained unique identifier, the operator == may return false even though the old and new unique identifier represent the same entity.

All unique identifier types inherit from class e4_CommonUniqueID. The following classes are defined:

Unique Identifier Classes Provided in e4Graph:
e4_CommonUniqueID | Not directly manipulated by application programs using e4Graph
e4_NodeUniqueID | Represents a unique identifier for a node; returned by e4_Node::GetUniqueID()
e4_VertexUniqueID | Represents a unique identifier for a vertex; returned by e4_Vertex::GetUniqueID()

All unique identifier classes provide the same operations, described here for e4_CommonUniqueID.

Constructors and Methods of e4_CommonUniqueID:
e4_CommonUniqueID() | Constructor.
e4_CommonUniqueID(const e4_CommonUniqueID &referrer) | Constructor. The state of the new instance is the same as the state of referrer.
e4_CommonUniqueID(int uid, e4_Storage s) | Constructor. Constructs a unique identifier that identifies the entity with that serial number within the given storage. Serial numbers are internal to the implementation of e4Graph.
e4_CommonUniqueID &operator=(const e4_CommonUniqueID &referrer) | Assignment operator. After its invocation, this unique identifier has the same state as the referrer argument.
~e4_CommonUniqueID() | Destructor.
bool operator==(const e4_CommonUniqueID &compared) const | Returns true if compared and this instance represent the same e4Graph entity, false otherwise.
bool operator!=(const e4_CommonUniqueID &compared) const | Returns true if compared and this instance represent different e4Graph entities, and false if they represent the same entity.
bool IsAssigned() const | Returns true if this unique identifier represents an actual entity within some storage, false otherwise.
operator int() const | Returns the serial number for the entity represented by this unique identifier. Serial numbers are internal to the implementation of e4Graph. If the unique identifier does not represent any specific instance (it is not assigned) then the constant E4_INVALIDUNIQUEID is returned.
int GetUniqueID() const | Returns the serial number for the entity represented by this unique identifier. Serial numbers are internal to the implementation of e4Graph.
void SetUniqueID(int id, e4_Storage s) | Sets the unique identifier to represent the entity with the given s in the supplied storage. Serial numbers are internal to the implementation of e4Graph.