GetObjectProperty

This function gets the value(s) of a certain property of an instance, class or model.
The value of card gives the actual card of the values list.
The list values of integers is a list of handles to instance, classe or property, this list
has a length as given in the value card.
Caller should not dispose the list
The return value always should be 0, if not something is wrong in the way this property is called.

Syntax

//
//   Strong typing definition
//
int64_t                     GetObjectProperty(
                                    RdfsResource            rdfsResource,
                                    OwlObjectProperty       owlObjectProperty,
                                    const RdfsResource      ** values,
                                    int64_t                 * card
                                );

static  inline  int64_t GetObjectProperty(
                                RdfsResource            rdfsResource,
                                OwlObjectProperty       owlObjectProperty,
                                RdfsResource            ** values,
                                int64_t                 * card
                            )
{
    return  GetObjectProperty(
                    rdfsResource,
                    owlObjectProperty,
                    (const RdfsResource**) values,
                    card
                );
}

static  inline  int64_t GetObjectProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlObjectProperty
                            )
{
    OwlInstance * values = nullptr;
    int64_t     card = 0;

    GetObjectProperty(
            rdfsResource,
            owlObjectProperty,
            &values,
            &card
        );

    if (card == 1)
        return  values[0];
    else
        return  0;
}


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall GetObjectProperty(
                                                int64_t                 rdfsResource,
                                                int64_t                 owlObjectProperty,
                                                const int64_t           ** values,
                                                int64_t                 * card
                                            );

static  inline  int64_t GetObjectProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlObjectProperty,
                                int64_t                 ** values,
                                int64_t                 * card
                            )
{
    return  GetObjectProperty(
                    rdfsResource,
                    owlObjectProperty,
                    (const RdfsResource**) values,
                    card
                );
}

static  inline  int64_t GetObjectProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlObjectProperty
                            )
{
    OwlInstance * values = nullptr;
    int64_t     card = 0;

    GetObjectProperty(
            rdfsResource,
            owlObjectProperty,
            &values,
            &card
        );

    if (card == 1)
        return  values[0];
    else
        return  0;
}
    

Property rdfsResource

Size: 64 bit / 8 byte (value)
???.

Property owlObjectProperty

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the object property (relation). The handle will be static during the life-time of the model, when the model (or part of it) is saved and opened again, the handle will most probably be different.

Property values

Size: 32 bit / 4 byte (reference)
The output array for object properties content. The contents memory is allocated by the library

Property card

Size: 32 bit / 4 byte (reference)
The cardinality (i.e. number of elements) of the array as given or returned.

Example (based on pure API calls)

Here you can find code snippets that show how the API call GetObjectProperty can be used.

#include    "./include/engine.h"
#include    <stdio.h>
#include    <string.h>

int64_t model = CreateModel();

if (model) {
    //
    //  Classes
    //
    int64_t classAbcd = CreateClass(model, "ABCD");

    //
    //  Object Properties (relations)
    //
    int64_t propertyAb = CreateProperty(model, OBJECTPROPERTY_TYPE, "Ab");

    //
    //  Instances
    //
    int64_t instanceAbcdI = CreateInstance(classAbcd, nullptr),
            instanceAbcdII = CreateInstance(classAbcd, nullptr);

    //
    //  Set Properties
    //
        
    {
        SetObjectProperty(instanceAbcdI, propertyAb, &instanceAbcdII, 1);

        int64_t valuesAb[3] = { instanceAbcdI, instanceAbcdII, instanceAbcdI };
        SetObjectProperty(instanceAbcdII, propertyAb, valuesAb, 3);
    }

    //
    //  Get Properties
    //

    {
        int64_t card = 0,
                * values = nullptr;
        GetObjectProperty(instanceAbcdI, propertyAb, &values, &card);

        assert(card == 1 && values[0] == instanceAbcdII);
    }

    {
        int64_t card = 0,
                * values = nullptr;
        GetObjectProperty(instanceAbcdII, propertyAb, &values, &card);

        assert(card == 3 && values[0] == instanceAbcdI && values[1] == instanceAbcdII && values[2] == instanceAbcdI);
    }

    //
    //  The same can be applied to existing classes and properties
    //

    //
    //  Classes
    //
    int64_t classCollection = GetClassByName(model, "Collection"),
            classCube = GetClassByName(model, "Cube");

    //
    //  Object Properties (relations)
    //
    int64_t propertyObjects = GetPropertyByName(model, "objects");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyLength = GetPropertyByName(model, "length");

    //
    //  Instances (creating)
    //
    int64_t instanceCollectionI = CreateInstance(classCollection, nullptr),
            instanceCollectionII = CreateInstance(classCollection, nullptr),
            instanceCube = CreateInstance(classCube, nullptr);

    double  length = 1.0;
        
    SetDatatypeProperty(instanceCube, propertyLength, &length, 1);

    int64_t values[3] = { instanceCollectionII, instanceCube, instanceCube };
    SetObjectProperty(instanceCollectionI, propertyObjects, values, 3);
    SetObjectProperty(instanceCollectionII, propertyObjects, &instanceCube, 1);

    //
    //  CollectionI contains 3 cubes and CollectionII contains 1 cube
    //
    assert(GetVolume(instanceCollectionI, nullptr, nullptr) == 3);
    assert(GetVolume(instanceCollectionII, nullptr, nullptr) == 1);

    //
    //  The resulting model can be viewed in 3D-Editor.exe
    //
    SaveModel(model, "c:\\created\\myFile.bin");
    CloseModel(model);
}