~vbursian/research-assistant/intervers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
////////////////////////////////////////////////////////////////////////////////
/*! @file PhysMath.h   Expression interpreter with physvalues.
- Part of RANet - Research Assistant Net Library.
- Copyright(C) 2014, Viktor E. Bursian, St.Petersburg, Russia.
                     Viktor.Bursian@mail.ioffe.ru
*///////////////////////////////////////////////////////////////////////////////
#ifndef PhysMath_H
#define PhysMath_H
#include "BasicMath.h"
#include "PhysValue.h"
namespace RA {
//------------------------------------------------------------------------------

ANNOUNCE_CLASS(sPhysMath)

//---------------------------------------------------------------- sPhysMath ---
/*! Performs calculation of an expression with integers, reals and physvalues.
*/
class RANet_EXPORT  sPhysMath : public sMath
{
  public://static
    static void               AddConstant (rcsPhysValue  value
                                          ,rcsString     identifier);

  public:
                              sPhysMath (rcsString  source)
                                  :sMath(source)
                                {}

  protected:
    virtual psMathValue       Constant (rcsString  identifier
                                       ,int        start_pos ) const;
    virtual psMathValue       Value ();
    virtual psMathValue       Call (rcsString    identifier
                                   ,int          start_pos
                                   ,psMathValue  arg1      ) const;
    virtual psMathValue       Call (rcsString    identifier
                                   ,int          start_pos
                                   ,psMathValue  arg1
                                   ,psMathValue  arg2      ) const;
    virtual psMathValue       Call (rcsString    identifier
                                   ,int          start_pos
                                   ,psMathValue  arg1
                                   ,psMathValue  arg2
                                   ,psMathValue  arg3      ) const;
    virtual psMathValue       Call (rcsString    identifier
                                   ,int          start_pos
                                   ,psMathValue  arg1
                                   ,psMathValue  arg2
                                   ,psMathValue  arg3
                                   ,psMathValue  arg4      ) const;

  private: //types
    class sMathOpRegistrator { public: sMathOpRegistrator(); };
  private: //static field
    static sMathOpRegistrator MathOpRegistrator;

  private:
    static psMathValue        UnaryMinusPhysValue (pcsMathValue);
    static psMathValue        PhysValuePlusPhysValue (pcsMathValue,pcsMathValue);
    static psMathValue        PhysValueMinusPhysValue (pcsMathValue,pcsMathValue);
    static psMathValue        PhysValueMultPhysValue (pcsMathValue,pcsMathValue);
    static psMathValue        PhysValueDivPhysValue (pcsMathValue,pcsMathValue);
    static psMathValue        PhysValuePowerInteger (pcsMathValue,pcsMathValue);

    static psMathValue        sin (pcsMathValue);
    static psMathValue        cos (pcsMathValue);
    static psMathValue        tg (pcsMathValue);
    static psMathValue        ctg (pcsMathValue);

    static psMathValue        seven ();
};

//------------------------------------------------------------------------------
} //namespace RA
#endif