Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LengthUnit.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2016 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OMNI_LENGTHUNIT_H_
20 #define OMNI_LENGTHUNIT_H_
21 
22 #include <map>
23 #include <QString>
25 
26 namespace omni {
27  /// An encapsulation for length units
28  class LengthUnit {
29  public:
30  /// Supported unit types
31  enum Type {
35  };
36 
37  /// Make a new unit with a certain type
39 
40  /// Make a new unit from abbreviation type
41  LengthUnit(QString const&);
42 
43  /// Return abbreviation for unit with type
44  static QString abbreviation(Type);
45 
46  /// Return abbreviation of unit
47  QString abbreviation() const;
48 
49  /// Get unit type from abbreviation
50  static Type type(QString const& abbr);
51 
52  /// Return type of unit
53  Type type() const;
54 
55  /// Set type of unit
56  void setType(Type);
57 
58  /// Return singular name of unit with type
59  static QString nameSingular(Type);
60 
61  /// Return singular name of unit
62  QString nameSingular() const;
63 
64  /// Return plural name of unit with type
65  static QString namePlural(Type);
66 
67  /// Return plural name of unit
68  QString namePlural() const;
69 
70  /// Deserialize from stream
71  void fromStream(QDataStream&);
72 
73  /// Serialize to stream
74  void toStream(QDataStream&) const;
75 
76  /// Test for equality. ScreenSetup is ignored
77  friend bool operator==(LengthUnit const&,
78  LengthUnit const&);
79 
80  private:
81  typedef std::map<Type, QString>map_type;
82 
84  };
85 }
86 
88 OMNI_DECL_STREAM_OPERATORS(omni::LengthUnit)
89 
90 #endif /* OMNI_LENGTHUNIT_H_ */
LengthUnit(Type=METER)
Make a new unit with a certain type.
Definition: LengthUnit.cpp:25
#define OMNI_DECL_ENUM_STREAM_OPERATORS(ENUM)
Definition: Interface.h:65
Type type_
Definition: LengthUnit.h:83
Definition: LengthUnit.h:32
Definition: LengthUnit.h:34
Definition: LengthUnit.h:33
void setType(Type)
Set type of unit.
Definition: LengthUnit.cpp:83
std::map< Type, QString > map_type
Definition: LengthUnit.h:81
An encapsulation for length units.
Definition: LengthUnit.h:28
Definition: LengthUnit.h:33
void toStream(QDataStream &) const
Serialize to stream.
Definition: LengthUnit.cpp:143
friend bool operator==(LengthUnit const &, LengthUnit const &)
Test for equality. ScreenSetup is ignored.
Definition: LengthUnit.cpp:148
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
Definition: LengthUnit.h:32
Definition: LengthUnit.h:32
QString nameSingular() const
Return singular name of unit.
Definition: LengthUnit.cpp:108
Definition: LengthUnit.h:33
Type
Supported unit types.
Definition: LengthUnit.h:31
QString abbreviation() const
Return abbreviation of unit.
Definition: LengthUnit.cpp:53
void fromStream(QDataStream &)
Deserialize from stream.
Definition: LengthUnit.cpp:138
QString namePlural() const
Return plural name of unit.
Definition: LengthUnit.cpp:133
Type type() const
Return type of unit.
Definition: LengthUnit.cpp:78