Changeset 2598 in Sophya for trunk/SophyaLib/SysTools


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

Location:
trunk/SophyaLib/SysTools
Files:
14 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;
  • trunk/SophyaLib/SysTools/cexpre.h

    r2512 r2598  
    1414namespace SOPHYA {
    1515
    16 //! Exception class used by  CExpressionEvaluator
     16/*!
     17  \ingroup SysTools
     18  \brief Exception class used by  CExpressionEvaluator
     19*/
    1720class CExprException : public PException {
    1821  public:
     
    2225
    2326//--------------------------------------------------------------------
    24 //! Base class for arithmetic expressions used by CExpressionEvaluator
     27/*!
     28  \ingroup SysTools
     29  \brief Base class for arithmetic expressions used by CExpressionEvaluator
     30  \sa CExpressionEvaluator
     31*/
    2532class CExprBase {
    2633public:
     
    3946};
    4047
     48/*!
     49  \ingroup SysTools
     50  \brief For formatted write (print) of expressions in a stream
     51*/
    4152inline ostream& operator << (ostream& s, CExprBase const & ex)
    4253  {  ex.Print(s);  return(s);  }
     
    4556class CE_FuncExp;
    4657//---------------------------------------------------------
    47 //! Class for evaluation of arithmetic expressions with C-like syntax
    4858class CExpressionEvaluator : public CExprBase {
    4959public:
    5060  CExpressionEvaluator(string const & sex);
    5161  virtual ~CExpressionEvaluator();
     62//! Evaluate the expression and returns the corresponding value.
    5263  virtual double Evaluate() const;
     64//! Alias for Evaluate()
    5365  inline double Value() const { return Evaluate(); }
     66//! Formatted output on a stream
    5467  virtual void  Print(ostream& os) const;
    5568
    5669protected:
     70//! Does the parsing and builds an CExprBase object.
    5771  CExprBase* ParseString(int extype, string fname, string const & sex,
    5872                    size_t off, size_t& stop, string& errmsg);
  • trunk/SophyaLib/SysTools/commander.cc

    r2532 r2598  
    2525// ------------------------------------------------------------
    2626/*!
     27  \internal
    2728  \class SOPHYA::CommanderBloc
    2829  \ingroup SysTools
    29   Class for internal use by SOPHYA::Commander to handle loops
     30  Class for internal use by class Commander to handle loops
    3031*/
    3132class CommanderBloc {
     
    253254
    254255/*!
     256  \internal
    255257  \class SOPHYA::CommanderScript
    256258  \ingroup SysTools
    257   Class for internal use by SOPHYA::Commander to handle functions
     259  Class for internal use by class Commander to handle functions
    258260  or scripts
    259261*/
     
    334336
    335337/*!
    336   \class SOPHYA::Commander
     338  \class Commander
    337339  \ingroup SysTools
    338   Simple command interpreter with c-shell like syntax and dynamic
    339   load capabilities. Can be used to add scripting capabilities
    340   to applications
     340  \brief Simple command interpreter
     341
     342  This Simple command interpreter with c-shell like syntax
     343  can be used to add scripting capabilities
     344  to applications.
     345
     346  Although the insterpreter has many limitations compared to
     347  c-shell, or Tcl , it provides some interesting possibilities:
     348
     349  - Extended arithmetic operations (c-like and RPN)
     350  - Simple and vector variables
     351  - Script definition
     352  - Dynamic Load
     353
     354  \sa CmdExecutor CExpressionEvaluator RPNExpressionEvaluator
     355
     356  Usage example:
     357  \code
     358  #include "commander.h"
     359  ...
     360  Commander cmd;
     361  char* ss[3] = {"foreach f ( AA bbb CCCC ddddd )", "echo $f" , "end"};
     362  for(int k=0; k<3; k++) {
     363    string line = ss[k];
     364    cmd.Interpret(line);
     365  }
     366  \endcode
    341367*/
    342368
     
    345371static Commander* cur_commander = NULL;
    346372/* --Methode-- */
     373//! Default constructor. Initializes variable list and copies \c history.pic to \c hisold.pic
    347374Commander::Commander()
    348375{
     
    488515
    489516/* --Methode-- */
     517//! Returns the string \c Commander as the interpreter's name.
    490518string Commander::Name()
    491519{
     
    494522
    495523/* --Methode-- */
     524//! Add the \b grp help group with description \b desc.
    496525void Commander::AddHelpGroup(string& grp, string& desc)
    497526{
     
    501530
    502531/* --Methode-- */
     532/*!
     533  \brief Register a command executor associated with a given keyword.
     534  \param keyw : keyword identifying the command
     535  \param usage : the command help and usage information
     536  \param ce : CmdExecutor pointer for this a command. The same object can be registered
     537  multiple time for different commands.
     538  \param grp : The help group corresponding to this command.
     539*/
    503540void Commander::RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, string& grp)
    504541{
     
    517554
    518555/* --Methode-- */
     556/*!
     557  \brief Register a help text.
     558  \param keyw : help keyword
     559  \param usage : help text
     560  \param grp : help group
     561*/
    519562void Commander::RegisterHelp(string& keyw, string& usage, string& grp)
    520563{
     
    548591
    549592/* --Methode-- */
     593/*!
     594  \brief  Dynamic loader for modules
     595
     596  A module is a shared library extending the application functionalities.
     597  Typically, a module adds new commands to the interpreter. Once loaded,
     598  the module is activated (initialized) by calling a function with the
     599  name \b modulename_init . This function should be declared extern C
     600  to avoid C++ name mangling. A cleanup function \b modulename_end
     601  is called by the Commander destructor.
     602
     603  \param fnameso : Shared library name containing the module functions
     604  and classes.
     605  \param name : Module name. This string is used to form module
     606  initializer and cleanup function name \c name_init \c name_end
     607*/
    550608void Commander::LoadModule(string& fnameso, string& name)
    551609{
     
    569627
    570628/* --Methode-- */
     629//! Declare a new interpreter
    571630void Commander::AddInterpreter(CmdInterpreter * cl)
    572631{
     
    575634
    576635/* --Methode-- */
     636//! Select an interpreter by its name. The corresponding Interpret method is then called
    577637void Commander::SelInterpreter(string& name)
    578638{
     
    594654
    595655/* --Methode-- */
     656/*!
     657  \brief Method which has to be invoked to interpret a giev command line or string.
     658*/
    596659int Commander::Interpret(string& s)
    597660{
     
    18941957
    18951958/* --Methode-- */
     1959//! Produces a LaTeX file containing the registered command helps
    18961960void Commander::HelptoLaTeX(string const & fname)
    18971961{
  • trunk/SophyaLib/SysTools/commander.h

    r2518 r2598  
    2727// Classe definissant l'interface pour un interpreteur de commande
    2828
    29 //! Interface definition for a generic command interpreter
     29/*!
     30  \ingroup SysTools
     31  \brief  Interface definition for a generic command interpreter.
     32*/
    3033class CmdInterpreter {
    3134public:
    3235  virtual               ~CmdInterpreter() {} ;
     36//! Returns the interpreter's name
    3337  virtual string        Name()=0;
     38//! Method to be called in order to interpret a line or string.
    3439  virtual int           Interpret(string& line)=0;
    3540};
    3641
    3742
    38 //! Interface definition for command executor, to be used with SOPHYA::Commander
     43/*!
     44  \ingroup SysTools
     45  \brief Interface definition for command executor, to be used with Commander
     46
     47  A command is defined by a keyword and a number of argument
     48*/
    3949
    4050class CmdExecutor {
     
    159169
    160170// Pour enregistrer la liste de commandes et leurs executeurs et le help
     171//! Command executor registration - For Commander internal use
    161172  struct cmdex {int group; string us; CmdExecutor * cex; } ;
     173//! Help text registration - For Commander internal use
    162174  struct hgrpst {int gid; string desc; } ;               // Identification+description d'un groupe de help
    163175  typedef map<string, hgrpst, less<string> > CmdHGroup;   // Liste des groupes de commandes
  • trunk/SophyaLib/SysTools/ctimer.cc

    r913 r2598  
    11//
    2 // $Id: ctimer.cc,v 1.4 2000-04-13 15:58:37 ansari Exp $
     2// $Id: ctimer.cc,v 1.5 2004-08-11 13:10:25 ansari Exp $
    33//
    44
     
    4040  \class SOPHYA::Timer
    4141  \ingroup SysTools
     42  \brief Simple chronometer for CPU and elapsed time measurements.
    4243  This class implements a simple chronometer which can be used for
    4344  measuring the CPU and elapsed time in functions. The constructor
  • trunk/SophyaLib/SysTools/cxxcmplnk.cc

    r2496 r2598  
    1010  This classes handles the compilation of a C++ source code and
    1111  building of a shared library.
    12   The present version has been adapted for different compilers:
    13   g++ , Compaq/Digital cxx , SGI CC , KCC .
     12  The present version has been adapted for different compilers and
     13  systems:
     14  - Linux-g++
     15  - Linux-KCC
     16  - MacOS X/Darwin (Apple OS X 10.2 and 10.3)
     17  - OSF-cxx : (HP/Compaq/Digital OSF-Tru64 and cxx c++ compiler)
     18  - SGI-CC : Silicon Graphics system and C++ compiler
     19
    1420  \sa SOPHYA::PDynLinkMgr
     21
    1522  \code
    1623  #include "cxxcmplnk.h"
  • trunk/SophyaLib/SysTools/pdlmgr.cc

    r2498 r2598  
    2626  This classes handles the run-time operations related to using shared
    2727  libraries. The present version has been adapted for different Unix
    28   flavours (Linux, Compaq/Digital Unix, SGI IRIX, IBM AIX, Sun Solaris,
    29   MacOS X/Darwin).
     28  flavours (Linux, HP/Compaq/Digital OSF-Tru64, SGI IRIX, IBM AIX, Sun Solaris,
     29  MacOS X/Darwin). \n
     30  For MacOS X/Darwin, the NSxxx API
     31  <tt> (NSLinkModule , NSCreateObjectFileImageFromFile, ...) </tt>
     32  is used.
    3033  The example here shows the linking of shared library named "mylib.so"
    3134  containing a function \c double \c myfunction(double x).
  • trunk/SophyaLib/SysTools/psighand.cc

    r2508 r2598  
    1313/* Nouvelle-Fonction */
    1414/*!\ingroup  SysTools
     15   \brief Utility function for signal handling configuration.
     16
    1517   Configures signal handling. When the flag is true, an exception
    1618   \b CaughtSignalExc is thrown with the excpetion id set to the
  • trunk/SophyaLib/SysTools/resusage.cc

    r2487 r2598  
    3737  Constructor. the \b Update() method is called.
    3838  \param pg: Process group RU_Self or RU_Children or RU_All
     39  - pg = RU_Self : Resource usage for the process itself
     40  - pg = RU_Children : Resource usage for the child processes
     41  - pg = RU_All : resource usage for the process itself and its child processes
    3942*/
    4043ResourceUsage::ResourceUsage(RU_ProcGrp pg)
  • trunk/SophyaLib/SysTools/resusage.h

    r2487 r2598  
    1717{
    1818public:
     19/*!
     20  - RU_Self : Resource usage for the process itself
     21  - RU_Children : Resource usage for the child processes
     22  - RU_All : resource usage for the process itself and its child processes
     23*/
    1924  enum RU_ProcGrp {RU_Self=0, RU_Children=1, RU_All=2};
    20   // RU_Self: Resource usage for the process itself
    21   // RU_Children: Resource usage for the child processes
    22   // RU_All: Process itself and child processes
     25
    2326  ResourceUsage(RU_ProcGrp pg=RU_Self);
    2427  ~ResourceUsage();
  • trunk/SophyaLib/SysTools/rpneval.cc

    r2596 r2598  
    1010
    1111/*!
    12   \class SOPHYA::RPNExpressionEvaluator
     12  \class RPNExpressionEvaluator
    1313  \ingroup SysTools
    1414  Arithmetic expression (double precision float) evaluator
    1515  in Reverse Polish Notation (RPN). This is an HP calculator
    1616  like syntax. Space are used for separating the string
    17   expression into tokens.
     17  expression into tokens. \n
     18  The string parsed by RPNExpressionEvaluator should be
     19  formed by a set of space separated words. Each word may be
     20  a numerical constant or operation or function.
     21  All numeriacl constants are pushed to stack top.
     22  The stack is limited only
     23  by the available memory. The three numbers on the stack top
     24  are referred to as <tt> x y x </tt>. \n
     25  Available operations:
     26  - op= + - * / % : replace (x,y) by x.op.y
     27  - e pi : M_PI , M_E numerical constants
     28  - f= sin cos tan asin acos atan : replace x by f(x)
     29  - f= chs sqrt sq : (x<-f(x)) change-sign , square root and square (x<-x^2) operations
     30  - f= log log10 exp : replace x by f(x)
     31  - f= fabs floor ceiling : replace x by f(x)
     32  - f= deg2rad rad2deg : replace x by f(x)
     33  - f= rand01 randpm1 gaurand : pushes a random number on the stack top ([0 1] [-1 1] Gaussian)
     34  - print x<>y pop push : stack operations
     35  - sum product : Replace the complete stack by the sum / product of the numbers in the stack
     36  - mean sigma : Replace the complete stack by the mean / sigma of the numbers in the stack
     37
     38  \sa CExpressionEvaluator Commander
     39
     40  The following output is produced by the sample code below:
     41  \code
     42  #include "rpneval.h"
     43  ...
     44  RPNExpressionEvaluator rpn1("4 2 print + 3 * ");
     45  cout << "RPN1: 4 2 + 3 * -> rpn1.Value() = " << rpn1.Value() << endl; 
     46  RPNExpressionEvaluator rpn2("1 2 3 4 5 sum");
     47  cout << "RPN2: 1 2 3 4 5 sum -> rpn2.Value() = " << rpn2.Value() << endl;
     48  \endcode
     49
     50  Output:
     51  \verbatim
     52  RPNExpressionEvaluator::PrintStack() Size()= 2
     53      0:  2   (x)
     54      1:  4   (y)
     55  RPN1: 4 2 + 3 * -> rpn1.Value() = 18
     56  RPN2: 1 2 3 4 5 sum -> rpn2.Value() = 15 
     57  \endverbatim
    1858*/
    1959
     60/*!
     61  \brief Parses the string \b sex into words and perform the specified operations on the stack.
     62
     63  Can throw  RPNExprException
     64*/
    2065RPNExpressionEvaluator::RPNExpressionEvaluator(string const & sex)
    2166{
     
    3378}
    3479
     80/*!
     81  \brief Perform the operations specified by \b on the stack, starting from element \b exe[off]. 
     82
     83  Can throw  RPNExprException
     84*/
    3585RPNExpressionEvaluator::RPNExpressionEvaluator(vector<string> & exe, int off)
    3686{
     
    52102/* Operations sur le stack RPN */
    53103/* --Methode-- */
     104//! Return the stack top (x)
    54105double RPNExpressionEvaluator::Evaluate() const
    55106{
  • trunk/SophyaLib/SysTools/rpneval.h

    r2510 r2598  
    1515namespace SOPHYA {
    1616
    17 //! Exception class used by  RPNExpressionEvaluator
    18 
     17/*!
     18  \ingroup SysTools
     19  \brief Exception class used by  RPNExpressionEvaluator
     20  \sa RPNExpressionEvaluator
     21*/
    1922class RPNExprException : public PException {
    2023  public:
     
    3033  explicit RPNExpressionEvaluator(vector<string> & exe, int off=0);
    3134  virtual ~RPNExpressionEvaluator();
     35//! Return the stack top \c (x) as the result of the expression evaluation
    3236  virtual double Evaluate() const;  // Return the value of the stack top
     37//! Alias for Evaluate()
    3338  inline double Value() const { return Evaluate(); }
    3439
    35 protected:
     40private:
    3641  int EvalRPNExpr(vector<string> & args, int off=0);
    3742  inline bool CheckStack(double& x) const
  • trunk/SophyaLib/SysTools/zthread.cc

    r2487 r2598  
    99  \class SOPHYA::ZThread
    1010  \ingroup SysTools
     11  \brief Simple class for creating and controlling threads.
     12
    1113  This class provides an interface for creating and controlling threads.
    1214  The implementation uses the POSIX thread interface.
     
    130132  \class SOPHYA::ZMutex
    131133  \ingroup SysTools
     134  \brief Wrapper for Mutex objects.
     135
    132136  This class implements an interface to the Mutual Exclusion objects
    133137  of the POSIX threads.
     
    161165  \class SOPHYA::ZSync
    162166  \ingroup SysTools
     167  \brief Wrapper/utility class ensuring synchronised execution of an instruction bloc.
     168
    163169  This class can be used to insure that the execution of a given
    164170  part of the code is synchronised, i.e. only a single thread
  • trunk/SophyaLib/SysTools/zthread.h

    r2496 r2598  
    1616
    1717/*!
    18   \class SOPHYA::ZThreadExc
     18  \class ZThreadExc
    1919  \ingroup SysTools
    20   This exception class is used by the classes implementing the interface
    21   to the POSIX threads (\b ZThread ...)
     20  \brief Exception class used by ZThread and ZMutex classes.
    2221*/ 
    2322class ZThreadExc : public PException {
     
    9392class ZSync {
    9493public:
     94/*!
     95  Constructor. Locks the associated ZMutex.
     96 
     97  - <tt> sigbr==1 </tt> destructor calls \c signal on
     98  the associated ZMutex
     99  - <tt> sigbr==2 </tt> destructor calls \c broadcast on
     100  the associated ZMutex
     101*/
    95102  explicit inline  ZSync(ZMutex & mtx, int sigbr=0)
    96103  {_mtx = &mtx; _sigbr = sigbr; mtx.lock(); }
Note: See TracChangeset for help on using the changeset viewer.