Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »


 
This operation creates an entity instance and optionally set the specified attribute values of the created instance. Hence this operation is a combination of sdaiCreateInstance../../../SDAI_C_Binding_Reference/Functions/sdaiPutAttrs.htm">sdaiPutAttrs operations.
This operation is only applicable to data models.
The actual data model must be open for write access, before this operation can be successfully performed.
Related functions:
 edmiCreateInstanceAndPutAttrsBN , sdaiCreateInstance , sdaiPutAttrs
Header:
#include "sdai.h"
Prototype:
SdaiAppInstance edmiCreateInstanceAndPutAttrs(SdaiModel         model, 
                                               SdaiEntity        entity, 
                                               SdaiInteger       numberAttr, 
                                               /* [SdaiAttr      attribute, 
                                               SdaiPrimitiveType valueType, 
                                               void              attributeValue]*/ 
                                                . . .); /* values */ 
Arguments:

model

A numeric modelID that uniquely identifies the model in the EDMdatabase in which the instance is created.

entity

A numeric entityID that uniquely identifies an entity definition instance in a dictionary model in the EDMdatabase. This entity definition must be defined in the underlying schema of the actual model specified by the <model> argument.
The entityID is returned by the sdaiGetEntity function.

numberAttr

An integer number that specifies the number of attribute values to put in the operation.

values

For each attribute value to assign the three following arguments in the following order have to be specified:

  1. <attribute>: A numeric identifier that uniquely identifies an attribute definition instance in the EDMdatabase, hence defines the attribute within the specified instance to assign the specified value to. The attributeID is returned from the sdaiGetAttrDefinition and sdaiGetAttrDefinitionBN functions.
  2. <valueType> : The specified primitive type <valueType> must be the same or a compatible data type of the actual attribute domain as defined in the attribute declaration in the related EXPRESS schema.

    All data types except sdaiAGGR can be handled by this operation. Aggregates cannot be assigned as attribute data value by this operation. Aggregates must be assigned to attributes by either sdaiCreateAggr or sdaiCreateAggrBN operations. The primitive type sdaiSELECT can be used to write all data types. The primitive type sdaiADB can be used to write all data types except typed values.
    The primitive type sdaiINTEGER is compatible with sdaiREAL, and sdaiBOOLEAN is compatible with sdaiLOGICAL, hence conversion between these compatible data types will be performed when required.
    An aggregate, i.e. data type sdaiAGGR is illegal in this operation.
  3. <attributeValue>: The data value to assign to the actual attribute in the specified instance. The type of <attributeValue>must be the same as specified in the <valueType> argument.

Returns:
A numeric instanceID that uniquely identifies the new created entity instance in the EDMdatabase. This instanceID should be used to identify the particular instance for subsequent EDMinterface operations.
instanceID != 0 : operation successfully performed.
instanceID = 0 : operation failed, use sdaiErrorQuery function to get error reason.
EXAMPLE
SdaiAppInstance myPoint;
SdaiEntity pointId;
SdaiAttr xId, yId, zId;
SdaiModel model;
...
myPoint = edmiCreateInstanceAndPutAttrs(model,
pointId, 
3, 
xId, sdaiREAL, 0.0, 
yId, sdaiREAL, 0.0, 
zId, sdaiREAL, 0.0); 
if (! myPoint) {
/* Error in operation */ 
printf("\nError in edmiCreateInstanceAndPutAttrs: %s\n", 
edmiGetErrorText(sdaiErrorQuery())); 
goto error; 
}
...

  • No labels