C# Class Antmicro.Migrant.ObjectIdentifier

Gives consecutive, unique identifiers for presented objects during its lifetime. Can also be used to retrive an object by its ID.
The first returned id is 0. For given object, if it was presented to the class earlier, the previously returned identificator is returned again. Note that the objects presented to class are remembered, so they will not be collected until the ObjectIdentifier lives.
Datei anzeigen Open project: antmicro/Migrant Class Usage Examples

Public Methods

Method Description
Clear ( ) : void

Clears internal elements.

GetContext ( ) : Antmicro.Migrant.ObjectIdentifierContext

Gets the context of object identifier that can be used for open stream serialization.

GetId ( object o ) : int

For a given object, returns its unique ID. The new ID is used if object was not presented to this class earlier, otherwise the previously returned is used.

GetId ( object o, bool &isNew ) : int

For a given object, returns its unique ID. The new ID is used if object was not presented to this class earlier, otherwise the previously returned is used.

GetObject ( int id ) : object

For an ID which was previously returned by the Antmicro.Migrant.ObjectIdentifier.GetId(object, out bool) method, returns an object for which this ID was generated.

ObjectIdentifier ( ) : System

Initializes a new instance of the Antmicro.Migrant.ObjectIdentifier class.

ObjectIdentifier ( Antmicro.Migrant.ObjectIdentifierContext context ) : System

Initializes a new instance of the Antmicro.Migrant.ObjectIdentifier class, reusing given context.

SetIdentifierForObject ( object o, int id ) : void

Sets new identifier for object. REMARK: Setting new mapping of object to id does not remove the old one. As a reuslt, after this operation asking for id of old object and new object results in returing the same identifier. This behaviour is intended to support surrogated objects.

this ( int id ) : object

For an ID which was previously returned by the Antmicro.Migrant.ObjectIdentifier.GetId(object, out bool) method, returns an object for which this ID was generated.

Method Details

Clear() public method

Clears internal elements.
public Clear ( ) : void
return void

GetContext() public method

Gets the context of object identifier that can be used for open stream serialization.
public GetContext ( ) : Antmicro.Migrant.ObjectIdentifierContext
return Antmicro.Migrant.ObjectIdentifierContext

GetId() public method

For a given object, returns its unique ID. The new ID is used if object was not presented to this class earlier, otherwise the previously returned is used.
public GetId ( object o ) : int
o object /// An object to give unique ID for. ///
return int

GetId() public method

For a given object, returns its unique ID. The new ID is used if object was not presented to this class earlier, otherwise the previously returned is used.
public GetId ( object o, bool &isNew ) : int
o object /// An object to give unique ID for. ///
isNew bool /// Out parameter specifying if returned id has just been generated. ///
return int

GetObject() public method

For an ID which was previously returned by the Antmicro.Migrant.ObjectIdentifier.GetId(object, out bool) method, returns an object for which this ID was generated.
public GetObject ( int id ) : object
id int /// The unique ID, previously returned by the method. ///
return object

ObjectIdentifier() public method

Initializes a new instance of the Antmicro.Migrant.ObjectIdentifier class.
public ObjectIdentifier ( ) : System
return System

ObjectIdentifier() public method

Initializes a new instance of the Antmicro.Migrant.ObjectIdentifier class, reusing given context.
public ObjectIdentifier ( Antmicro.Migrant.ObjectIdentifierContext context ) : System
context Antmicro.Migrant.ObjectIdentifierContext Context to reuse.
return System

SetIdentifierForObject() public method

Sets new identifier for object. REMARK: Setting new mapping of object to id does not remove the old one. As a reuslt, after this operation asking for id of old object and new object results in returing the same identifier. This behaviour is intended to support surrogated objects.
public SetIdentifierForObject ( object o, int id ) : void
o object Object
id int Identifier
return void

this() public method

For an ID which was previously returned by the Antmicro.Migrant.ObjectIdentifier.GetId(object, out bool) method, returns an object for which this ID was generated.
public this ( int id ) : object
id int /// The unique ID, previously returned by the method. ///
return object