This operation creates an entity instance and optionally set the specified attribute values of the created instance in a remote model. This function implements the same functionality as edmiRemoteCreateInstanceAndPutAttrs, but uses buffers in stead of a variable argument list to transfere attribute values.
This operation is only applicable to data models.
Related functions: edmiRemoteCreateInstanceAndPutAttrs, edmiRemoteCreateInstanceAndPutAttrsBN, edmiRemoteCreateInstanceAndPutAttrsBNEx
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteCreateInstanceAndPutAttrsEx(SdaiServerContext serverContextId,
SdaiModel remoteModelId,
SdaiEntity entityId,
SdaiInteger attributes,
SdaiAttr attributeIds[],
SdaiSelect attributeValues[],
SdaiOptions options,
SdaiAppInstance *newInstanceId,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
remoteModelId |
The numeric modelID that uniquely identifies the edmModel in the remote _EDMdatabase_ in which the instance is to be created. |
entityId |
The numeric entityID that uniquely identifies the entity definition instance in the dictionary model within the remote _EDMdatabase{_}. |
attributes |
The number of attribute values given in the variable argument list <values>. |
attributeIds |
A buffer containing the attributeIds of all the attributes to assign values to. |
attributeValues |
A buffer of pointers to tSdaiSelect structures. Each structure defines the type and value to be assigned to the attribute with the name given by the element of <attributeNames> with the same buffer position. |
options |
Currently not used. |
newInstanceId |
A variable that will receive a numeric instanceID that uniquely identifies the created instance in the remote EDMdatabase. |
edmiInvocationId |
Currently not used. |
Options: Descriptions:
|
|
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an _EDMinterface_ error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
EdmiError rstat;
SdaiServerContext myContext;
SdaiInstance instId;
SdaiModel modelId;
SdaiEntity entityId;
SdaiString name = "Lucy Scmidt";
SdaiAttr attrIds[4];
tSdaiSelect sel[4], *ps;
SdaiSelect attrVals[4] = {&sel[0], &sel[1], &sel[2], &sel[3]};
/* Create Server Context */
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Get the model Id */
rstat = edmiRemoteGetModelBN(myContext, "DataRepository",
"MySocialNetwork", &modelId, NULL);
/* Get the entity Id */
rstat = edmiRemoteGetEntity(myContext, modelId,
"PERSON", &entityId, NULL);
/* Get the attribute Ids */
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "SocialNetwork",
"Person", "NAME", &attrIds[0], NULL);
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "SocialNetwork",
"Person", "AGE", &attrIds[1], NULL);
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "SocialNetwork",
"Person", "WEIGHT", &attrIds[2], NULL);
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "SocialNetwork",
"Person", "MARRIED", &attrIds[3], NULL);
/* The NAME attribute */
ps = attrVals[0];
ps->nTypes = 0;
ps->typeList = NULL;
ps->type = sdaiSTRING;
ps->value.stringVal = name;
/* The AGE attribute */
++ps;
ps->nTypes = 0;
ps->typeList = NULL;
ps->type = sdaiINTEGER;
ps->value.intVal = 32;
/* The WEIGHT attribute */
++ps;
ps->nTypes = 0;
ps->typeList = NULL;
ps->type = sdaiREAL;
ps->value.realVal = 59.5;
/* The MARRIED attribute */
++ps;
ps->nTypes = 0;
ps->typeList = NULL;
ps->type = sdaiBOOLEAN;
ps->value.boolVal = sdaiFALSE;
/* Add lucy to my social network */
rstat = edmiRemoteCreateInstanceAndPutAttrsEx(myContext,
modelId, entityId, 4, attrIds, attrVals,
0, &instId, NULL);
. . .