About the Caché Class Definition Classes
The Caché Library
set of class definitions classes
has been superceded by the
classes described here are maintained for compatibility with existing applications.
should make use of the classes within the
can be found in the online documentation in the
Caché Development Guides section in the book titled,
Using Caché Objects.
Make sure that you specify the correct package name when using these classes
or you may inadvertently use the wrong class.
The Caché Library includes a number of class definition classes that
provide object access to the Caché Unified Dictionary. Using these classes you can
programmatically examine class definitions, modify class definitions, create new classes,
or even write programs that automatically generate documentation.
There are two parallel sets of class definition classes: those that represent defined
classes and those that respresent 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 super classes. 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 super classes.
A compiled class definition object can only be instantiated from a class that has been compiled.
You cannot save a compiled class definition. In this document we will only discuss defined classes but
the operation of the compiled class definitions is similar.
The family of class definition classes that represent defined classes includes:
Browsing Class Definitions
You can use the class definition classes to browse through the class definitions
within the Caché
dictionary using the same techniques you
would use in a database application: you can use the %ResultSet
object to iterate over sets of classes and you can instantiate
persistent objects that represent specific class definitions.
from within a Caché process you can get a list of all classes defined
within the dictionary for the current namespace by using the %ClassDefinition.ClassInfo query:
For Quit:result.Next()=0 Write result.GetDataByName("Name")
You can just as easily invoke this query from an ActiveX or
Java client using the client ResultSet object.
This %ClassDefinition.ClassInfo query will return all of the classes
visible from the current namespace (including classes in the system library). You can filter out unwanted
classes using the various columns returned by the %ClassDefinition.ClassInfo query.
You can get detailed information about a specific class definition by opening a
object for the class and observing its properties. The
ID used to store %ClassDefinition
objects is the class name:
; get list of properties
For i=1:1:count Write cdef.Properties.GetAt(i).Name
You can also do this easily from an ActiveX or Java client.
Altering Class Definitions
You can modify an existing class definition by opening a %ClassDefinition
object, making the desired changes, and saving it using the %Save
You can create a new class by creating a new %ClassDefinition
object, filling in its properties and saving it. When you create %ClassDefinition
object you must pass the name of the class via the %New
command. When you want to add
a member to the class (such as a property or method) you must create the corresponding definition
class (passing its %New
command a string containing "classname.membername")
and add the object to the appropriate collection within the %ClassDefinition
; add a Name property
; save and close the class definition object