Search a specified aggregate of instances in a remote edmModel for instances that match a specified condition. The condition must be a simple logical expression addressing only the simple type attribute values of the instance elements. A NULL or empty string condition will match all the aggregate elements.
Each matching element will be identified by its aggregate element index. Note that even though the ISO10303 standard specifies no such thing as an internal ordering of the elements within a bag and set type aggregate, the elements may still be indexed as long as the aggregates remain unchanged.
The index of the first aggregate element to check, and the maximum number of matching element indexes to return, are specified as input arguments to the function. The actual number of matching elements returned and the index of the last returned matching element in the aggregate will be returned from the function. This makes it possible to query through huge aggregates by means of a loop where each iteration handles small subset of the total aggregate. See the example below.
When the <maxBufferSize> argument is zero and the <resultBuffer> argument is NULL. Nothing but the number of matching aggregate elements will be returned.
Related functions: edmiRemoteFindAggrInstances, edmiRemoteFindInstancesBN
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteFindAggrInstances(SdaiServerContext serverContextId,
SdaiAggr aggregate,
SdaiString condition,
SdaiInteger maxBufferSize,
SdaiInteger *index,
SdaiInteger *numberOfHits,
SdaiInstance *resultBuffer,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
aggregate |
A numeric aggregateID that uniquely identifies the persistent aggregate of instances in the remote _EDMdatabase._ Scratch aggregates may also be used, but only when LOCAL_CONTEXT is specified in the <serverContextId> argument. |
condition |
The condition that the instance elements shall match. A NULL or empty string condition will match all the elements. The condition statement must be on the form "attribute = value" |
maxBufferSize |
The size of the buffer in which the indexes of all the matching aggregate elements will be returned. The number of returned indexes will never exceed this number. |
index |
In: The index of the aggregate element to start reading from. The first element is indexed zero. Hence the legal index range is: [ 0 <= index < N ] , where N is the number of elements in the aggregate. |
numberOfHits |
In: The maximum number of matching aggregate element indexes to return.If this number is greater than the limitation specified by the <maxBufferSize> argument, the maximum number of hits will be overruled by the value given in the <maxBufferSize> argument. |
resultBuffer |
A buffer, allocated by the calling application, that will receive the indexes of the matching aggregate elements. Use the <maxBufferSize> argument to prevent writing past the end of this buffer. |
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 Furniture
TYPE tScrewType = ENUMERATION OF (PHILIPS, ALLEN, FLAT); END_TYPE;
ENTITY screw;
ID : STRING;
TYPE : tScrewType;
LEN : REAL;
DIA : REAL;
END_ENTITY;
ENTITY dining_table;
Name : STRING;
Legs : INTEGER;
Length : REAL;
Width : REAL;
Height : REAL;
Screws : BAG OF screw;
END_ENTITY;
END_SCHEMA;
*/
#define S_BATCHSIZE 10
EdmiError rstat;
SdaiInteger nHits, index;
SdaiServerContext myContext;
SdaiInstance tableId;
SdaiAggr screwBagId;
SdaiQueryResult qexRes;
/* Create Server Context */
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Get the id of the dining table
with the unique name 'PIZA-210'
in the FURNITURE_DESIGN model. */
index = 0;
nHits = 1;
rstat = edmiRemoteSelectInstances(myContext, "DataRepository",
"FURNITURE_DESIGN", "DINING_TABLE", "NAME = 'PIZA-210'",
ONLY_INSTANCE_IDS, NULL, NULL, NULL,
&index, &nHits, &qexRes,
NULL, NULL, NULL, NULL);
tableId = qexRes->instanceIds[0];
edmiFreeQueryResult(qexRes);
/* Get the screw bag Id of the
dining table 'PIZA-210' */
rstat = edmiRemoteGetAttrsBN(myContext, tableId, 0, 1, NULL,
"SCREWS", sdaiAGGR, &screwBagId);
/* Find the number of screws of type
Allen 5mm x 75mm used for the
dining table 'PIZA-210' */
index = 0;
nHits = 1000;
rstat = edmiRemoteFindAggrInstances(myContext, screwBagId,
"(LEN=75) AND (DIA=5) AND (TYPE=ALLEN)",
0, &index, &nHits, NULL, NULL);
printf("\n%d screws of type Allen 5mm x 75mm used", &nHits);
. . .