Determines whether an instance is of a specified instance type or of any subtype of this instance type. The instance type is identified by its unique entityId.
This operation returns sdaiTRUE if the specified instance is of the specified instance type or a subtype of this instance type, else sdaiFALSE is returned.
Related function: edmiRemoteIsKindOfBN
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteIsKindOf(SdaiServerContext serverContextId,
SdaiInstance instanceId,
SdaiEntity entityId,
SdaiBoolean *isKindOf,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
instanceId |
A numeric instanceID that uniquely identifies the instance of interrest in the remote _EDMdatabase{_}. |
entityId |
A numeric entityID that uniquely identifies an entity definition instance in a dictionary model in the remote _EDMdatabase{_}. |
isKindOf |
A variable that will receive sdaiTRUE if the instanceId given in argument <instanceId> is of an instance type equal to that given in argument <entityId> or to any of its subtypes. If there is no such type relation, sdaiFALSE will be returned. |
edmiInvocationId |
Currently not used. |
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:
/*
SCHEMA Relations
ENTITY Person;
PID : INTEGER;
Name : STRING;
END_ENTITY;
ENTITY Man SUBTYPE OF Person;
. . .
HasBeard : BOOLEAN;
. . .
END_ENTITY;
ENTITY Woman SUBTYPE OF Person;
. . .
IsVirgin : BOOLEAN;
. . .
END_ENTITY;
END_SCHEMA;
*/
int i;
EdmiError rstat;
SdaiInteger nPerson, nTot;
SdaiServerContext myContext;
SdaiAggr personAggr;
SdaiInstance *personBuff;
SdaiEntity manEID, womanEID;
SdaiBoolean isKindOfWoman, isKindOfMan;
SdaiPrimitiveType personType;
SdaiModel modelId;
/* Define Remote Server Context */
rstat = edmiDefineServerContext("MyRemoteServerContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Get the id of the model MyRelations */
rstat = edmiRemoteGetModelBN(myContext, "JohnnysRepository",
"MyRelations", &modelId, NULL);
/* Get Man entity Id */
rstat = edmiRemoteGetEntity(myContext,
modelId, "MAN", &manEID, NULL);
/* Get Person entity Id */
rstat = edmiRemoteGetEntity(myContext,
modelId, "WOMAN", &womanEID, NULL);
/* Get all persons */
rstat = edmiRemoteGetEntityExtentBN(myContext, "JohnnysRepository",
"MyRelations", "PERSON", SUBTYPES,
&personAggr, &nPerson, &nTot, NULL);
rstat = edmiRemoteReadAggrElements(myContext, personAggr,
0, 0, nPerson, &nPerson, &personType,
NULL, &personBuff, NULL);
for (i=0;i<nPerson;i++) {
rstat = edmiRemoteIsKindOf(myContext, personBuff[i],
manEID, &isKindOfMan, NULL);
rstat = edmiRemoteIsKindOf(myContext, personBuff[i],
womanEID, &isKindOfWoman, NULL);
if (isKindOfMan) {
/* Shave all the men */
rstat = edmiRemotePutAttrsBN(myContext, personBuff[i], 1, NULL,
"HASBEARD", sdaiBOOLEAN, sdaiFALSE);
} else if (isKindOfWoman) {
/* Defile all the women */
rstat = edmiRemotePutAttrsBN(myContext, personBuff[i], 1, NULL,
"ISVIRGIN", sdaiBOOLEAN, sdaiFALSE);
}
}
. . .