SOMClass

File stem: somcls

Base

SOMObject

Metaclass

SOMClass
(SOMClass is the only class with itself as metaclass.)

Ancestor Classes SOMObject

Description

SOMClass is the root class for all SOM metaclasses. That is, all SOM metaclasses must be subclasses of SOMClass or some other class derived from it. It defines the essential behavior common to all SOM classes. In particular, it provides a suite of methods for initializing class objects, generic methods for manufacturing instances of those classes, and methods that dynamically obtain or update information about a class and its methods at run time.

Just as all SOM classes are expected to have SOMObject (or a class derived from SOMObject) as their base class, all SOM classes are expected to have SOMClass or a class derived from SOMClass as their metaclass. Metaclasses define "class" methods (sometimes called "factory" methods or "constructors") that manufacture objects from any class object that is defined as an instance of the metaclass.

To define your own class methods, define your own metaclass by subclassing SOMClass or one of its subclasses. Three methods that SOMClass inherits and overrides from SOMObject are typically overridden by any metaclass that introduces instance data somInit, somUninit, and somDumpSelfInt. The new methods introduced in SOMClass that are frequently overridden are somNew, somRenew, and somClassReady. (See the descriptions of these methods for further information.)

Other reasons for creating a new metaclass include tracking object instances, automatic garbage collection, interfacing to a persistent object store, or providing/managing information that is global to a set of object instances.

Types

   typedef sequence <SOMClass> SOMClassSequence;

   struct somOffsetInfo  {
      SOMClass          cls;
      long              offset
      };
   typedef sequence <somOffsetInfo> SOMOffsets;

New Methods

Attributes

   readonly attribute somOffsets somInstanceDataOffsets

_get_somInstanceDataOffsets returns a sequence of structures, each of which indicates an ancestor of the receiver class (or the receiver class itself) and the offset to the beginning of the instance data introduced by the indicated class in an instance of the receiver class. The somOffsets information can be used in conjunction with information derived from calls to a SOM Interface Repository to completely determine the layout of SOM objects at runtime.

C++ Example

#include <somcls.xh>
main()
{
   int i;
   SOMClassMgr *scm = somEnvironmentNew();
   somOffsets so = _SOMClass->_get_somInstanceDataOffsets();
   for (i=0; i
      printf("In an instance of SOMClass, %s data starts at %d\n",
                so._buffer[i]->cls->somGetName(),
                so._buffer[i]->offset);
}

Introduced Methods

The following list shows all the SOMClass introduced methods.

Group: Instance Creation (Factory)

Group: Initialization/Termination