TrueReality  v0.1.1912
trUtil::EnumerationString Class Reference

This class represents a type-safe EnumerationString pattern. More...

#include <EnumerationString.h>

Inheritance diagram for trUtil::EnumerationString:

Public Member Functions

const std::string & GetName () const
 Inlined because it's called frequently. More...
 
bool operator== (const EnumerationString &rhs) const
 Equality test for an EnumerationString. More...
 
bool operator!= (const EnumerationString &rhs) const
 Inequality test for an EnumerationString. More...
 
bool operator== (const std::string &rhs) const
 Overloaded string compare operator for the EnumerationString. More...
 
bool operator!= (const std::string &rhs) const
 Overloaded inequality test for this EnumerationString's string value. More...
 
bool operator< (const std::string &rhs) const
 Overloaded less than test for this EnumerationString's string value. More...
 
bool operator> (const std::string &rhs) const
 Overloaded greater than test for this EnumerationString's string value. More...
 
bool operator< (const EnumerationString &rhs) const
 Overloaded less than operator. More...
 

Protected Member Functions

virtual int Compare (const std::string &nameString) const
 Virtual string compare method to used by the operators that take a string. More...
 
virtual ~EnumerationString ()
 Private virtual destructor to get rid of compile warning. More...
 
 EnumerationString (const std::string &name)
 Construct the EnumerationString. More...
 

Private Member Functions

EnumerationStringoperator= (const EnumerationString &)
 Private assignment operator to enforce EnumerationString storage by reference. More...
 
 EnumerationString (const EnumerationString &)
 Private copy constructor to enforce EnumerationString storage by reference. More...
 

Private Attributes

std::string mName
 String representation of the EnumerationString. More...
 

Detailed Description

This class represents a type-safe EnumerationString pattern.

It allows one to also enumerate an EnumerationString thus looking up values in a list fashion.

Definition at line 57 of file EnumerationString.h.

Constructor & Destructor Documentation

◆ ~EnumerationString()

trUtil::EnumerationString::~EnumerationString ( )
protectedvirtual

Private virtual destructor to get rid of compile warning.

Definition at line 60 of file EnumerationString.cpp.

◆ EnumerationString() [1/2]

trUtil::EnumerationString::EnumerationString ( const std::string &  name)
protected

Construct the EnumerationString.

Note
When creating a new EnumerationString, the constructor of derived types must call addInstance(this) in order for EnumerationStrings to be enumerated.
Parameters
nameThe name.

Definition at line 65 of file EnumerationString.cpp.

◆ EnumerationString() [2/2]

trUtil::EnumerationString::EnumerationString ( const EnumerationString )
private

Private copy constructor to enforce EnumerationString storage by reference.

Parameters
parameter1The first parameter.

Definition at line 77 of file EnumerationString.cpp.

Member Function Documentation

◆ Compare()

int trUtil::EnumerationString::Compare ( const std::string &  nameString) const
protectedvirtual

Virtual string compare method to used by the operators that take a string.

This allows overriding the behavior in a subclass. It should work like std::string::compare.

Parameters
nameStringThe constant standard string& to compare to this object.
Returns
Negative if 'nameString' is less than '', 0 if they are equal, or positive if it is greater.

Definition at line 54 of file EnumerationString.cpp.

References mName.

Referenced by operator!=(), trUtil::EnumerationNumeric::operator!=(), operator<(), trUtil::EnumerationNumeric::operator<(), operator==(), trUtil::EnumerationNumeric::operator==(), operator>(), and trUtil::EnumerationNumeric::operator>().

Here is the caller graph for this function:

◆ GetName()

const std::string & trUtil::EnumerationString::GetName ( ) const
inline

Inlined because it's called frequently.

Returns
the string representation of this EnumerationString.

Definition at line 68 of file EnumerationString.h.

Referenced by trManager::ActorBase::AddActorModule(), trManager::EntityBase::AddChild(), trUtil::operator<<(), and trManager::ActorBase::RemoveActorModule().

Here is the caller graph for this function:

◆ operator!=() [1/2]

bool trUtil::EnumerationString::operator!= ( const EnumerationString rhs) const
inline

Inequality test for an EnumerationString.

Inlined because it's called frequently.

Parameters
rhsThe right hand side.
Returns
True if the parameters are not considered equivalent.
See also
operator==

Definition at line 101 of file EnumerationString.h.

References trUtil::operator!=(), and trUtil::operator==().

Here is the call graph for this function:

◆ operator!=() [2/2]

bool trUtil::EnumerationString::operator!= ( const std::string &  rhs) const

Overloaded inequality test for this EnumerationString's string value.

Parameters
rhsThe right hand side.
Returns
True if the parameters are not considered equivalent.

Definition at line 36 of file EnumerationString.cpp.

References Compare().

Here is the call graph for this function:

◆ operator<() [1/2]

bool trUtil::EnumerationString::operator< ( const std::string &  rhs) const

Overloaded less than test for this EnumerationString's string value.

Parameters
rhsThe right hand side.
Returns
True if the first parameter is less than the second.

Definition at line 42 of file EnumerationString.cpp.

References Compare().

Here is the call graph for this function:

◆ operator<() [2/2]

bool trUtil::EnumerationString::operator< ( const EnumerationString rhs) const
inline

Overloaded less than operator.

This checks the memory addresses of the two EnumerationStrings. Inlined because it's called frequently.

Parameters
rhsThe second EnumerationString to compare to this one.
Returns
True if this EnumerationString is less than rhs.
Note
This method is supported by EnumerationStrings so they may be used as keys in STL containers. Since memory addresses are guaranteed to be unique this methods works fine. However, it really does not make sense to use this method of comparison in other circumstances.

Definition at line 169 of file EnumerationString.h.

◆ operator=()

EnumerationString & trUtil::EnumerationString::operator= ( const EnumerationString )
private

Private assignment operator to enforce EnumerationString storage by reference.

Parameters
parameter1The first parameter.
Returns
A shallow copy of this object.

Definition at line 71 of file EnumerationString.cpp.

◆ operator==() [1/2]

bool trUtil::EnumerationString::operator== ( const EnumerationString rhs) const
inline

Equality test for an EnumerationString.

Since EnumerationString objects are static, and only references to EnumerationStrings may be stored by the user, it is safe and efficient to compare EnumerationString objects based on their memory address. Inlined because it's called frequently.

Parameters
rhsThe right hand side.
Returns
True if the parameters are considered equivalent.

Definition at line 85 of file EnumerationString.h.

◆ operator==() [2/2]

bool trUtil::EnumerationString::operator== ( const std::string &  rhs) const

Overloaded string compare operator for the EnumerationString.

This will compare the string to this EnumerationStrings getName() value.

Parameters
rhs.
Returns
True if they are equal.
Note
Uses the STL string compare method implying that the rules for string equality are the same as they are for the STL string compare method.

Definition at line 30 of file EnumerationString.cpp.

References Compare().

Here is the call graph for this function:

◆ operator>()

bool trUtil::EnumerationString::operator> ( const std::string &  rhs) const

Overloaded greater than test for this EnumerationString's string value.

Parameters
rhsThe right hand side.
Returns
True if the first parameter is greater than to the second.

Definition at line 48 of file EnumerationString.cpp.

References Compare().

Here is the call graph for this function:

Member Data Documentation

◆ mName

std::string trUtil::EnumerationString::mName
private

String representation of the EnumerationString.

Definition at line 221 of file EnumerationString.h.

Referenced by Compare().


The documentation for this class was generated from the following files: