...
Code Block | ||||
---|---|---|---|---|
| ||||
EdmiError edmiRemoteFindAggrElements(SdaiServerContext serverContextId,
SdaiAggr aggregate,
SdaiString condition,
SdaiInteger maxBufferSize,
SdaiInteger *index,
SdaiInteger *numberOfHits,
SdaiInteger *resultBuffer,
SdaiInvocationId *edmiInvocationId);
|
Search in a specified aggregate within a remote edmModel for elements that match a specified condition. The condition must be a simple logical expression addressing only the simple type values of the aggregate elements. A NULL or empty string condition will match All elements of the specified aggregate.
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 the unordered 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, edmiRemoteFindAggrInstances, edmiRemoteFindAggrInstancesBN
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteFindAggrElements(SdaiServerContext serverContextId,
SdaiAggr aggregate,
SdaiString condition,
SdaiInteger maxBufferSize,
SdaiInteger *index,
SdaiInteger *numberOfHits,
SdaiInteger *resultBuffer,
SdaiInvocationId *edmiInvocationId);
Arguments:
Arguments
...
Type | Name | Comment |
SdaiServerContext | serverContextId | Context identification, from edmiDefineServerContext |
SdaiAggr | aggregate | A numeric aggregateID that uniquely identifies the persistent aggregate of interest in the remote _EDMdatabase._ Scratch aggregates may also be used, but only when LOCAL_CONTEXT is specified in the <serverContextId> argument. |
SdaiString | condition | Specifies the condition the target elements should match. A NULL or empty string condition matches all elements. |
SdaiInteger | 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. |
SdaiInteger | index |
|
SdaiInteger | numberOfHits |
|
SdaiInteger | 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. |
SdaiInvocationId | edmiInvocationId | Currently not used. |
...
Return Value
...
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Options
...
Example
...
Code Block | ||
---|---|---|
| ||
/*
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, screwId;
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 id of the allen screw that is
5 mm thick, and have a length of 75 mm.
The id is found among the instances of
type SCREW */
index = 0;
nHits = 1;
rstat = edmiRemoteSelectInstances(myContext, "DataRepository",
"FURNITURE_DESIGN", "SCREW",
"(LEN=75) AND (DIA=5) AND (TYPE=ALLEN)",
ONLY_INSTANCE_IDS, NULL, NULL, NULL,
&index, &nHits, &qexRes,
NULL, NULL, NULL, NULL);
screwId = 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 = edmiRemoteFindAggrElements(myContext, screwBagId,
" = screwId", 0, &index, &nHits, NULL, NULL);
printf("\n%d screws of type Allen 5mm x 75mm used", &nHits);
. . . |
See also
Filter by label (Content by label) | ||||||
---|---|---|---|---|---|---|
|