2
* hop.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/>.
25
#include "observable.h"
27
#include "BeerXMLElement.h"
34
class Hop : public Observable, public BeerXMLElement
39
Hop( const XmlNode *node );
40
Hop(const QDomNode& hopNode);
42
friend bool operator<( Hop &h1, Hop &h2 );
43
friend bool operator==( Hop &h1, Hop &h2 );
45
virtual void toXml(QDomDocument& doc, QDomNode& parent); // From BeerXMLElement
46
//std::string toXml();
48
const string& getName() const;
49
int getVersion() const;
50
double getAlpha_pct() const;
51
double getAmount_kg() const;
52
const string& getUse() const;
53
double getTime_min() const;
55
const string& getNotes() const;
56
const string& getType() const;
57
const string& getForm() const;
58
double getBeta_pct() const;
59
double getHsi_pct() const;
60
const string& getOrigin() const;
61
const string& getSubstitutes() const;
62
double getHumulene_pct() const;
63
double getCaryophyllene_pct() const;
64
double getCohumulone_pct() const;
65
double getMyrcene_pct() const;
68
void setName( const string &str );
69
void setAlpha_pct( double num );
70
void setAmount_kg( double num );
71
bool setUse( const string &str );
72
void setTime_min( double num );
74
void setNotes( const string &str );
75
bool setType( const string &str );
76
bool setForm( const string &str );
77
void setBeta_pct( double num );
78
void setHsi_pct( double num );
79
void setOrigin( const string &str );
80
void setSubstitutes( const string &str );
81
void setHumulene_pct( double num );
82
void setCaryophyllene_pct( double num );
83
void setCohumulone_pct( double num );
84
void setMyrcene_pct( double num );
89
const static int version = 1;
104
double caryophyllene_pct;
105
double cohumulone_pct;
108
// Sets every member to zero or blank or whatever.
111
static bool isValidUse(const string &str);
112
static bool isValidType(const string &str);
113
static bool isValidForm(const string &str);
116
class HopException : public std::exception
120
virtual const char* what() const throw()
122
// Note: this temporary object might get destroyed too early.
123
// I'm not really sure.
124
return std::string("BeerXml HOP error: " + _err + "\n").c_str();
127
HopException( std::string message )
132
~HopException() throw() {}
141
bool operator()( Hop* lhs, Hop* rhs)
147
struct Hop_ptr_equals
149
bool operator()( Hop* lhs, Hop* rhs )