company logo

SDB_Attribute - Attribute definition

Inherits:  SDB_Property

Attribute definitions are used to define the attributes for a complex data type (structure). Attributes can be defined as transient or persistent attributes. Attributes are persistent by default when being defined in a persistent instance and they are transient, when being defined in a transient instance.

Within a persistent instance, transient attributes can be defined by setting the transient option. Transient attributes must be filled by the application as long as no source has been defined for the attribute. When a source is defined, the attribute is filled, when accessing it (e.g. calling toString()). This means, that the attribute value is not automatically calculated, when reading the instance.

Attributes of complex data type must not containrelationships to structured instances. Attributes may contain MEMO fields.

Notes:

Defining attributes will create a warning when containing references or relationships, but no error. When using references in attributes, following restrictions must be taken into account:

  • References in array attributes are not initialized properly
  • References in copy nodes are not initialized properly
Transient attributes

Attributes are transient by default when being defined in a transient instance. Within a persistent instance, transient attributes may be defined by setting the transient option.

Transient attributes might be filled by the application. This is typically done in the instance read handler for the data type containing the transient attribute or by defining a data source (OSI expression) for the transient attribute.

A more simple way is defining a source expression for the transient attribute. When a source is being defined, the attribute is filled, when being accessed (e.g. Property::string()). Thus, transient attribute values are not automatically calculated, when reading the instance, but only, when being explicitly accessed.

After being calculated once, the attribute value will not be calculated again, until changing the selection for the owning parent property handle or refreshing the instance. This may cause problems, when changing attribute values in the instance, on which the transient attribute value depends. In order to re-evaluate the transient attribute value, Value::refresh() may also be called.

Array attributes

Array attributes can be defined by setting a dimension value greater than 1. Attribute arrays can be checked by calling Property::isArray() (do not call Property::isCollection() since arrays are not treated as collections).

Attribute arrays can be accessed as soon as the structure instance containing the array is selected or positioned. Array elements can be accessed by assigning an array index (Property::get(iPosition)) or using the selection operator in an access path (Persons('Miller').firstnames(0)).

Accessing an array with an index higher than the dimension value for the array will throw an error.

Keys
Functions