file: ../SURF/parameter.h

#include <LEDA/array.h> #include <sys/timeb.h> #include <LEDA/string.h> //created by John Langford (jl@crush.caltech.edu) //the idea of this class is to have a variable who's contents will //be recalculated everytime one of the thing's it is dependent on is reset. //The method used is vulnerable to dependencies on yourself... be careful. //This class allows a regular system of equations to be set up in such a way //that the code for the equation will only be written once. //It is recommended that if one variable in a system of equations is a //OVERLOAD CALL: if: parameter.cc(?), parameter.cc(?) //parameter, all variables should be made parameters. //otherwise the dependency checking will fail pretty miserably. //I have set up this class to have fast read and slow write. class parameter { private: bool value_good; //whether or not the current value of val is good //used for detection of dependencies between //parameters. static parameter* detector; static bool detecting; //when a dependent parameter is added to a system of //equations, the defining equation is called //with detecting set to true. This allows //setting up of dependencies. static bool deleting; //When an equation is deleted this is used to detect and delete dependencies //on or by other parameters. int location(const parameter *target); //finds the particular parameter in //dependents (see below) == target and returns the index. protected: string nme;//name of parameter bool determined;//whether or not the parameter is determined or free double val;//the value of the parameter double (*valmake)(); //if (determined) val=valmake() //OVERLOAD CALL: if: parameter.cc(?), parameter.cc(?) //else valmake=NULL and val must be set with setvalue (a public method) array<parameter*> dependents; //if (determined) dependents=all parameters upon which you are dependent //OVERLOAD CALL: if: parameter.cc(?), parameter.cc(?) //else dependents=all the parameters which are dependent on your value. public: parameter& operator=(const parameter& from);//standard method //the important thing to note here is that because of dependency structures //from is no longer valid after a "this=from" statement. In other words //there is a conservation of parameters through operator= //various constructors parameter(const string& newname,const double& newval); //OVERLOAD CALL: parameter: parameter.cc(parameter), parameter.cc(parameter), parameter.cc(parameter) //used for free parameters //used for dependent parameters parameter(const string& newname, double (*newmake)()); //OVERLOAD CALL: parameter: parameter.cc(parameter), parameter.cc(parameter), parameter.cc(parameter) //Only around to make a good default parameter(); //OVERLOAD CALL: parameter: parameter.cc(parameter), parameter.cc(parameter), parameter.cc(parameter) //used to output all the fields of a parameter. void print(); //OVERLOAD CALL: print: event.cc(event), parameter.cc(parameter) //gets rid of alot of context modifiers. operator double(); //relatively straightforward parameter modification functions const string& name(){return nme;}; void setdependents(array<parameter *>& newdep); void setvalue(const double& newval); void setmake(double (*newmake)()); };


Back to Source File Index


C++ to HTML Conversion by ctoohtml