Instance naming


There are several ways to name an instance in EDMexpressX. Naming an instance means that an instance can be given a name, i.e. a key. This key can be a string, an integer, or another instance. There exist several built in functions that uses fast lookup tables to find a particular instance by using the instance name (key).
The following pairs of built in functions are available for instance naming and instance retrieval based on the instance name:
xpxMapInstance(target_instance, source_instance : GENERIC) : iNTEGER;
xpxGetSourceInstance(TargetInstance, VAR SourceInstance: GENERIC) :INTEGER;
xpxGetTargetInstance(SourceInstance, VAR targetInstance: GENERIC) :INTEGER;
 
The function xpxMapInstance is used to name a source instance by a target instance and vice versa. The functions xpxGetSourceInstance and xpxGetTargetInstance can later be used to retrieve the source instance by specifying the related target instance as argument, and retrieve the target instance by specifying the related source instance as argument, respectively. The xpxGetSourceInstance and xpxGetTargetInstance will return a generic value being the actual instance in the last argument in case a related instance is found and return zero in the last argument when no related instance is found.
xpxMapString (MapTableIndex : INTEGER; instanceName : STRING;
       anInstance : GENERIC) : INTEGER;
xpxGetStringMap(MapTableIndex : INTEGER; instanceName : STRING,
       VAR anInstance : GENERIC) : INTEGER;
xpxMapInteger(MapTableIndex, instanceName : INTEGER;
      anInstance : GENERIC) : INTEGER;
xpxGetIntegerMap(MapTableIndex, instanceName : INTEGER,
      VAR anInstance : GENERIC) : INTEGER;
 
The function xpxMapString is used to name an instance by a string and the function xpxGetStringMap can be used to retrieve an instance by a string name. The xpxMapInteger and xpxGetIntegerMap is used in the same way except that the instance name is an integer.
It is possible to give different instances the same name, but then it is necessary to use more than one mapping table. The first argument "MapTableIndex" is used to specify the actual mapping table the functions should operate on. The "MapTableIndex" is an integer starting with 1 for the first mapping table. The number of mapping tables in an EDMmodelConverter is configurable by the user.
The functions xpxMapString and xpxMapInteger will return a INTEGER value that is a completion code. This code is zero when the function is performed successfully , otherwise an error code will be returned. The functions xpxGetStringMap and xpxGetIntegerMap will return an instanceId in the last argument that is named by the string or the integer given as arguments in the function calls. If the returned instanceId should be assigned to an identifier, this identifier has to be the same type as the actual returned instance or a subtype of this instance, or the identifier can be of type GENERIC.