Previous: Units, Up: Properties

6.5.3 Virtual properties

The properties have a non-trivial overhead (because of the key, type and subtype identification, and other data). Also, the GEOMLIB cannot use the property mechanism, as it is independent of the kernel. Moreover, some properties have a special meaning and need some additional value checks (sometimes depending on other property values as well).

For these reasons, the virtual properties were introduced. A virtual property looks the same as a regular one; but some special callbacks handle the reading and writing of its value. The callbacks are called by the property manipulating functions.

The information about one virtual property is stored in the struct prop_virtual structure (common for all properties of the same key, type and subtype belonging to the same GO subtype). It contains the following callback pointers:

prop_value (*get)(struct o* o)
Returns the value of the property the object o.
void (*set)(struct o* o, prop_value new_value)
Tries to change the value of the property. This function may fail because of a numeric error or a forbidden value. It can also change some other variables of the object o.
void (*set_low)(struct o* o, prop_value new_value)
This function is called by the undo to change the value – it does not trigger any callback calls.
uns (*get_unit)(struct o* o)
Returns the property unit. (The property must have a unit.)
void (*set_unit)(struct o* o, uns unit)
Changes the unit. (The property must have a unit.)

List of virtual properties

Every object has its own property list. In the beginning of the list, there are non-virtual properties, and the last non-virtual property points to the first virtual property. Each GO subtype has its own list of virtual properties. The last virtual property is always the “name” property.