company logo

Property :: createAttributeExtension - Create attribute extension

The function allows creating ad hoc properties to the property handle. The property definition is passed in vExpression. The property definition must follow the rules for a parameter specification (parm_spec) as being defined in ODL. Property definitions may refer to simple or complex attributes or reference collections.

The property definition at least requires a data type (e.g. "string name" or "SET<Person> friends"). The property must not yet exist in the data type definition for the property handle or in one of its generalizations or extensions. Attribute extensions may be defined with or without data source (assignment expression) and as static or non-static properties. When defining a data source, the extension property will be evaluated always when being accessed.

After being created, extension properties may be referred to as regular properties in OSI functions or expressions and other property access functions (e.g. value() or property()).

After creating an attribute extension for a property handle, it becomes a member of the current property handle, but not a member of the property's type definition. In order to remove an attribute extension, one may call removeAttributeExtension().

When the property handle is not valid or when the attribute definition is invalid, the function throws an exception.

// add age_grup a Person type property handle

  createAttributeExtension("static int sum_age");

  createAttributeExtension("static int pcount = count");

  createAttributeExtension("STRING(10) agegroup = ( age <= 20 ? 'young' :

                                                    age <= 60 ? 'medium': 'old')");

Implementation details

Property  :: createAttributeExtension ( odaba::String &vExpression )
  • vExpression - OSI inline expression

    An inline expression can be passed as operation path, as operand (something like a + b) or as complete expression. As operand, an expression may contain any expression, which is allowed in a statement, but no semicolon must be appended at the end.

    Complete expressions include expression header (optional) and may include different sections in the expression body which is enclosed in { ... }.

    In contrast to class expressions, inline expressions are not defined explicitly as class expressions but passed as strings to the application at run-time.

    In order to pass no expression, an empty string ( String() ) has to be passed.