~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
////////////////////////////////////////////////////////////////////////////////
/*! @file NetMath.h   Basic expression interpreter.
- Part of RANet - Research Assistant Net Library.
- Copyright(C) 2014, Viktor E. Bursian, St.Petersburg, Russia.
                     Viktor.Bursian@mail.ioffe.ru
*///////////////////////////////////////////////////////////////////////////////
#ifndef NetMath_H
#define NetMath_H
#include "PhysMath.h"
#include "BasicNodes.h"
#include "Functions.h"
namespace RA {
//------------------------------------------------------------------------------

ANNOUNCE_CLASS(sNetMath)

//----------------------------------------- get_math_value_from <node_class> ---
/*! Convenience function template for extracting data from the net
    for use in math expressions.

*/
template<class node_class>
bool  get_math_value_from (rcsNodePtr     node_ptr_expression
                          ,psMathValue &  result_ptr)
{
  sPtr<node_class>            ValPtr (node_ptr_expression);
  if( ValPtr.IsCorrect() ){
    result_ptr = ValPtr->MathValue();
    return true;
  }
  return false;
}


//----------------------------------------------------------------- sNetMath ---
/*! Performs calculation of an expression over phys.values and functions.
*/
class RANet_EXPORT  sNetMath : public sPhysMath
{
  public://static
    static pcsFunction        GetMathFunctionFrom (sNodePtr  node);

  public:
                              sNetMath (sNodePtr   host
                                       ,rcsString  source)
                                  :sPhysMath(source)
                                  ,Host(host)
                                {}

  protected:
    virtual psMathValue       Term ();

  protected: //fields
    sNodePtr                  Host;

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

  private:
};

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