~scottydelicious666/brewtarget/brewtarget

« back to all changes in this revision

Viewing changes to mash.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
 
 * mash.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 _MASH_H
20
 
#define _MASH_H
21
 
#include <string>
22
 
#include <exception>
23
 
#include "xmlnode.h"
24
 
#include "mashstep.h"
25
 
#include "observable.h"
26
 
#include <QDomNode>
27
 
#include "BeerXMLElement.h"
28
 
 
29
 
class Mash;
30
 
class MashException;
31
 
 
32
 
class Mash : public Observable, public MultipleObserver, public BeerXMLElement
33
 
{
34
 
public:
35
 
 
36
 
   Mash();
37
 
   Mash( const XmlNode *node);
38
 
   Mash( const QDomNode& mashNode );
39
 
 
40
 
   friend bool operator<(Mash &m1, Mash &m2);
41
 
   friend bool operator==(Mash &m1, Mash &m2);
42
 
 
43
 
   virtual void toXml(QDomDocument& doc, QDomNode& parent); // From BeerXMLElement
44
 
   virtual void notify(Observable *notifier, QVariant info); // From MultipleObserver
45
 
   
46
 
   void setName( const std::string &var );
47
 
   void setGrainTemp_c( double var );
48
 
   void setNotes( const std::string &var );
49
 
   void setTunTemp_c( double var );
50
 
   void setSpargeTemp_c( double var );
51
 
   void setPh( double var );
52
 
   void setTunWeight_kg( double var );
53
 
   void setTunSpecificHeat_calGC( double var );
54
 
   void setEquipAdjust( bool var );
55
 
 
56
 
   std::string getName() const;
57
 
   double getGrainTemp_c() const;
58
 
   unsigned int getNumMashSteps() const;
59
 
   MashStep* getMashStep( unsigned int i );
60
 
   std::string getNotes() const;
61
 
   double getTunTemp_c() const;
62
 
   double getSpargeTemp_c() const;
63
 
   double getPh() const;
64
 
   double getTunWeight_kg() const;
65
 
   double getTunSpecificHeat_calGC() const;
66
 
   bool getEquipAdjust() const;
67
 
 
68
 
   void addMashStep(MashStep* step);
69
 
   void removeMashStep(MashStep* step);
70
 
   double totalMashWater_l() const; // Total amount of water that went INTO the mash.
71
 
private:
72
 
 
73
 
   std::string name;
74
 
   static const int version = 1;
75
 
   double grainTemp_c;
76
 
   std::vector<MashStep *> mashSteps;
77
 
   std::string notes;
78
 
   double tunTemp_c;
79
 
   double spargeTemp_c;
80
 
   double ph;
81
 
   double tunWeight_kg;
82
 
   double tunSpecificHeat_calGC;
83
 
   bool equipAdjust;
84
 
   
85
 
   void setDefaults();
86
 
 
87
 
};
88
 
 
89
 
class MashException : public std::exception
90
 
{
91
 
public:
92
 
 
93
 
   virtual const char* what() const throw()
94
 
   {
95
 
      return std::string("BeerXML ... error: " + _err + "\n").c_str();
96
 
   }
97
 
 
98
 
   MashException( std::string message )
99
 
   {
100
 
      _err = message;
101
 
   }
102
 
 
103
 
   ~MashException() throw() {}
104
 
 
105
 
private:
106
 
 
107
 
   std::string _err;
108
 
};
109
 
 
110
 
struct Mash_ptr_cmp
111
 
{
112
 
   bool operator()( Mash* lhs, Mash* rhs)
113
 
   {
114
 
      return *lhs < *rhs;
115
 
   }
116
 
};
117
 
 
118
 
struct Mash_ptr_equals
119
 
{
120
 
   bool operator()( Mash* lhs, Mash* rhs )
121
 
   {
122
 
      return *lhs == *rhs;
123
 
   }
124
 
};
125
 
 
126
 
#endif //_MASH_H