~scottydelicious666/brewtarget/brewtarget

« back to all changes in this revision

Viewing changes to fermentable.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
 
 * fermentable.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 _FERMENTABLE_H
20
 
#define _FERMENTABLE_H
21
 
 
22
 
#include <string>
23
 
#include <exception>
24
 
#include "xmlnode.h"
25
 
#include "observable.h"
26
 
#include <QDomNode>
27
 
#include "BeerXMLElement.h"
28
 
 
29
 
class Fermentable;
30
 
 
31
 
class Fermentable : public Observable, public BeerXMLElement
32
 
{
33
 
public:
34
 
   Fermentable();
35
 
   Fermentable( Fermentable& other );
36
 
   Fermentable( const XmlNode* node );
37
 
   Fermentable(const QDomNode& fermentableNode);
38
 
   
39
 
   virtual void toXml(QDomDocument& doc, QDomNode& parent); // From BeerXMLElement
40
 
   //std::string toXml();
41
 
 
42
 
   // Operators
43
 
   friend bool operator<(Fermentable &f1, Fermentable &f2);
44
 
   friend bool operator==(Fermentable &f1, Fermentable &f2);
45
 
 
46
 
   // Get
47
 
   const std::string& getName() const;
48
 
   int getVersion() const;
49
 
   const std::string& getType() const;
50
 
   double getAmount_kg() const;
51
 
   double getYield_pct() const;
52
 
   double getColor_srm() const;
53
 
   
54
 
   bool getAddAfterBoil() const;
55
 
   const std::string& getOrigin() const;
56
 
   const std::string& getSupplier() const;
57
 
   const std::string& getNotes() const;
58
 
   double getCoarseFineDiff_pct() const;
59
 
   double getMoisture_pct() const;
60
 
   double getDiastaticPower_lintner() const;
61
 
   double getProtein_pct() const;
62
 
   double getMaxInBatch_pct() const;
63
 
   bool getRecommendMash() const;
64
 
   double getIbuGalPerLb() const;
65
 
 
66
 
   // Derived getters...
67
 
 
68
 
   // Get the maximum kg of equivalent sucrose that will come out of this ferm.
69
 
   double getEquivSucrose_kg() const;
70
 
 
71
 
   // Set
72
 
   void setName( const std::string& str );
73
 
   void setVersion( int num );
74
 
   void setType( const std::string& str );
75
 
   void setAmount_kg( double num );
76
 
   void setYield_pct( double num );
77
 
   void setColor_srm( double num );
78
 
   
79
 
   void setAddAfterBoil( bool b );
80
 
   void setOrigin( const std::string& str );
81
 
   void setSupplier( const std::string& str);
82
 
   void setNotes( const std::string& str );
83
 
   void setCoarseFineDiff_pct( double num );
84
 
   void setMoisture_pct( double num );
85
 
   void setDiastaticPower_lintner( double num );
86
 
   void setProtein_pct( double num );
87
 
   void setMaxInBatch_pct( double num );
88
 
   void setRecommendMash( bool b );
89
 
   void setIbuGalPerLb( double num );
90
 
   
91
 
   /*** My extensions ***/
92
 
   bool getIsMashed() const;
93
 
   void setIsMashed(bool var);
94
 
   /*** END my extensions ***/
95
 
   
96
 
private:
97
 
   std::string name;
98
 
   static const int version = 1;
99
 
   std::string type;
100
 
   double amount_kg;
101
 
   double yield_pct;
102
 
   double color_srm;
103
 
 
104
 
   bool addAfterBoil;
105
 
   std::string origin;
106
 
   std::string supplier;
107
 
   std::string notes;
108
 
   double coarseFineDiff_pct;
109
 
   double moisture_pct;
110
 
   double diastaticPower_lintner;
111
 
   double protein_pct;
112
 
   double maxInBatch_pct;
113
 
   bool recommendMash;
114
 
   double ibuGalPerLb;
115
 
   /*** My extensions ***/
116
 
   bool isMashed;
117
 
   /*** END my extensions ***/
118
 
 
119
 
   static bool isValidType( const std::string& str );
120
 
   void setDefaults();
121
 
};
122
 
 
123
 
class FermentableException : public std::exception
124
 
{
125
 
public:
126
 
   
127
 
   virtual const char* what() const throw()
128
 
   {
129
 
      // Note: this temporary object might get destroyed too early.
130
 
      // I'm not really sure.
131
 
      return std::string("BeerXml FERMENTABLE error: " + _err + "\n").c_str();
132
 
   }
133
 
   
134
 
   FermentableException( std::string message )
135
 
   {
136
 
      _err = message;
137
 
   }
138
 
   
139
 
   ~FermentableException() throw() {}
140
 
   
141
 
private:
142
 
   
143
 
   std::string _err;
144
 
};
145
 
 
146
 
struct Fermentable_ptr_cmp
147
 
{
148
 
   bool operator()( Fermentable* lhs, Fermentable* rhs)
149
 
   {
150
 
      return *lhs < *rhs;
151
 
   }
152
 
};
153
 
 
154
 
struct Fermentable_ptr_equals
155
 
{
156
 
   bool operator()( Fermentable* lhs, Fermentable* rhs )
157
 
   {
158
 
      return *lhs == *rhs;
159
 
   }
160
 
};
161
 
 
162
 
#endif