next up previous contents
Next: A.5. Model Definition Up: A. A Tiny Algorithm Previous: A.3. MDL Function Definition


A.4. Parameter Definition

The results obtained by the function plotting Model described in Appendix A.6 are stored in an Parameter of the type MdlDblmap which implements a map associating the dependent and independent variables of the function to be plotted. Example A.6 and Example A.7 depict the declaration respectively definition of the according C++ class as described in Section 2.3.1. To keep the source code examples short only the array subscript operator '[]' is defined.

\includegraphics[width=0.6cm]{figures/exaLeft.eps}

#include "map.hh"

class MdlDblmap {
private:
   Map<double,double> dict;
public:
   MdlDblmap(){};             
   ~MdlDblmap(){};            
   MdlDblmap(const MdlDblmap&);
   MdlDblmap& operator=(const MdlDblmap&);
   double& operator[](const double&);
};

Example A.6: C++ header file for the definition of MDL Parameters

\includegraphics[width=0.6cm]{figures/exaLeft.eps}

#include "mdldblmap.hh"

MdlDblmap::MdlDblmap(const MdlDblmap& orig) : dict(orig.dict) {}

MdlDblmap& MdlDblmap::operator=(const MdlDblmap& orig) {
   dict = orig.dict;
   return *this;
}

double& MdlDblmap::operator[](const double& which) {
   return dict[which];
}

Example A.7: C++ source file for the definition of MDL Parameters

The UNFUG tuple file required for the notification of the new Parameters type to the Algorithm Library structures and the complying extension of the MDL language is listed in Example A.8. It results from replacing the appropriate place holders ParLibName, opTupleName, ... in the UNFUG tuple file template Example 2.5.

Listing the VMAKE makefile for this Parameter extension library is omitted, since its derivation from the according template given in Example 2.7 can be done analogously to the derivation of the makefile for the function extension library (Example A.5) described in Appendix A.3.

\includegraphics[width=0.6cm]{figures/exaLeft.eps}

; A symbolic Library Name
(defun LocalParamLibraryName () "TinyAlibParExtLib")

; Definition of parameter types 'MdlDblmap'
(tuple
  '(LocParameter::instances
   (vClass      ( header          vAlias       scan   print   
                                               instantiate newArg ))
   ("MdlDblmap" ( "mdldblmap.hh"  "MdlDblmap"  NIL    NIL     
                                               t           NIL    ))
))

; Definition of operator 'double MdlDblmap[double]'
(tuple
 '(MDL::op_ArraySubscript
   (resType  op1Type     op2Type  isAlias resAlias   
            op1Alias     op2Alias     ( left  oper    right   ))
   ("double" "MdlDblmap" "double" NIL     "double"   
            "MdlDblmap"  "double"     ( NIL   NIL     NIL     ))
   ))

Example A.8: UNFUG tuples for these MDL Parameters


next up previous contents
Next: A.5. Model Definition Up: A. A Tiny Algorithm Previous: A.3. MDL Function Definition
Robert Mlekus
1999-11-14