TrueReality  v0.1.1912
EnumerationNumeric.cpp
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
23 
24 namespace trUtil
25 {
27  EnumerationNumeric::EnumerationNumeric(const std::string& name, unsigned int id) : BaseClass(name), mID(id)
28  {
29  }
30 
33  {
34  return *this;
35  }
36 
38  bool EnumerationNumeric::operator==(const std::string& rhs) const
39  {
40  return Compare(rhs) == 0;
41  }
42 
44  bool EnumerationNumeric::operator!=(const std::string& rhs) const
45  {
46  return Compare(rhs) != 0;
47  }
48 
50  bool EnumerationNumeric::operator<(const std::string& rhs) const
51  {
52  return Compare(rhs) < 0;
53  }
54 
56  bool EnumerationNumeric::operator>(const std::string& rhs) const
57  {
58  return Compare(rhs) > 0;
59  }
60 
63  {
64  }
65 
67  unsigned int EnumerationNumeric::GetID() const
68  {
69  return mID;
70  }
71 
73  std::ostream& operator<<(std::ostream& os, const EnumerationNumeric& e)
74  {
75  os << e.GetName() << ":" << e.GetID();
76  return os;
77  }
78 }
unsigned int mID
The identifier.
const std::string & GetName() const
Inlined because it&#39;s called frequently.
bool operator<(const unsigned int &id) const
Less than test for an EnumerationNumeric.
This class represents a type-safe Enumeration pattern.
bool operator!=(const unsigned int &id) const
Inequality test for an EnumerationNumeric.
bool operator==(const unsigned int &id) const
Equality test for an EnumerationNumeric.
TR_UTIL_EXPORT std::ostream & operator<<(std::ostream &os, const EnumerationString &e)
Helper method to print EnumerationNumeric to an output stream.
virtual int Compare(const std::string &nameString) const
Virtual string compare method to used by the operators that take a string.
This class represents a type-safe EnumerationString pattern.
bool operator>(const unsigned int &id) const
Greater than test for an EnumerationNumeric.
Namespace that holds various utility classes for the engine.
Definition: SmrtPtr.h:208
unsigned int GetID() const
Returns the Numeric value of the Enum.
EnumerationNumeric(const std::string &name, unsigned int orderId)
ctor Protected to prevent creation of an instance.
EnumerationNumeric & operator=(const EnumerationNumeric &)
Private assignment operator to enforce EnumerationNumeric storage by reference.