1 : |
agomez |
1 |
#ifndef timevariable_h
|
2 : |
|
|
#define timevariable_h
|
3 : |
|
|
|
4 : |
|
|
#include "formulavector.h" |
5 : |
|
|
#include "areatime.h" |
6 : |
|
|
#include "commentstream.h" |
7 : |
|
|
|
8 : |
|
|
/**
|
9 : |
|
|
* \class TimeVariable
|
10 : |
|
|
* \brief This is the class used to calculate the value of the time-dependent variables used in the model simulation
|
11 : |
|
|
*/
|
12 : |
|
|
class TimeVariable {
|
13 : |
|
|
public:
|
14 : |
|
|
/**
|
15 : |
|
|
* \brief This is the default TimeVariable constructor
|
16 : |
|
|
*/
|
17 : |
|
|
TimeVariable() { value = 0.0; lastvalue = -1.0; };
|
18 : |
|
|
/**
|
19 : |
|
|
* \brief This is the default TimeVariable destructor
|
20 : |
|
|
*/
|
21 : |
|
|
~TimeVariable() {};
|
22 : |
|
|
/**
|
23 : |
|
|
* \brief This function will read TimeVariable data from file
|
24 : |
|
|
* \param infile is the CommentStream to read the data from
|
25 : |
|
|
* \param TimeInfo is the TimeClass for the current model
|
26 : |
|
|
* \param keeper is the Keeper for the current model
|
27 : |
|
|
*/
|
28 : |
|
|
void read(CommentStream& infile, const TimeClass* const TimeInfo, Keeper* const keeper);
|
29 : |
|
|
/**
|
30 : |
|
|
* \brief This function will return the value of the TimeVariable
|
31 : |
|
|
* \return the value of the TimeVariable
|
32 : |
|
|
*/
|
33 : |
|
|
double getValue() const { return value; };
|
34 : |
|
|
/**
|
35 : |
|
|
* \brief This function will swap the TimeVariable value for a new value
|
36 : |
|
|
* \param newTV is the new TimeVariable value
|
37 : |
|
|
* \param keeper is the Keeper for the current model
|
38 : |
|
|
*/
|
39 : |
|
|
void Interchange(TimeVariable& newTV, Keeper* const keeper) const;
|
40 : |
|
|
/**
|
41 : |
|
|
* \brief This function will update the TimeVariable value
|
42 : |
|
|
* \param TimeInfo is the TimeClass for the current model
|
43 : |
|
|
*/
|
44 : |
|
|
void Update(const TimeClass* const TimeInfo);
|
45 : |
|
|
/**
|
46 : |
|
|
* \brief This function will delete a TimeVariable value
|
47 : |
|
|
* \param keeper is the Keeper for the current model
|
48 : |
|
|
*/
|
49 : |
|
|
void Delete(Keeper* const keeper) const;
|
50 : |
|
|
/**
|
51 : |
|
|
* \brief This function will check to see if the TimeVariable value has changed
|
52 : |
|
|
* \param TimeInfo is the TimeClass for the current model
|
53 : |
|
|
* \return 1 if the values have changed, 0 otherwise
|
54 : |
|
|
*/
|
55 : |
|
|
int didChange(const TimeClass* const TimeInfo);
|
56 : |
|
|
private:
|
57 : |
|
|
/**
|
58 : |
|
|
* \brief This is the identifier for the last timestep that the value of the TimeVariable changed
|
59 : |
|
|
*/
|
60 : |
|
|
int timeid;
|
61 : |
|
|
/**
|
62 : |
|
|
* \brief This is the last timestep that the value of the TimeVariable changed
|
63 : |
|
|
*/
|
64 : |
|
|
int time;
|
65 : |
|
|
/**
|
66 : |
|
|
* \brief This is the IntVector of the years when the value of the TimeVariable changes
|
67 : |
|
|
*/
|
68 : |
|
|
IntVector years;
|
69 : |
|
|
/**
|
70 : |
|
|
* \brief This is the IntVector of the steps when the value of the TimeVariable changes
|
71 : |
|
|
*/
|
72 : |
|
|
IntVector steps;
|
73 : |
|
|
/**
|
74 : |
|
|
* \brief This is the FormulaVector of the values of the TimeVariable
|
75 : |
|
|
*/
|
76 : |
|
|
FormulaVector values;
|
77 : |
|
|
/**
|
78 : |
|
|
* \brief This is the last value of the TimeVariable
|
79 : |
|
|
*/
|
80 : |
|
|
double lastvalue;
|
81 : |
|
|
/**
|
82 : |
|
|
* \brief This is the value of the TimeVariable
|
83 : |
|
|
*/
|
84 : |
|
|
double value;
|
85 : |
|
|
};
|
86 : |
|
|
|
87 : |
|
|
#endif
|