Next section

Class Definitions

Describes the structure of a class definition.

Introduction

In InterSystems IRIS, a class can include familiar class elements such as properties, methods, and parameters (known as constants in other class languages). It can also include items not usually defined in classes, including triggers, queries, and indexes.

Details

A class definition has the following structure:
Import import_ppackage_list  
Include include_code  
IncludeGenerator include_generator_code  

/// description 
Class package.shortclassname Extends superclass_list [ class_keyword_list ] 
{  
Class_members
}
Where:
  • import_package_list (optional) specifies the names of any packages that you wish your class to import from. This affects how the compiler resolves short class names; see “Importing Packages” in Defining and Using Classes.
    This option, if specified, is either the name of a single package or is a comma-separated list of multiple packages, enclosed in parentheses.
    If import_package_list is null, do not add the Import line at the start of the class definition.
    Note:
    If a class imports any packages, that class does not automatically import the User package.
    Imported packages are inherited from all superclasses. If a subclass specifies one or more import packages, those are added to any import packages defined by the superclasses.
  • include_code (optional) specifies InterSystems IRIS include (.inc) files used when compiling this class.
    This option, if specified, is either the name of a single include file (without the .inc extension) or is a comma-separated list of multiple include files, enclosed in parentheses.
    If include_code is null, omit the Include line at the start of the class definition.
    For an introduction to include files, see “Include Files” in the InterSystems Programming Tools Index.
    Include files are inherited from all superclasses. If a subclass specifies one or more include files, those are added to any include files defined by the superclasses.
  • include_generator_code (optional) specifies InterSystems IRIS include (.inc) files used when compiling the generator methods for this class. For information on generator methods, see “Defining Method and Trigger Generators” in Defining and Using Classes.
    For general comments, see the previous item.
    If include_generator_code is null, do not add the IncludeGenerator line at the start of the class definition.
  • description (optional) is intended for display in the Class Reference. A description may consist of multiple lines and may include HTML formatting tags and additional tags such as <class> and <method>. For limitations and details, see “Creating Class Documentation” in Defining and Using Classes. The description is blank by default.
  • package (required) is a valid package name, as described in “Package Names” in Defining and Using Classes.
  • shortclassname (required) is a valid class name. Together, package and shortclassname form the complete class name, which is subject to a length restriction. See “Naming Conventions” in Defining and Using Classes.
  • superclass_list (optional) specifies the class or classes from which this class inherits. This option, if specified, is either the name of a single class (without the .cls extension) or is a comma-separated list of classes, enclosed in parentheses.
    The first such class is referred to as the primary superclass; any additional classes are secondary superclasses. For information, see “Inheritance” in Defining and Using Classes.
    If superclass_list is null, omit the word Extends from the class definition.
  • class_keyword_list (optional) is a comma-separated list of keywords that (in most cases) affect how the compiler generates code for this class definition.
    See the section “Class Keywords.”
    If this list is omitted, also omit the square brackets.
  • Class_members is zero or more definitions of class members.
    For an introduction, see “Kinds of Class Members” in Defining and Using Classes. The other sections in this reference provide details on these kinds of class member.

See Also

This reference does not formally introduce storage definitions. For an introduction to storage definitions, see “Storage” in “Persistent Objects and InterSystems IRIS SQL” in the Orientation Guide for Server-Side Programming. Also see “Storage Definitions and Storage Classes” in “Defining Persistent Classes” in Defining and Using Classes.
Next section