~scottydelicious666/brewtarget/brewtarget

« back to all changes in this revision

Viewing changes to src/equipment.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
 * equipment.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 _EQUIPMENT_H
 
20
#define _EQUIPMENT_H
 
21
 
 
22
#include <string>
 
23
#include <exception>
 
24
#include <ostream>
 
25
#include <QDomNode>
 
26
#include "xmlnode.h"
 
27
#include "observable.h"
 
28
#include "BeerXMLElement.h"
 
29
 
 
30
class Equipment;
 
31
class EquipmentException;
 
32
 
 
33
class Equipment : public Observable, public BeerXMLElement
 
34
{
 
35
public:
 
36
   
 
37
   Equipment();
 
38
   Equipment(XmlNode *node);
 
39
   Equipment(const QDomNode& equipmentNode);
 
40
   
 
41
   virtual void toXml(QDomDocument& doc, QDomNode& parent); // From BeerXMLElement
 
42
   //std::string toXml();
 
43
 
 
44
   // Operators
 
45
   friend bool operator<(Equipment &e1, Equipment &e2);
 
46
   friend bool operator==(Equipment &e1, Equipment &e2);
 
47
 
 
48
   // Set
 
49
   void setName( const std::string &var );
 
50
   void setBoilSize_l( double var );
 
51
   void setBatchSize_l( double var );
 
52
   void setTunVolume_l( double var );
 
53
   void setTunWeight_kg( double var );
 
54
   void setTunSpecificHeat_calGC( double var );
 
55
   void setTopUpWater_l( double var );
 
56
   void setTrubChillerLoss_l( double var );
 
57
   void setEvapRate_pctHr( double var );
 
58
   void setBoilTime_min( double var );
 
59
   void setCalcBoilVolume( bool var );
 
60
   void setLauterDeadspace_l( double var );
 
61
   void setTopUpKettle_l( double var );
 
62
   void setHopUtilization_pct( double var );
 
63
   void setNotes( const std::string &var );
 
64
 
 
65
   // Get
 
66
   std::string getName() const;
 
67
   double getBoilSize_l() const;
 
68
   double getBatchSize_l() const;
 
69
   double getTunVolume_l() const;
 
70
   double getTunWeight_kg() const;
 
71
   double getTunSpecificHeat_calGC() const;
 
72
   double getTopUpWater_l() const;
 
73
   double getTrubChillerLoss_l() const;
 
74
   double getEvapRate_pctHr() const;
 
75
   double getBoilTime_min() const;
 
76
   bool getCalcBoilVolume() const;
 
77
   double getLauterDeadspace_l() const;
 
78
   double getTopUpKettle_l() const;
 
79
   double getHopUtilization_pct() const;
 
80
   std::string getNotes() const;
 
81
   
 
82
   double wortEndOfBoil_l( double kettleWort_l ) const; // Calculate how much wort is left immediately at knockout.
 
83
 
 
84
private:
 
85
   std::string name;
 
86
   static const int version = 1;
 
87
   double boilSize_l;
 
88
   double batchSize_l;
 
89
   double tunVolume_l;
 
90
   double tunWeight_kg;
 
91
   double tunSpecificHeat_calGC;
 
92
   double topUpWater_l;
 
93
   double trubChillerLoss_l;
 
94
   double evapRate_pctHr;
 
95
   double boilTime_min;
 
96
   bool calcBoilVolume;
 
97
   double lauterDeadspace_l;
 
98
   double topUpKettle_l;
 
99
   double hopUtilization_pct;
 
100
   std::string notes;
 
101
 
 
102
   void setDefaults();
 
103
   void doCalculations();
 
104
};
 
105
 
 
106
class EquipmentException : public std::exception
 
107
{
 
108
public:
 
109
   
 
110
   virtual const char* what() const throw()
 
111
   {
 
112
      // Note: this temporary object might get destroyed too early.
 
113
      // I'm not really sure.
 
114
      return std::string("BeerXml EQUIPMENT error: " + _err + "\n").c_str();
 
115
   }
 
116
   
 
117
   EquipmentException( std::string message )
 
118
   {
 
119
      _err = message;
 
120
   }
 
121
   
 
122
   ~EquipmentException() throw() {}
 
123
   
 
124
private:
 
125
   
 
126
   std::string _err;
 
127
};
 
128
 
 
129
struct Equipment_ptr_cmp
 
130
{
 
131
   bool operator()( Equipment* lhs, Equipment* rhs)
 
132
   {
 
133
      return *lhs < *rhs;
 
134
   }
 
135
};
 
136
 
 
137
struct Equipment_ptr_equals
 
138
{
 
139
   bool operator()( Equipment* lhs, Equipment* rhs )
 
140
   {
 
141
      return *lhs == *rhs;
 
142
   }
 
143
};
 
144
 
 
145
#endif  /* _EQUIPMENT_H */
 
146