1 /***************************************************************************
2 style.cpp
3 -------------------
4 AHA-like style class
5 -------------------
6 Copyright 1999-2008, David Johnson
7 Please see the header file for copyright and license information
8 ***************************************************************************/
9
10 #include "resource.h"
11 #include "style.h"
12
13 using namespace Resource;
14
15 //////////////////////////////////////////////////////////////////////////////
16 // Construction, Destruction //
17 //////////////////////////////////////////////////////////////////////////////
18
Style()19 Style::Style()
20 : name_("Generic Ale"), oglow_(0.0), oghi_(0.0), fglow_(0.0), fghi_(0.0),
21 ibulow_(0), ibuhi_(100), srmlow_(0), srmhi_(40)
22 { ; }
23
24 //////////////////////////////////////////////////////////////////////////////
25 // Style()
26 // -------
27 // Constructor
28
Style(const QString name,const double & oglow,const double & oghi,const double & fglow,const double & fghi,const int & ibulow,const int & ibuhi,const int & srmlow,const int & srmhi)29 Style::Style(const QString name, const double &oglow, const double &oghi,
30 const double &fglow, const double &fghi,
31 const int &ibulow, const int &ibuhi,
32 const int &srmlow, const int &srmhi)
33 : name_(name), oglow_(oglow), oghi_(oghi), fglow_(fglow), fghi_(fghi),
34 ibulow_(ibulow), ibuhi_(ibuhi), srmlow_(srmlow), srmhi_(srmhi)
35 {
36 // older qbrewdata files might not have FG values
37 if (fglow_ == 0.0) fglow_ = ((oglow_ - 1.0) * 0.25) + 1.0;
38 if (fghi_ == 0.0) fghi_ = ((oghi_ - 1.0) * 0.25) + 1.0;
39 }
40
Style(const Style & s)41 Style::Style(const Style &s)
42 : name_(s.name_), oglow_(s.oglow_), oghi_(s.oghi_), fglow_(s.fglow_),
43 fghi_(s.fghi_), ibulow_(s.ibulow_), ibuhi_(s.ibuhi_),
44 srmlow_(s.srmlow_), srmhi_(s.srmhi_)
45 { ; }
46
~Style()47 Style::~Style() { ; }
48
49 //////////////////////////////////////////////////////////////////////////////
50 // Miscellaneous //
51 //////////////////////////////////////////////////////////////////////////////
52
53 //////////////////////////////////////////////////////////////////////////////
54 // operator=
55 // ---------
56 // Assignment operator
57
operator =(const Style & s)58 Style Style::operator=(const Style &s)
59 {
60 if (&s != this) {
61 name_ = s.name_;
62 oglow_ = s.oglow_; oghi_ = s.oghi_;
63 fglow_ = s.fglow_; fghi_ = s.fghi_;
64 ibulow_ = s.ibulow_; ibuhi_ = s.ibuhi_;
65 srmlow_ = s.srmlow_; srmhi_ = s.srmhi_;
66 }
67 return *this;
68 }
69
70 //////////////////////////////////////////////////////////////////////////////
71 // operator==
72 // ----------
73 // Equivalence operator
74
operator ==(const Style & s) const75 bool Style::operator==(const Style &s) const
76 {
77 return ( (name_ == s.name_) &&
78 (oglow_ == s.oglow_) &&
79 (oghi_ == s.oghi_) &&
80 (fglow_ == s.fglow_) &&
81 (fghi_ == s.fghi_) &&
82 (ibulow_ == s.ibulow_) &&
83 (ibuhi_ == s.ibuhi_) &&
84 (srmlow_ == s.srmlow_) &&
85 (srmhi_ == s.srmhi_) );
86 }
87