~scottydelicious666/brewtarget/brewtarget

« back to all changes in this revision

Viewing changes to src/mashstep.h

  • Committer: Philip Greggory Lee
  • Date: 2009-08-23 16:53:43 UTC
  • Revision ID: git-v1:f8d1a25135bd92f06c46c562293800e4faa42c61
Made a src/ and ui/ directory and moved everything.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * mashstep.h is part of Brewtarget, and is Copyright Philip G. Lee
 
3
 * (rocketman768@gmail.com), 2009.
 
4
 *
 
5
 * Brewtarget is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation, either version 3 of the License, or
 
8
 * (at your option) any later version.
 
9
 
 
10
 * Brewtarget is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#ifndef _MASHSTEP_H
 
20
#define _MASHSTEP_H
 
21
#include <string>
 
22
#include <exception>
 
23
#include "xmlnode.h"
 
24
#include "observable.h"
 
25
#include <QDomNode>
 
26
#include "BeerXMLElement.h"
 
27
 
 
28
class MashStep;
 
29
class MashStepException;
 
30
 
 
31
class MashStep : public Observable, public BeerXMLElement
 
32
{
 
33
public:
 
34
 
 
35
   MashStep();
 
36
   MashStep(const XmlNode *node);
 
37
   MashStep( const QDomNode& mashStepNode );
 
38
 
 
39
   friend bool operator<(MashStep &m1, MashStep &m2);
 
40
   friend bool operator==(MashStep &m1, MashStep &m2);
 
41
 
 
42
   virtual void toXml(QDomDocument& doc, QDomNode& parent); // From BeerXMLElement
 
43
   //std::string toXml();
 
44
   
 
45
   void setName( const std::string &var );
 
46
   void setType( const std::string &var );
 
47
   void setInfuseAmount_l( double var );
 
48
   void setStepTemp_c( double var );
 
49
   void setStepTime_min( double var );
 
50
   void setRampTime_min( double var );
 
51
   void setEndTemp_c( double var );
 
52
 
 
53
   std::string getName() const;
 
54
   std::string getType() const;
 
55
   double getInfuseAmount_l() const;
 
56
   double getStepTemp_c() const;
 
57
   double getStepTime_min() const;
 
58
   double getRampTime_min() const;
 
59
   double getEndTemp_c() const;
 
60
 
 
61
   // My extensions
 
62
   void setInfuseTemp_c( double var );
 
63
   double getInfuseTemp_c() const;
 
64
   void setDecoctionAmount_l( double var );
 
65
   double getDecoctionAmount_l() const;
 
66
   // ===
 
67
 
 
68
private:
 
69
 
 
70
   std::string name;
 
71
   static const int version = 1;
 
72
   std::string type;
 
73
   double infuseAmount_l;
 
74
   double stepTemp_c;
 
75
   double stepTime_min;
 
76
   double rampTime_min;
 
77
   double endTemp_c;
 
78
 
 
79
   // My extensions
 
80
   double infuseTemp_c;
 
81
   double decoctionAmount_l;
 
82
   // ===
 
83
 
 
84
   bool isValidType( const std::string &str ) const;
 
85
   void setDefaults();
 
86
};
 
87
 
 
88
class MashStepException : public std::exception
 
89
{
 
90
public:
 
91
 
 
92
   virtual const char* what() const throw()
 
93
   {
 
94
      return std::string("BeerXML MASH_STEP error: " + _err + "\n").c_str();
 
95
   }
 
96
 
 
97
   MashStepException( std::string message )
 
98
   {
 
99
      _err = message;
 
100
   }
 
101
 
 
102
   ~MashStepException() throw() {}
 
103
 
 
104
private:
 
105
 
 
106
   std::string _err;
 
107
};
 
108
 
 
109
struct MashStep_ptr_cmp
 
110
{
 
111
   bool operator()( MashStep* lhs, MashStep* rhs)
 
112
   {
 
113
      return *lhs < *rhs;
 
114
   }
 
115
};
 
116
 
 
117
struct MashStep_ptr_equals
 
118
{
 
119
   bool operator()( MashStep* lhs, MashStep* rhs )
 
120
   {
 
121
      return *lhs == *rhs;
 
122
   }
 
123
};
 
124
 
 
125
#endif //_MASHSTEP_H