CreateProperty

Returns a handle to an on the fly created property, however when
a property with this name already exists the handle of existing property will be returned.

The following reasons will cause a return value of 0:
    - when the name is already used for a class or instance;
    - if the model input is zero or not a model handle.

Giving the property a name is optional, if a name is not given it will recieve an automatically generated name,
it's automatically generated name can change between sessions.

Syntax

//
//   Strong typing definition
//
RdfProperty     CreateProperty(
                        OwlModel                model,
                        int64_t                 rdfPropertyType,
                        const char              * name
                    );

static  inline  RdfProperty CreateProperty(
                                    OwlModel                model,
                                    int64_t                 rdfPropertyType,
                                    char                    * name
                                )
{
    return  CreateProperty(
                    model,
                    rdfPropertyType,
                    (const char*) name
                );
}

static  inline  RdfProperty CreateProperty(
                                    OwlModel                model,
                                    int64_t                 rdfPropertyType
                                )
{
    return  CreateProperty(
                    model,
                    rdfPropertyType,
                    (const char*) nullptr               //    name
                );
}

static  inline  RdfProperty CreateProperty(
                                    OwlModel                model
                                )
{
    return  CreateProperty(
                    model,
                    0,                                  //    rdfPropertyType
                    (const char*) nullptr               //    name
                );
}


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall CreateProperty(
                                                int64_t                 model,
                                                int64_t                 rdfPropertyType,
                                                const char              * name
                                            );

static  inline  int64_t CreateProperty(
                                int64_t                 model,
                                int64_t                 rdfPropertyType,
                                char                    * name
                            )
{
    return  CreateProperty(
                    model,
                    rdfPropertyType,
                    (const char*) name
                );
}

static  inline  int64_t CreateProperty(
                                int64_t                 model,
                                int64_t                 rdfPropertyType
                            )
{
    return  CreateProperty(
                    model,
                    rdfPropertyType,
                    (const char*) nullptr               //    name
                );
}

static  inline  int64_t CreateProperty(
                                int64_t                 model
                            )
{
    return  CreateProperty(
                    model,
                    0,                                  //    rdfPropertyType
                    (const char*) nullptr               //    name
                );
}
    

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 rdfPropertyType

Size: 64 bit / 8 byte (value)
the type of the rdfProperty, i.e. is it an ObjectProperty (relation) or a DatatypeProperty, in the later case also subdivision towards Boolean, Double, Integer or String.

Property name

Size: 64 bit / 8 byte (reference)
This attribute represents the name of the property; either a datatype property or a relation (given as char array / ASCII). The name is given by the host and the attribute is not changed.

Example (based on pure API calls)

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

#include    "./include/engine.h"
#include    <cmath>

int64_t model = CreateModel();

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

    //
    //  Object Properties (relations)
    //
    int64_t propertyAbcd = CreateProperty(model, OBJECTPROPERTY_TYPE, "abcd"),
            propertyObjects = GetPropertyByName(model, "objects");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyLength = GetPropertyByName(model, "length"),
            propertyEfgh = CreateProperty(model, DATATYPEPROPERTY_TYPE_DOUBLE, "efgh");

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

    double  length = 2.,
            efgh = 1.7;

    SetDatatypeProperty(instanceCube, propertyLength, &length, 1);
    SetDatatypeProperty(instanceCollection, propertyEfgh, &efgh, 1);

    assert(GetVolume(instanceCollection, 0, 0) == 0.);

    char    * propertyNameI = nullptr;
    GetNameOfProperty(propertyAbcd, &propertyNameI);

    char    * propertyNameII = nullptr;
    GetNameOfProperty(propertyEfgh, &propertyNameII);

    SetNameOfProperty(propertyAbcd, "InverseRelationControledByThirdParty");

    SetObjectProperty(instanceCube, propertyAbcd, &instanceCollection, 1);
    SetObjectProperty(instanceCollection, propertyObjects, &instanceCube, 1);

    assert(GetVolume(instanceCollection, 0, 0) == 8.);

    char    * propertyNameIII = nullptr;
    GetNameOfProperty(propertyAbcd, &propertyNameIII);

    //
    //  The retrieved property names have the following values 
    //      propertyNameI   :  'abcd'
    //      propertyNameII  :  'efgh'
    //      propertyNameIII :  'InverseRelationControledByThirdParty'
    //

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