next up previous contents
Next: 2.3.4 Interface Structure Up: 2.3 Structures of the Previous: 2.3.2 Model Structure


2.3.3 Model Instances

Model class instances which can be evaluated on the purpose to compute the results of a certain algorithm can be generated in three distinct ways:

traditional: The traditional way of instantiating a Model class like ordinary C++ classes offers the least functionality. Its main restriction is that it works only with classes defined in C++. The only way in which such Model instances can be accessed by MDL expressions is by using their automatically generated instance name to access their interface parameters or MDL methods.
new by class name: The Algorithm Library provides the possibility of instantiation Model and Parameter classes by using their respective MDL class type. The according Algorithm Library functions return a C++ pointer to the parent class AnyParameter in case of parameter instantiations, or to the virtual/primary Model parent class of a model instantiation.
instance name: The third method of instantiating Model classes is to request a pointer to the virtual/primary Model parent class with a certain instance name. The actual class type of this model instance is determined at runtime by using either the mdlDefineDefaultInstance function of the Algorithm Library within the application, or by using the Instance MDL command (Section 3.3).

The polymorphic Model pointer resulting from instantiating a Model class by using either its class name or its instance name may represent Model classes of two different ``flavors''. The first possibility is that the pointer references a Model object defined in C++. In this case the pointer can safely be casted using the standard C++ runtime type identification and dynamic cast mechanism. The second possibility is that the pointer references a Model class defined by using the MDL interpreter.

Both instantiation methods provide the possibility of checking whether the generated Model instance is a Model of a specific MDL class type or derived from a certain required MDL class type. Thus the inheritance tree formed by the Model definitions (Fig. 2.4) is used to classify the various Model classes and is used by the Algorithm Library to check that instantiated Model objects fulfill the type requirements for the accompanying interface of the Model instance.


next up previous contents
Next: 2.3.4 Interface Structure Up: 2.3 Structures of the Previous: 2.3.2 Model Structure
Robert Mlekus
1999-11-14