next up previous
Next: Iterators Up: C++ Design For Research Previous: Associated Functions

Examples (AppModel Library)

The TC_VectorModelBase represents mappings from one vector space (eg parameters) to another:
\\ Declare classes only refered to by pointer/reference:
class TC_MVPDFBase;
class TC_VectorModelBuilderBase;

class TC_VectorModelBase {
    TC_MVPDFBase 		*_param_density;
    TC_VectorModelBuilderBase 	*_builder;

    TC_VectorModelBase(const TC_VectorModelBase&);
    TC_VectorModelBase& operator=(const TC_VectorModelBase&);
    virtual ~TC_VectorModelBase();

    virtual void instance(RD_Vector& x, const RD_Vector& b) =0;
    virtual void params(RD_Vector& b, const RD_Vector& x) =0;
    // Distribution of parameters:
    const TC_MVPDFBase& paramDensity() const;

    const TC_VectorModelBuilderBase& builder();

    // Standard IO
    short versionNo() const;
    virtual const string& isA() const =0;
    virtual TC_VectorModelBase* clone() const = 0;
    virtual void print(ostream& os) const;
    virtual void save(RD_Bfstream& bfs) const;
    virtual void load(RD_Bfstream& bfs);

This demonstrates:

class TC_VectorModelBase;

class TC_VectorModelBuilderBase {
    virtual ~TC_VectorModelBuilderBase() {};

    virtual void build(TC_VectorModelBase& model, 
                        TC_VectorDataBase& data) =0;

    // Standard IO
    virtual const string& isA() const = 0;

Tim Cootes