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 Current »


 
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 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, edmiFindAggrInstancesBN, edmiFindAggrInstances
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteFindAggrInstancesBN(SdaiServerContext serverContextId, 
                                         SdaiInstance      instance, 
                                         SdaiString        attributeName, 
                                         SdaiString        condition, 
                                         SdaiInteger       maxBufferSize, 
                                         SdaiInteger       *index, 
                                         SdaiInteger       *numberOfHits, 
                                         SdaiInstance      *resultBuffer, 
                                         SdaiInvocationId  *edmiInvocationId); 
 
Arguments:

serverContextId

Context identification, from edmiDefineServerContext

instance

The numeric instanceID that uniquely identifies the instance in the remote _EDMdatabase_ that owns the aggregate to be queried.

attributeName

Name of the attribute that owns the aggregate to be queried. Attribute names are case insensitive. The <attributeName> must be qualified with the name of the entity from which it was originally inherited if it is not unique within the Entity.

condition

The condition that the instances in the aggregate shall match. A NULL or empty string condition will match all the elements. The condition statement must be on the form "attribute = value"
Example condition:
"NAME = 'Johnny'" or "AGE > 30".
For more complex logical expressions, use edmiRemoteSelectAggrInstances

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.
Out: The index of the last returned matching element. If the return value is incremented by one, it may be used as input value for succeeding calls to the same function. This way, the second call will start reading aggregate elements where the first call finished. this will reduce the required size of the <resultBuffer>.

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.
Out: The number of matching aggregate element indexes returned.

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;
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);
 
/* Find the number of screws of type
Allen 5mm x 75mm used for the 
dining table 'PIZA-210' */ 
index = 0;
nHits = 1000;
rstat = edmiRemoteFindAggrInstancesBN(myContext,
tableId, "SCREWS", 
"(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);
. . .

  • No labels