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 in the specified aggregate for elements that matches the specified conditions. All elements in the specified aggregate will match an empty condition, i.e. the <condition> argument set to NULL.
Each matching element is identified by the element index. The index of the first aggregate element to test for matching the specified condition, and the maximum number of matching elements to return, are specified as input arguments to the function. The actual number of matching elements and the "index of the last returned matching element in the aggregate" are returned from the operation. This makes it convenient to query an aggregate by the edmiFindAggrElements function in an incremental way.
The actual model hosting the specified aggregate to query must be open before this operation can be successfully performed.
When the input arguments <maxBufferSize> == 0 & <resultBuffer> == NULL no instanceId or elementNumber will be returned. Only the number of matching instances/elements will be returned.
Related functions: edmiFindAggrInstances , edmiFindAggrInstancesBN, edmiFindInstancesBN
Header:
#include "sdai.h"
Prototype:
EdmiError edmiFindAggrElements(SdaiAggr aggregate,
                                SdaiString condition, 
                                SdaiInteger maxBufferSize, 
                                SdaiInteger *index, 
                                SdaiInteger *numberOfHits, 
                                SdaiInteger *resultBuffer); 
Arguments:

aggregate

A numeric aggregateID that uniquely identifies the aggregate to query in the EDMdatabase.
The aggregateID is defined when the aggregate is created by one of the following operations: sdaiCreateAggr , sdaiCreateAggrBN , sdaiCreateNestedAggr , sdaiCreateNestedAggrByIndex , sdaiCreateNestedAggrByIterator

condition

Specifies the condition the target elements should match. All elements in the specified aggregate match an empty condition, i.e. <condition> = NULL or <condition> = "".

maxBufferSize

Specifies the size (in number of bytes) of the buffer to receive the index of the matching elements. The actual number of returned matching elements will never be greater than the number of indexes that can be placed in a buffer of the size specified by this argument.

index

In: The index of the aggregate element to start searching at. The index of the first element in the actual aggregate will always be index zero, independent of the aggregate type. Hence the legal index range is: 0<= index < number of elements in the aggregate.
Out: The index of the "last returned matching element". This argument enables the caller to search for elements in an incremental way by specifying this "returned index value plus one" as the input to the next edmiFindAggrElements function and so on.

numberOfHits

In: Specifies the maximum number of matching elements to return. If this number is greater than the limitation specified by the <maxBufferSize> argument, then the maximum number of hits will be calculated from the <maxBufferSize> argument.
Out: The number of found matching elements.

resultBuffer

Address of a buffer in the calling application that will receive the index of each returned matching aggregate element. This buffer is mapped to a SdaiInteger array when the index of each returned matching aggregate element is stored. The <maxBufferSize> argument should prevent the function to write past buffer.

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:
SdaiAggr aggrId;
int i;
SdaiInteger index,hits,resultBuffer[MAX_ELEMENTS];
...
index = 0; /* start on first aggregate element */
hits = MAX_ELEMENTS; /* max number of hits */
if (rstat = edmiFindAggrElements(aggrId,
" between 100 100000", 
sizeof(resultBuffer), 
&index, 
&hits, 
resultBuffer)) { 
/* Error in operation */ 
printf("\nError: %s in edmiFindAggrElements\n", 
edmiGetErrorText(rstat)); 
goto error; 
}
/* print out matching element numbers */
for (i = 0; i < hits; i++) {
printf("\nElement: #%5ld", resultBuffer[i]);
}
...

  • No labels