GetInstancesByIterator

Returns a handle to an instance.
If input instance is zero, the handle will point to the first relevant instance.
If all instances are past (or no relevant instances are found), the function will return 0.

Syntax

//
//   Strong typing definition
//
OwlInstance     GetInstancesByIterator(
                        OwlModel                model,
                        OwlInstance             owlInstance
                    );


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall GetInstancesByIterator(
                                                int64_t                 model,
                                                int64_t                 owlInstance
                                            );
    

Property model

Size: 64 bit / 8 byte (value)
The handle to the model. The model handle is static during its existance. Several models can be opened simultaniously within one session. Different models are always independent, threads are allowed to be running on different models simultaniously.

Property owlInstance

Size: 64 bit / 8 byte (value)
The handle to the specific instance in the design tree. The instance handle is static within one open model but is most probably different when the same instance is opened in another model. The instance is always exactly of one unique class.

Example (based on pure API calls)

Here you can find code snippits that show how the API call GetInstancesByIterator can be used.

#include    "./include/engine.h"

int64_t GetInstanceCnt(int64_t model)
{
    int64_t instanceCnt = 0,
            myIteratedInstance = GetInstancesByIterator(model, 0);
    while (myIteratedInstance) {
        char    * instanceName = nullptr,
                * className = nullptr;
        GetNameOfInstance(myIteratedInstance, &instanceName);
        GetNameOfClass(GetInstanceClass(myIteratedInstance), &className);
        //
        //  The name of the class can be checked by placing a breakpoint after this point while debugging
        //
        myIteratedInstance = GetInstancesByIterator(model, myIteratedInstance);
        instanceCnt++;
    }

    return  instanceCnt;
}

int _tmain(int argc, _TCHAR* argv[])
{
    int64_t model = CreateModel();

    if (model) {
        int64_t instanceCnt = GetInstanceCnt(model);

        //
        //  Add a new class
        //
        CreateInstance(GetClassByName(model, "Collection"), "CreatedInstanceToTestInstanceCnt");

        assert(GetInstanceCnt(model) == instanceCnt + 1);

        int64_t instanceCntThroughAPI = 0;
        OrderedHandles(model, nullptr, nullptr, &instanceCntThroughAPI, 0, 0);

        assert(GetInstanceCnt(model) == instanceCntThroughAPI);

        CloseModel(model);
    }

    return  0;
}