ClassType (Class Keyword)
Usage
To specify the type of class (if needed), use the following syntax:
Class MyApp.MyClass [ ClassType = classtype ]
{ //class members }
Where classtype is one of the following:
-
datatype — the class is a data type class and is used to represent a literal value.
-
dynamic — the class is a dynamic class, such as %DynamicAbstractObjectOpens in a new tab, %DynamicArrayOpens in a new tab, or %DynamicObjectOpens in a new tab.
-
index — the class is an index class, a specialized class that defines an index interface. For details, see %Library.FunctionalIndexOpens in a new tab in the class reference.
-
persistent — the class represents data to be stored in the database.
-
serial — the class represents data to be stored (in its serialized state) in another persistent object.
-
stream — the class represents streaming data.
-
view — the class is used to define an SQL view (see the ViewQuery keyword).
-
An empty string, which indicates that this class has no specific type. Abstract classes typically do not specify a class type.
If this keyword is not specified, the class type is inherited from the primary superclass, if there is one.
Note that ClassType is specified for system classes such as %RegisteredObjectOpens in a new tab, %SerialObjectOpens in a new tab, %PersistentOpens in a new tab, %DynamicAbstractObjectOpens in a new tab, and data type classes, so you do not generally need to specify this keyword if you subclass those classes.
Details
This keyword specifies how this class is to be used. The class compiler uses the ClassType keyword to determine how to compile a class. For example, if ClassType is persistent, the class compiler additionally invokes the storage compiler to generate persistence code for a class. Unless explicitly defined, the value of ClassType is either the default value or it is inherited from the primary superclass.
For persistent classes, an explicit ClassType statement is only required when standard persistence behavior is being overridden. If a class definition includes such a statement, it is either because a developer has specified it or because the class originated in code developed with an older version of InterSystems IRIS.
Effect on Subclasses
This keyword is inherited from the primary superclass. The subclass can override the value of the keyword.
Default
If you omit this keyword, the class type is inherited from the primary superclass, if there is one.
The ClassType for sharded classes cannot have any value other than persistent.