Skip to main content

Introduction to Class Definition Classes

Introduction to Class Definition Classes

The class definition classes provide object and SQL access to the Caché unified dictionary. Using these classes, you can programmatically examine class definitions, modify class definitions, create new classes, and even write programs that automatically generate documentation. These classes are contained within the %Dictionary package.

Note:

There is an older set of class definition classes defined within the %Library package. These are maintained for compatibility with existing applications. New code should make use of the classes within the %Dictionary package. Make sure that you specify the correct package name when using these classes or you may inadvertently use the wrong class.

There are two parallel sets of class definition classes: those that represent defined classes and those that represent compiled classes.

A defined class definition represents the definition of a specific class. It includes only information defined by that class; it does not include information inherited from superclasses. In addition to providing information about classes in the dictionary, these classes can be used to programmatically alter or create new class definitions.

A compiled class definition includes all of the class members that are inherited from superclasses. A compiled class definition object can only be instantiated from a class that has been compiled. You cannot save a compiled class definition.

This appendix discusses defined class definitions exclusively, though the operation of the compiled class definitions is similar.

The family of class definition classes that represent defined classes includes:

Class Description
%Dictionary.ClassDefinitionOpens in a new tab Represents a class definition. Contains class keywords as well as collections containing class member definitions.
%Dictionary.ForeignKeyDefinitionOpens in a new tab Represents a foreign key definition within a class.
%Dictionary.IndexDefinitionOpens in a new tab Represents an index definition within a class.
%Dictionary.MethodDefinitionOpens in a new tab Represents a method definition within a class.
%Dictionary.ParameterDefinitionOpens in a new tab Represents a parameter definition within a class.
%Dictionary.PropertyDefinitionOpens in a new tab Represents a property definition within a class.
%Dictionary.QueryDefinitionOpens in a new tab Represents a query definition within a class.
%Dictionary.TriggerDefinitionOpens in a new tab Represents an SQL trigger definition within a class.
Important:

To reiterate, the content of an uncompiled class definition (as an instance of the %Dictionary.ClassDefinitionOpens in a new tab) is not necessarily the same as the content of a compiled class definition (as an instance of %Dictionary.CompiledClassOpens in a new tab). The %Dictionary.ClassDefinitionOpens in a new tab class provides an API to inspect or change the definition of the class — it does not ever represent the compiled class with inheritance resolved; %Dictionary.CompiledClassOpens in a new tab, on the other hand, does represent the compiled class with inheritance resolved.

For example, if you are trying to determine the value of a particular keyword in a class definition, use the keywordnameIsDefined() method from %Dictionary.ClassDefinitionOpens in a new tab (such as OdbcTypeIsDefined()Opens in a new tab or ServerOnlyIsDefined()Opens in a new tab). If this boolean method returns false, then the keyword is not explicitly defined for the class. If you check the value of the keyword for the class definition, it will be the default value. However, after compilation (which includes inheritance resolution), the value of the keyword is determined by inheritance and may differ from the value as defined.

FeedbackOpens in a new tab