class Inheritance


The SCATMECH library makes heavy use of class inheritance. In order to aid run-time creation of instances of these classes, it is helpful to have a database of all the child classes for any parent class. The class Inheritance enables such a database of the inheritance structure of a class. Thus, each class which is part of an inheritance structure has a static data member

static Inheritance inheritance;

and a virtual member function

virtual Model* clone() const;

This static member contains pointers to all of the class' children. A macro Get_Model(_Model) creates a menu, from which a user can chose a child class of Model, and returns a pointer to a _Model. Another macro Get_Named_Model(_Model,name) returns a _Model named name.

Include file:

#include "inherit.h"

Source code:

inherit.cpp

See also:

SCATMECH HomeBRDF_ModelSphericalScattererPSD_FunctionSlope_Distribution_FunctionShadow_FunctionPhase_Function

Definition of public elements:

class Inheritance {
    Inheritance(const string& name,const string& description);
    string get_name();
    string get_description();
    Model* get_model();
    Model* get_named_model(const string& name);

    bool is_virtual() const;
    bool is_instantiable() const;

    const Inheritance* get_named_inheritance(const std::string& model) const;
    const InheritanceList& get_children() const;
    const Inheritance* get_parent_inheritance() const;
    void get_parameters(ModelParameterList& result,bool top=true) const;
    const ModelParameterBase* get_modelparameter(const std::string& param) const;
    Model* make() const;
    Model* clone(const Model& m) const;

    void Register_Model();
};

#define Get_Model(_Model)            _Model::inheritance.Get_Model()
#define Get_Named_Model(_Model,name) _Model::inheritance.Get_Named_Model(name)
#define Register_Model(_Model)       _Model::inheritance.Register_Model()

void Register_SCATMECH_Models();

Inheritance(const string& name,const string& description)

The class constructor takes two arguments of type string, one which gives the model's name and the other the model's description.

Top of Page

string get_name()
string get_description()

These functions returns strings with the name of the class or its description.

Top of Page

Model* get_model()
macro Get_Model(_Model)

This function and macro return a pointer to a new instantiation of Model. They present the user with a menu with all registered classes inheriting Model and will prompt the user for model parameters.

Top of Page

Model* get_named_model(const string& name)
macro Get_Named_Model(_Model,const string& name)

This function and macro return a pointer to a new instantiation of Model. They return a pointer to a Model whose name matches name and does not prompt the user for model parameters.

Top of Page

void Register_Model()
macro Register_Model(_Model)
void Register_SCATMECH_Models()

The first of these functions registers the existence of this Model with its Parent. The second of these functions registers all models in the SCATMECH library with their parents.

Top of Page


For More Information

SCATMECH Technical Information and Questions
Sensor Science Division Home Page
Sensor Science Division Inquiries
Website Comments

Current SCATMECH version: 7.22 (April 2021)