GitHub    Download    Forum
Overview
Tutorial
C++ API
C# API
DTDL
DADL
Comments, Preprocessor
Definitions
BitFlagSets
Linking objects
Setup

Linking objects

One of the most important functions of DataFS is to link objects. Objects are linked by writing or setting attributes of the 'object' type.

Types of links

There are two ways of filling attributes of the 'object' type.
One way is to just set it to an ObjectId. This is sometimes called a 'lazy' link or 'hint' link. It provides nothing more than the smallest piece of information about an object. These links don't provide any guarantees about their target. It is possible that the linked object might not exist.
The second type of link is a combination of ObjectId and a list of classes. These links provide the guarantee that the target exists. In fact, the object only exists if links of that type to it exist. As long as one link to a class of an object exists, this class and therefore the object remains in existence.

Using links

There are six possible definitions for links in DADL.
object WMyObject
{
    MyClass
    {
        LinkedObject [ set, set(WOtherObject), link(WOtherObject) ];
    }
};

list WMyList MyList
{
    LinkedObject [ set(WOtherObject), link(WOtherObject) ];
};
object: set
The set function is the most flexible solution. You can create links and lazy links depending on the parameter passed.
The BuildLink function of every DADL object class can be used to prepare this parameter. Pass true in the AddRef parameter of BuildLink to generate a link parameter for a link or false for a lazy link parameter.
object: set(ObjectType)
Generates a function that takes a parameter of the 'ObjectType' type and stores a lazy link to this object in the attribute.
object: link(type)
Generates a function that takes a parameter of the 'ObjectType' type and stores a link to this object in the attribute.
list, struct: set
This type is always available and doesn't need a definition in DADL.
The set function is the most flexible solution. You can create links and lazy links depending on the parameter passed.
The BuildLink function of every DADL object class can be used to prepare this parameter. Pass true in the AddRef parameter of BuildLink to generate a link parameter for a link or false for a lazy link parameter.
list, struct: set(type)
Generates a function that takes a parameter of the 'ObjectType' type and stores a lazy link to this object in the attribute.
list, struct: link(type)
Generates a function that takes a parameter of the 'ObjectType' type and stores a link to this object in the attribute.

Multiple definitions

It is possible to define multiple set/link functions with a class parameter on an attribute at the same time.
object WMyObject
{
    MyClass
    {
        LinkedObject [ set(WType1), set(WType2), link(WType2), link(WType3) ];
    }
};
© 2022 Mobiland AG