company logo

Defining transient references

Transient references are used a sort of placeholder, which is replaced by an appropriate property at run time. This differs completely from the feature of defining transient collection (see following chapter) or attributes. Transient references may refer to any kind of result, i.e. instance collections, complex structured instances, but also basic type attributes or MEMO fields.

Defining a transient reference requires only switching on the transient option in the reference definition. All the other options must be switched off and no index and no source must be defined. The type defined for a transient property is the base type for properties assigned to the transient reference later. Defining a type for a transient reference is necessary, when the transient reference will be referred to in OSI expressions. Without type, subordinated properties for the transient reference cannot be resolved, which may cause errors.

When any type of property can be assigned to the transient reference, the type must be define as VOID, which it the base type for any other user defined type.

Transient properties can be altered in the application program, typically from within context functions. Usually, transient properties are set in the DBRead() or DBOpened() function calling SetTransientProperty().

Setting a property handle for a transient reference will not check collection attributes, i.e. one may also set an attribute property to a transient reference.


logical     sCompany::DBOpened() {

  Property       &prop = GetProperty();

  Property       &director = prop.GetProperty("director"); // transient reference

  

// person is a property defined in this context class

  person.Open(prop.GetDatabase(),"Person::Persons");

// DirectorPID is an option set in the application

  person.Get(GetOption("DirectorPID"));

// set person as current property in the transient director property

  director.SetTransientProperty(person);

}

Notes:

Setting create or owning or defining an index or a source for a transient reference will turn the transient reference in a transient or virtual collection. Hence, this reference properties should never be defined when trying to define a transient reference..