Changeset 4063 in Sophya for trunk/SophyaLib/SysTools/cexpre.h


Ignore:
Timestamp:
Apr 27, 2012, 12:34:31 AM (13 years ago)
Author:
ansari
Message:

Introduction de la classe interface CE_VarListInterface et modifs classe CExpressionEvaluator pour permettre l'inclusion de variables nommees dans les expressions traitees par CExpressionEvaluator, adaptation de la classe Commander afin que les variables de l'interpreteur soit visible par l'evaluateur CExpressionEvaluator, Reza 27/04/2012

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/cexpre.h

    r3586 r4063  
    99#include <iostream>
    1010#include <string>
     11#include <vector>
     12#include <map>
    1113#include "pexceptions.h"
    1214
     
    4648};
    4749
     50
    4851/*!
    4952  \ingroup SysTools
     
    5356  {  ex.Print(s);  return(s);  }
    5457
     58/*!
     59  \ingroup SysTools
     60  \brief Interface class used by the CExpressionEvaluator class to represent a list of variables
     61  or named values accessible trough a pointer.
     62
     63  Inherited class should define the \b GetVarPointer() method, and can optionaly redefine
     64  the \b Update() method.
     65  \sa CExpressionEvaluator
     66*/
     67class CE_VarListInterface {
     68public:
     69  //! To be called to update values corresponding to the pointers. Default implementation does nothing.
     70  virtual void Update() { return; }
     71  //! Return a pointer to a double containing the value associated with \t name. 
     72  virtual double* GetVarPointer(std::string const& name) = 0;
     73};
     74
     75
    5576class CE_BinExp;
    5677class CE_FuncExp;
     
    5879class CExpressionEvaluator : public CExprBase {
    5980public:
    60   CExpressionEvaluator(string const & sex);
     81  CExpressionEvaluator(const char* sexp, CE_VarListInterface* pvlist=NULL);
     82  CExpressionEvaluator(string const & sex, CE_VarListInterface* pvlist=NULL);
     83
    6184  virtual ~CExpressionEvaluator();
    6285//! Evaluate the expression and returns the corresponding value.
     
    6891
    6992protected:
     93//! Parse variable names or constants and return CE_NumberExp object.
     94  CExprBase* VarNameOrNumber(string const & s);
    7095//! Does the parsing and builds an CExprBase object.
    7196  CExprBase* ParseString(int extype, string fname, string const & sex,
     
    7398
    7499  CExprBase * _exp;
     100  CE_VarListInterface* _varlist;
    75101};
    76102
Note: See TracChangeset for help on using the changeset viewer.