2
* recipe.h is part of Brewtarget, and is Copyright Philip G. Lee
3
* (rocketman768@gmail.com), 2009.
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.
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.
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/>.
22
class RecipeException;
27
#include "BeerXMLElement.h"
35
#include "fermentable.h"
36
#include "equipment.h"
39
#include "observable.h"
40
#include "instruction.h"
42
class Recipe : public Observable, public MultipleObserver, public BeerXMLElement
47
//Recipe(const XmlNode *node);
48
Recipe(const QDomNode& recipeNode);
52
friend bool operator<(Recipe &r1, Recipe &r2 );
53
friend bool operator==(Recipe &r1, Recipe &r2 );
55
virtual void toXml(QDomDocument& doc, QDomNode& parent); // From BeerXMLElement
56
//std::string toXml();
57
void clear(); // Retains only the name, but sets everything else to defaults.
58
virtual void notify(Observable *notifier, QVariant info = QVariant()); // Inherited from MultipleObserver.
60
void setName( const std::string &var );
61
void setType( const std::string &var );
62
void setBrewer( const std::string &var );
63
void setStyle( Style *var );
64
void setBatchSize_l( double var );
65
void setBoilSize_l( double var );
66
void setBoilTime_min( double var );
67
void setEfficiency_pct( double var );
69
void addHop( Hop *var );
70
bool removeHop( Hop *var );
71
void addFermentable( Fermentable* var );
72
bool removeFermentable( Fermentable* var );
73
void addMisc( Misc* var );
74
bool removeMisc( Misc* var );
75
void addYeast( Yeast* var );
76
bool removeYeast( Yeast* var );
77
void addWater( Water* var );
78
bool removeWater( Water* var );
80
void addInstruction( Instruction* ins );
81
void removeInstruction( Instruction* ins );
82
void swapInstructions( unsigned int j, unsigned int k );
83
void clearInstructions();
84
void insertInstruction( Instruction* ins, int pos );
85
int getNumInstructions();
86
Instruction* getInstruction(int i);
87
void generateInstructions();
88
QString nextAddToBoil(double& time);
90
void setMash( Mash *var );
91
void setAsstBrewer( const std::string &var );
92
void setEquipment( Equipment *var );
93
void setNotes( const std::string &var );
94
void setTasteNotes( const std::string &var );
95
void setTasteRating( double var );
96
void setOg( double var );
97
void setFg( double var );
98
void setFermentationStages( int var );
99
void setPrimaryAge_days( double var );
100
void setPrimaryTemp_c( double var );
101
void setSecondaryAge_days( double var );
102
void setSecondaryTemp_c( double var );
103
void setTertiaryAge_days( double var );
104
void setTertiaryTemp_c( double var );
105
void setAge_days( double var );
106
void setAgeTemp_c( double var );
107
void setDate( const std::string &var );
108
void setCarbonation_vols( double var );
109
void setForcedCarbonation( bool var );
110
void setPrimingSugarName( const std::string &var );
111
void setCarbonationTemp_c( double var );
112
void setPrimingSugarEquiv( double var );
113
void setKegPrimingFactor( double var );
115
std::string getName() const;
116
std::string getType() const;
117
std::string getBrewer() const;
118
Style *getStyle() const;
119
double getBatchSize_l() const;
120
double getBoilSize_l() const;
121
double getBoilTime_min() const;
122
double getEfficiency_pct() const;
124
unsigned int getNumHops() const;
125
Hop* getHop(unsigned int i);
126
unsigned int getNumFermentables() const;
127
Fermentable* getFermentable(unsigned int i);
128
unsigned int getNumMiscs() const;
129
Misc* getMisc(unsigned int i);
130
unsigned int getNumYeasts() const;
131
Yeast* getYeast(unsigned int i);
132
unsigned int getNumWaters() const;
133
Water* getWater(unsigned int i);
135
Mash* getMash() const;
137
std::string getAsstBrewer() const;
138
Equipment* getEquipment() const;
139
std::string getNotes() const;
140
std::string getTasteNotes() const;
141
double getTasteRating() const;
142
double getOg() const;
143
double getFg() const;
144
int getFermentationStages() const;
145
double getPrimaryAge_days() const;
146
double getPrimaryTemp_c() const;
147
double getSecondaryAge_days() const;
148
double getSecondaryTemp_c() const;
149
double getTertiaryAge_days() const;
150
double getTertiaryTemp_c() const;
151
double getAge_days() const;
152
double getAgeTemp_c() const;
153
std::string getDate() const;
154
double getCarbonation_vols() const;
155
bool getForcedCarbonation() const;
156
std::string getPrimingSugarName() const;
157
double getCarbonationTemp_c() const;
158
double getPrimingSugarEquiv() const;
159
double getKegPrimingFactor() const;
161
void recalculate(); // Calculates some parameters.
163
double getColor_srm();
164
double getWortGrav();
166
double getIBUFromHop( unsigned int i );
167
QColor getSRMColor();
168
double estimateWortFromMash_l() const; // Estimate amount of wort collected immediately after the mash.
169
double estimateBoilVolume_l() const; // Estimate boil volume based on user inputs.
170
double estimateFinalVolume_l() const; // Estimate final volume based on user inputs.
171
double getGrainsInMash_kg() const;
176
static const int version = 1;
183
double efficiency_pct;
184
std::vector<Hop*> hops;
185
std::vector<Fermentable*> fermentables;
186
std::vector<Misc*> miscs;
187
std::vector<Yeast*> yeasts;
188
std::vector<Water*> waters;
190
std::vector<Instruction*> instructions;
192
std::string asstBrewer;
193
Equipment* equipment;
195
std::string tasteNotes;
199
int fermentationStages;
200
double primaryAge_days;
201
double primaryTemp_c;
202
double secondaryAge_days;
203
double secondaryTemp_c;
204
double tertiaryAge_days;
205
double tertiaryTemp_c;
209
double carbonation_vols;
210
bool forcedCarbonation;
211
std::string primingSugarName;
212
double carbonationTemp_c;
213
double primingSugarEquiv;
214
double kegPrimingFactor;
217
bool isValidType( const std::string &str );
220
class RecipeException : public std::exception
224
virtual const char* what() const throw()
226
return std::string("BeerXML RECIPE error: " + _err + "\n").c_str();
229
RecipeException( std::string message )
234
~RecipeException() throw() {}
241
struct Recipe_ptr_cmp
243
bool operator()( Recipe* lhs, Recipe* rhs)
249
struct Recipe_ptr_equals
251
bool operator()( Recipe* lhs, Recipe* rhs )
257
#endif /* _RECIPE_H */