| 1 | /*************************************************************************** |
| 2 | misc.h |
| 3 | ------------------- |
| 4 | A generic ingredient class |
| 5 | ------------------- |
| 6 | Copyright 1999-2008, David Johnson |
| 7 | All rights reserved. |
| 8 | |
| 9 | Redistribution and use in source and binary forms, with or without |
| 10 | modification, are permitted provided that the following conditions are met: |
| 11 | |
| 12 | 1. Redistributions of source code must retain the above copyright notice, |
| 13 | this list of conditions and the following disclaimer. |
| 14 | |
| 15 | 2. Redistributions in binary form must reproduce the above copyright notice, |
| 16 | this list of conditions and the following disclaimer in the documentation |
| 17 | and/or other materials provided with the distribution. |
| 18 | |
| 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' |
| 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | POSSIBILITY OF SUCH DAMAGE. |
| 30 | ***************************************************************************/ |
| 31 | |
| 32 | #ifndef MISC_H |
| 33 | #define MISC_H |
| 34 | |
| 35 | #include <QList> |
| 36 | #include <QMap> |
| 37 | #include <QString> |
| 38 | |
| 39 | #include "quantity.h" |
| 40 | |
| 41 | class Misc { |
| 42 | public: |
| 43 | // misc strings |
| 44 | static const QByteArray YEAST_STRING; |
| 45 | static const QByteArray FINING_STRING; |
| 46 | static const QByteArray HERB_STRING; |
| 47 | static const QByteArray SPICE_STRING; |
| 48 | static const QByteArray FLAVOR_STRING; |
| 49 | static const QByteArray ADDITIVE_STRING; |
| 50 | static const QByteArray OTHER_STRING; |
| 51 | |
| 52 | // default constructor |
| 53 | Misc(); |
| 54 | // full constructor |
| 55 | Misc(const QString &name, const Quantity &quantity, |
| 56 | const QString &typ, const QString ¬es); |
| 57 | // copy constructor |
| 58 | Misc(const Misc &m); |
| 59 | // assignment operator |
| 60 | Misc operator=(const Misc &m); |
| 61 | // comparison operator |
| 62 | bool operator==(const Misc &m) const; |
| 63 | bool operator<(const Misc &m) const; |
| 64 | // destructor |
| 65 | ~Misc(); |
| 66 | |
| 67 | //get/set name |
| 68 | const QString &name() const; |
| 69 | void setName(const QString &name); |
| 70 | // get/set quantity |
| 71 | const Quantity &quantity() const; |
| 72 | void setQuantity(const Quantity &quantity); |
| 73 | // get/set type |
| 74 | const QString &type() const; |
| 75 | void setType(const QString &typ); |
| 76 | // get/set notes |
| 77 | const QString ¬es() const; |
| 78 | void setNotes(const QString ¬es); |
| 79 | |
| 80 | // list of misc type |
| 81 | static QStringList typeStringList(); |
| 82 | |
| 83 | private: |
| 84 | QString name_; |
| 85 | Quantity quantity_; |
| 86 | QString type_; |
| 87 | QString notes_; |
| 88 | }; |
| 89 | |
| 90 | typedef QList<Misc> MiscList; |
| 91 | typedef QMap<QString,Misc> MiscMap; |
| 92 | |
| 93 | ////////////////////////////////////////////////////////////////////////////// |
| 94 | // Inlined Methods |
| 95 | |
| 96 | inline bool Misc::operator<(const Misc &m) const { return (name_ < m.name_); } |
| 97 | |
| 98 | inline void Misc::setName(const QString &name) { name_ = name; } |
| 99 | |
| 100 | inline const QString &Misc::name() const { return name_; } |
| 101 | |
| 102 | inline void Misc::setQuantity(const Quantity &quantity) { quantity_ = quantity; } |
| 103 | |
| 104 | inline const Quantity &Misc::quantity() const { return quantity_; } |
| 105 | |
| 106 | inline void Misc::setType(const QString &typ) { type_ = typ; } |
| 107 | |
| 108 | inline const QString &Misc::type() const { return type_; } |
| 109 | |
| 110 | inline void Misc::setNotes(const QString ¬es) { notes_ = notes; } |
| 111 | |
| 112 | inline const QString &Misc::notes() const{ return notes_; } |
| 113 | |
| 114 | #endif // MISC_H |