Object-Oriented Programming Using SOM and DSOM:Understanding the Basics:SOMClass, The Root of all SOM Metaclasses
A SOM class defines the implementation of a SOM object. Every SOM object is an instance of a SOM class. In contrast to object-oriented languages such as C++, SOM classes are also represented as objects at run-time. Classes can have their own variables and methods. These objects are called class objects. Their variables are called class variables (to distinguish them from instance variables ), and their methods are called class methods (to distinguish them from instance methods).
Just like an object is an instance of a class, a class object is an instance of another class, called a metaclass.
A class defines instance methods to which its objects respond. A metaclass defines class methods to which a class object responds. Class methods perform class-related operations such as creating new instances of a class, maintaining a count of the number of instances of the class, and other operations of a supervisory nature.
SOMClass is the root class for all SOM metaclasses. All SOM metaclasses must be subclasses of SOMClass or of some other class derived from SOMClass. SOMClass introduces a number of methods that define the behavior common to all SOM class objects. The default metaclass for every class is SOMClass.
SOMClass provides the somNew method for creating a new instance of a class. When you invoke <className>New() in C or new <className> in C++ to create an instance of <className>, the bindings invoke somNew on the specified class. The somNew method allocates space for the new class object. It then calls somInit to initialize the newly created object and returns a pointer to it.
SOMClass also provides a number of methods for obtaining infomation about a class at run-time. For example, you can use these methods to find the methods the class supports, its relationships with other classes, or its version number. As we will see later in this book, SOM's implementation of classes as objects gives us a lot of flexibility at run-time.