company logo

Assigning database context classes in ClassEditor

In order to implement specific behavior for a database model resource (business rules), a context class has to be assigned to the resource (complex data type, property, object space or database). Typically, context classes are defined as data type or property context classes, which apply on data types (SDB_Structure) or properties (SDB_Property). Database (SDB_Database) and object space (SDB_NamedObject) resources may be associated withdatabase or object space context classes.

In order to react on database events, event handlers as being defined in the odaba::DBBaseContext class might be overloaded in derived application-defined context classes. Application-defined context classes have to be assigned to database model resources. Each application-defined context class may be associated with any number of database model resources, i.e. a type context class might be associated with any number of data type definition resources and property context classes might be associated with any number of property definition control resources.

The ClassEditor supports assigning context classes by a context association feature:

The Resource reference field ia available for data type and property (member) definitions. When entering the class name in the context class field, a resource reference will be created automatically, when not yet existing. The number (__AUTOIDENT) of the resource reference assigned is displayed in the field right of the class name. In order to create a new context class, one may click the associate button left of the resource reference number. The class create pops up allowing defining class properties for initializing the class properly:

A default class name has bee created from the resource name prefixed by the option set in Options.Implementation.Naming.TypeContextClassPrefix. One may change the name or assign an existing context class from the drop list. The default base class is the system context class defined for the resource type (typically TypeContext or PropertyContext). but an alternative context class might be selected from the drop list.

As programming language, the project programming language will be proposed. In case of C++ or C## projects, one might change the programming language to OSI, when all functions in the class should be implemented as OSI functions.

When defining a new context class, clicking OK will create the new context class, initialize constructor, destructor and Create() function (C++, only). Finally, the context class is assigned to the resource reference.

Related topics