Adding Projections to a Class
This chapter discusses how to add projection definitions in a class definition.
A projection definition instructs the Caché class compiler to perform specified operations when a class definition is compiled or removed. A projection defines the name of a projection class (derived from the %Projection.AbstractProjectionOpens in a new tab class) that implements methods that are called when a) the compilation of a class is complete and b) when a class definition is removed (either because it is being deleted or because the class is about to be recompiled).
A class can contain any number of projection definitions. The actions for all of them are invoked when the class is compiled (the order in which they are invoked is not defined).
Caché includes predefined projection classes that generate client code that allows access to a class from Java, MV, and so on. See the class in the class reference for definitions of parameters for each class.
To generate C++-related classes, use Tools > Generate C++ Projection or the cpp_generator command line interface. For more information, see the chapter “Using the C++ Generator Program ” in Using C++ with Caché.
|%Projection.JavaOpens in a new tab
|Generates a Java client class to enable access to the class from Java.
|Registers this class as a routine that works with Caché Monitor. Metadata is written to Monitor.Application, Monitor.Alert, Monitor.Item and Monitor.ItemGroup. A new persistent class is created called Monitor.Sample.
|%Projection.MVOpens in a new tab
|Generates an MV class that enables access to the class from MV.
|%Projection.StudioDocumentOpens in a new tab
|Registers this class as a routine that works with Studio.
|%Studio.Extension.ProjectionOpens in a new tab
|Projects the XData 'menu' block to the menu table.
|Projection class used by %ZEN.Component.objectOpens in a new tab classes. This is used to manage post-compilation actions for Zen components.
|%ZEN.PageProjectionOpens in a new tab
|Projection class used by %ZEN.Component.pageOpens in a new tab. Currently this does nothing.
|%ZEN.Template.TemplateProjectionOpens in a new tab
|Projection class used by %ZEN.Templage.studioTemplate class.
You can also create your own projection classes and use them from Studio as you would any built-in projection class.
You can add a new projection to a class definition in two ways:
Editing the class definition using the Class Editor.
Using the New Projection wizard
To add a projection using the Class Editor, position the cursor at a blank line and enter a projection declaration.
Alternatively, you can copy and paste an existing projection declaration and then edit it.
For details on projection definitions, see “Class Definitions” in the reference “Class Definitions” in Caché Class Definition Reference.
New Projection Wizard
You can invoke the New Projection wizard using the Class > Add > Projection and asking for a new Projection. Alternatively right-click in the Class Inspector and select New Projection.
The New Projection wizard displays pages prompting you for information about the new projection. To end, select Finish (in this case, default values are provided for any information you have not specified).
Name and Description Page
The New Projection wizard prompts you for the following information (you can later modify any of these values):
(required) Name of the new projection. This name must be a valid projection name and must not conflict with the name of a previously defined projection.
(optional) Description of the new projection.
Projection Type Page
The projection type determines what actions happen when your class definition is compiled or removed. You can select what kind of projection you would like to define:
Name of a projection class whose methods are executed when a class definition is compiled or removed.
A set of name-value pairs that control the behavior of the projection class. The list of available parameter names is determined by the selected projection class.
Results of Running the New Projection Wizard
When you finish running the New Projection wizard, the Class Editor window is updated to include the new projection definition. For example:
/// This is a Person class
class MyApp.Person extends %Persistent
Property Name As %String;
Projection JavaClient As %Projection.Java;
To edit this projection definition, use either the Class Editor or the Class Inspector.