Modeling Services > Dynamic Modeling Services > How to Use Dynamic Objects > Identified Objects
 
Identified Objects
An identified object is an object that has an identifier of type string as one of its attributes. This object type is declared to the server model interpreter by the macro ILS_OBJECT_WITH_ID_BEGIN or by means of the identifier Server property for a dynamic model.
When you work with dynamic modeling services, identified objects can be stored in a dictionary or a dynamic relation implemented as a set relation.
An identified object can be given an identifier at creation time:
*If it is built from a script function, this identifier can be passed to the object constructor.
*If the object is built from the function IlsDynObject::NewInstance, the identifier can be provided as an argument.
*When the object is built from a component request, the identifier value should be passed during that same component-to-server transaction.
When the useDictionary property is set for a dynamic type, instances of this type are stored in a global dictionary when they are built. Instances of such a type must be built with a non-null identifier. These instances can be retrieved using the static member function IlsDynObject::GetInstance or the Rogue Wave® Script method MvServer.GetInstance.
If you have defined the identifier of a dynamic class as a C++ data member and you want to store objects of this type in a dictionary, you must provide a setIdentifier method (see Example) so that the object is registered in the dictionary when created. If the identifier attribute is a static attribute (that is, an attribute declared as a C++ data member of a static type), and if your subtype inherits from IlsDynObject, you must notify IlsDynObject each time you change the value of the identifier, so as to maintain consistency within the dynamic set relations or dictionaries that store this object. Call the member function IlsDynObject::beforeRename before assigning the new identifier value to the identifier attribute and IlsDynObject::afterRename after having done so.
Example
IlsBoolean Network::setIdentifier(const IlsString& i)
{
IlsString oldValue = identifier.getValue();
identifier = i;
beforeRename(oldValue, i);
afterRename(oldValue, i);
return IlsTrue;
}
Notes:  
1. If you have declared an identifier attribute, you must specify the identifier value when calling the initObject function.
2. If you have subtyped an identified object type and you have defined an identifier attribute on the base type, you do not need to redeclare it on the subtype.
Important: When a dynamic object is to be stored in a dictionary or a set relation, its identifier must not be null.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.