Changeset 2598 in Sophya for trunk/SophyaLib/SysTools/cexpre.cc


Ignore:
Timestamp:
Aug 11, 2004, 3:10:25 PM (21 years ago)
Author:
ansari
Message:

Documentation (ajoutee ou completee) pour les classes du module SysTools - Reza 11 Aout 2004

File:
1 edited

Legend:

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

    r2593 r2598  
    6868//---------------------------------------------------------
    6969//-----------  Expression changement de signe -------------
     70/*!
     71  \internal
     72  \ingroup SysTools
     73  \brief Class for handling change sign expression (-x)
     74  \sa CExpressionEvaluator
     75*/
    7076class CE_ChsExp : public CExprBase {
    7177public:
     
    8086
    8187//---------------------------------------------------------
     88/*!
     89  \internal
     90  \ingroup SysTools
     91  \brief Base class for binary operations on expressions
     92  \sa CExpressionEvaluator
     93*/
    8294class CE_BinExp : public CExprBase {
    8395public:
     
    119131
    120132//---------------------------------------------------------
     133/*!
     134  \internal
     135  \ingroup SysTools
     136  \brief Addition of two CExprBase (binary operation : x+y)
     137  \sa CExpressionEvaluator
     138*/
    121139class CE_AddExp : public CE_BinExp {
    122140public:
     
    125143 }
    126144};
     145/*!
     146  \internal
     147  \ingroup SysTools
     148  \brief Multiplication of two CExprBase (binary operation : x*y)
     149  \sa CExpressionEvaluator
     150*/
    127151class CE_MulExp : public CE_BinExp {
    128152public:
     
    130154  virtual double Evaluate() const { CheckThrow("CE_MulExp::Evaluate"); return _e1->Evaluate()*_e2->Evaluate(); }
    131155};
     156/*!
     157  \internal
     158  \ingroup SysTools
     159  \brief Subtraction of two CExprBase (binary operation : x-y)
     160  \sa CExpressionEvaluator
     161*/
    132162class CE_SubExp : public CE_BinExp {
    133163public:
     
    135165  virtual double Evaluate() const { CheckThrow("CE_SubExp::Evaluate"); return _e1->Evaluate()-_e2->Evaluate(); }
    136166};
     167/*!
     168  \internal
     169  \ingroup SysTools
     170  \brief Division of two CExprBase (binary operation : x/y)
     171  \sa CExpressionEvaluator
     172*/
    137173class CE_DivExp : public CE_BinExp {
    138174public:
     
    149185//---------------------------------------------------------
    150186#define FMXARG 3
     187/*!
     188  \internal
     189  \ingroup SysTools
     190  \brief Function evaluation on other expression in the form f(), f(x), f(x,y), f(x,y,z)
     191  \sa CExpressionEvaluator
     192*/
    151193class CE_FuncExp : public CExprBase {
    152194public:
     
    169211
    170212// Les fonctions de generation de nombre aleatoire
    171 double _CE_rand01() { return drand01(); }
    172 double _CE_randpm1() { return drandpm1(); }
    173 double _CE_gaurand() { return GauRnd(0., 1.); }
     213static double _CE_rand01() { return drand01(); }
     214static double _CE_randpm1() { return drandpm1(); }
     215static double _CE_gaurand() { return GauRnd(0., 1.); }
    174216//---------------------------------------------------------
    175217CE_FuncExp::CE_FuncExp(string const & func)
     
    265307
    266308//---------------------------------------------------------
     309/*!
     310  \class CExpressionEvaluator
     311  \ingroup SysTools
     312  \brief Class for evaluation of arithmetic expressions with C-like syntax.
     313
     314  This classes can handle the parsing of c-like arithmetic
     315  expressions containing numerical constants, the four
     316  basic operations (addition +, subtraction -, multiplication *,
     317  division /) and functions.
     318  The numerical constants are also defined <tt> (Pi = M_PI E = M_E) </tt>.
     319  The following functions from the standard math library and
     320  random generators are available:
     321 
     322  - sqrt fabs floor hypot
     323  - exp log log10 pow
     324  - sin cos tan asin acos atan atan2
     325  - sinh cosh tanh
     326  - rand01() : Flat random number generator in the range [0 1]
     327  - randpm1() : Flat random number generator in the range [-1 1]
     328  - gaurand() : Gaussian random number generator (m=0, sigma=1)
     329
     330  Usage example :
     331  \code
     332  #include "cexpre.h"
     333  ...
     334  string es = "4.+3*(cos(Pi/8.)+1.5)";
     335  CExpressionEvaluator e(es);
     336  cout << " Expression: " << e << " = " << e.Evaluate() << endl;
     337  \endcode
     338
     339  Output : \n
     340  <tt>  Expression: (4+(3*(cos((3.14159/8))+1.5))) = 11.2716 </tt>
     341*/
     342
     343/*!
     344  Parse the string \c sex and builds an expression.
     345  Can throw CExprException exception.
     346*/
    267347CExpressionEvaluator::CExpressionEvaluator(string const & sex)
    268348{
     
    293373
    294374// cette fonction rearrange le stack des operations binaires en attente
    295 CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex, CE_BinExp* nbx)
     375static CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex, CE_BinExp* nbx)
    296376{
    297377  while ( !sbx.empty() && (nbx->Priority() <= sbx.top()->Priority()) ) {
     
    305385
    306386// cette fonction rearrange le stack des operations binaires en attente
    307 CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex)
     387static CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex)
    308388{
    309389  if (sbx.empty())  return cex;
Note: See TracChangeset for help on using the changeset viewer.