File: hop.cpp

package info (click to toggle)
qbrew 0.4.1-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,724 kB
  • ctags: 1,355
  • sloc: cpp: 7,503; sh: 414; makefile: 18
file content (98 lines) | stat: -rw-r--r-- 2,575 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/***************************************************************************
  hop.cpp
  -------------------
  A hop class
  -------------------
  Copyright 1999-2008, David Johnson
  Please see the header file for copyright and license information
 ***************************************************************************/

#include <QStringList>
#include "resource.h"
#include "hop.h"

const QByteArray Hop::PELLET_STRING = QT_TRANSLATE_NOOP("Hop", "Pellet");
const QByteArray Hop::PLUG_STRING   = QT_TRANSLATE_NOOP("Hop", "Plug");
const QByteArray Hop::WHOLE_STRING  = QT_TRANSLATE_NOOP("Hop", "Whole");

//////////////////////////////////////////////////////////////////////////////
// Hop()
// -----
// constructor

Hop::Hop()
    : name_(QObject::tr("Generic")), weight_(), type_(PELLET_STRING),
      alpha_(10.0),  time_(0)
{ ; }

Hop::Hop(const QString &name, const Weight &weight, const QString &typ,
         const double &alpha, const unsigned &time)
    : name_(name), weight_(weight), type_(typ), alpha_(alpha), time_(time)
      
{
    recalc();
}

Hop::~Hop() { ; }

//////////////////////////////////////////////////////////////////////////////
// Hop(const Hop &)
// ----------------
// Copy constructor

Hop::Hop(const Hop &h)
    : name_(h.name_), weight_(h.weight_), type_(h.type_), alpha_(h.alpha_),
      time_(h.time_), hbu_(h.hbu_)
{ ; }

//////////////////////////////////////////////////////////////////////////////
// operator=()
// -----------
// Assignment operator

Hop Hop::operator=(const Hop &h)
{
    if (this != &h) {
        name_ = h.name_;
        weight_ = h.weight_;
        type_ = h.type_;
        alpha_ = h.alpha_;
        time_ = h.time_;
        hbu_ = h.hbu_;
    }
    return *this;
}

//////////////////////////////////////////////////////////////////////////////
// operator==()
// ------------
// Equivalence operator

bool Hop::operator==(const Hop &h) const
{
    return (name_ == h.name_)
        && (weight_ == h.weight_)
        && (type_ == h.type_)
        && (alpha_ == h.alpha_)
        && (time_ == h.time_);
}

//////////////////////////////////////////////////////////////////////////////
// typeStringList()
// ----------------
// Return string list of available hop types

QStringList Hop::typeStringList()
{
    return (QStringList() << PELLET_STRING << PLUG_STRING << WHOLE_STRING);
}

//////////////////////////////////////////////////////////3/////////////////////
// recalc()
// --------
// Recalculate internal values

void Hop::recalc()
{
    hbu_ = 0.75 * alpha_ * weight_.amount(Weight::ounce);
}