Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/formula.h
[mareframe] / trunk / gadget / formula.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/formula.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef formula_h
2 :     #define formula_h
3 :    
4 :     #include "keeper.h"
5 :     #include "parameter.h"
6 :     #include "gadget.h"
7 :    
8 :     class Keeper;
9 :    
10 :     enum FormulaType { CONSTANT = 1, PARAMETER, FUNCTION };
11 :     enum FunctionType { NONE = 1, MULT, DIV, PLUS, MINUS, SIN, COS, LOG, EXP,
12 :     LOG10, POWER, SQRT, RAND, LESS, GREATER, EQUAL, AND, OR, NOT, ABS, IF, PI };
13 :    
14 :     /**
15 :     * \class Formula
16 :     * \brief This is the class used to calculate the value of the variables used in the model simulation
17 :     */
18 :     class Formula {
19 :     public:
20 :     /**
21 :     * \brief This is the default Formula constructor
22 :     */
23 :     Formula();
24 :     /**
25 :     * \brief This is the Formula constructor that creates a Formula with a given initial value
26 :     * \param initial is the initial vlaue for the Formula
27 :     */
28 :     Formula(double initial);
29 :     /**
30 :     * \brief This is the Formula constructor that creates a copy of an existing Formula
31 :     * \param initial is the Formula to copy
32 :     */
33 :     Formula(const Formula& initial);
34 :     /**
35 :     * \brief This is the Formula constructor for a given function type and list of parameters
36 :     * \param ft is the FunctionType for the new Formula function
37 :     * \param formlist is the vector of arguments for the new Formula function
38 :     */
39 :     Formula(FunctionType ft, vector<Formula*> formlist);
40 :     /**
41 :     * \brief This is the default Formula destructor
42 :     */
43 :     ~Formula();
44 :     /**
45 :     * \brief This function will set the value of the Formula
46 :     * \param init is the value of the Formula
47 :     */
48 :     void setValue(double init);
49 :     /**
50 :     * \brief This operator will return the value of the Formula
51 :     * \return the value of the Formula
52 :     */
53 :     operator double() const;
54 :     /**
55 :     * \brief This function will swap the Formula value for a new value
56 :     * \param newF is the new Formula value
57 :     * \param keeper is the Keeper for the current model
58 :     */
59 :     void Interchange(Formula& newF, Keeper* keeper) const;
60 :     /**
61 :     * \brief This function will inform the Keeper for the current model of the new Formula
62 :     * \param keeper is the Keeper for the current model
63 :     */
64 :     void Inform(Keeper* keeper);
65 :     /**
66 :     * \brief This function will delete a Formula value
67 :     * \param keeper is the Keeper for the current model
68 :     */
69 :     void Delete(Keeper* keeper) const;
70 :     /**
71 :     * \brief This operator will set the Formula equal to an existing Formula
72 :     * \param F is the Formula to copy
73 :     */
74 :     Formula& operator = (const Formula& F);
75 :     /**
76 :     * \brief This operator will read data from a CommentStream into a Formula
77 :     * \param infile is the CommentStream to read from
78 :     * \param F is the Formula used to store the data
79 :     */
80 :     friend CommentStream& operator >> (CommentStream& infile, Formula& F);
81 :     /**
82 :     * \brief This will return the type of Formula class
83 :     * \return type
84 :     */
85 :     FormulaType getType() const { return type; };
86 :     private:
87 :     /**
88 :     * \brief This function will calculate the value of the function
89 :     * \return the value of the function
90 :     */
91 :     double evalFunction() const;
92 :     /**
93 :     * \brief This denotes what type of Formula class has been created
94 :     */
95 :     FormulaType type;
96 :     /**
97 :     * \brief This denotes what type of function has been used for the Formula
98 :     */
99 :     FunctionType functiontype;
100 :     /**
101 :     * \brief This is the value of the Formula
102 :     */
103 :     double value;
104 :     /**
105 :     * \brief This Parameter is the name of the Formula
106 :     */
107 :     Parameter name;
108 :     /**
109 :     * \brief This is the vector of arguments for the Formula function
110 :     */
111 :     vector<Formula*> argList;
112 :     };
113 :    
114 :     #endif

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge