parsedFunction.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: parsedFunction.h,v 1.9 2003/12/19 14:54:08 anne Exp $
00005 //
00006 
00007 #ifndef BALL_MATHS_PARSEDFUNCTION_H
00008 #define BALL_MATHS_PARSEDFUNCTION_H
00009 
00010 #ifndef BALL_DATATYPE_STRINGHASHMAP_H
00011 # include <BALL/DATATYPE/stringHashMap.h>
00012 #endif
00013 
00014 #include <numeric>
00015 
00016 using std::unary_function;
00017 
00018 namespace BALL
00019 {
00023   extern StringHashMap<double*> *ParsedFunctionConstants;
00024   extern StringHashMap<double (*)(double)> *ParsedFunctionFunctions;
00025   
00033   template <typename arg> 
00034   class ParsedFunction 
00035     : public unary_function<arg, double> 
00036   {
00037     public:
00041   
00043       ParsedFunction();
00044   
00046       ParsedFunction(const String& expression);
00047       
00049       ParsedFunction(const ParsedFunction& func);
00050       
00052       ~ParsedFunction();
00053       
00055       
00061       double operator () (arg p) throw(Exception::ParseError);
00062     
00064 
00070       void initTable();
00072   
00075       StringHashMap<double*> constants_;
00076   
00079       StringHashMap<double (*)(double)> functions_;
00080     
00081     protected:
00082       String expression_;
00083   };
00085 }
00086 
00087 #endif // BALL_MATHS_PARSEDFUNCTION_H