nomlib
Loading...
Searching...
No Matches
nom::ObjectTypeInfo Class Reference

Run-time type information (RTTI) container class. More...

#include <ObjectTypeInfo.hpp>

Public Types

typedef ObjectTypeInfo self_type
typedef std::type_index value_type

Public Member Functions

 ObjectTypeInfo (void)
 Default constructor; initializes the object's type info as itself (this should be regarded as an invalid object state).
 ~ObjectTypeInfo (void)
 Destructor.
 ObjectTypeInfo (const self_type &copy)
 Copy constructor.
self_type & operator= (const self_type &other)
 Copy assignment operator.
 ObjectTypeInfo (const value_type &object)
 Constructor for a complete object initialization.
const std::string name (void) const
 Get the object type's name.
size_t hash_code (void) const
 Get the object's type hash code.
void set_type (const ObjectTypeInfo::value_type &object)
 Setter for the object's type.
bool operator== (const self_type &rhs) const
 Equality comparison operator.
bool operator!= (const self_type &rhs) const
 In-equality comparison operator.

Private Member Functions

const value_type & type (void) const
 Getter for the internal container type used.

Private Attributes

value_type type_
 Type information container.

Detailed Description

Run-time type information (RTTI) container class.

This utility class implementation is done primarily to help encapsulate implementation details that are subject to availability – not all platforms support RTTI (typeid, std::type_index), nor are the supported platforms implemented the same (i.e.: name strings).

See also: nom::IObject.

References (class design & ideas):

http://stackoverflow.com/questions/5330835/why-is-stdtype-info-noncopyable-am-i-allowed-to-store-it-somewhere http://docs.wxwidgets.org/trunk/classwx_class_info.html

Definition at line 40 of file ObjectTypeInfo.hpp.

Member Typedef Documentation

◆ self_type

typedef ObjectTypeInfo nom::ObjectTypeInfo::self_type

Definition at line 43 of file ObjectTypeInfo.hpp.

◆ value_type

typedef std::type_index nom::ObjectTypeInfo::value_type

Definition at line 44 of file ObjectTypeInfo.hpp.

Constructor & Destructor Documentation

◆ ObjectTypeInfo()

nom::ObjectTypeInfo::ObjectTypeInfo ( const value_type & object)

Constructor for a complete object initialization.

Parameters
std::type_infoobject; pass through the typeid method.

Member Function Documentation

◆ hash_code()

size_t nom::ObjectTypeInfo::hash_code ( void ) const

Get the object's type hash code.

Returns
A hash code value that identifies the type.
Remarks
This function returns the same value for any two type_info objects that compare equal.
Note
The particular values returned are implementation-defined and may vary between executions of the same program.

◆ name()

const std::string nom::ObjectTypeInfo::name ( void ) const

Get the object type's name.

Returns
A null-terminated character sequence that may identify the object's type.
Note
The particular representation pointed by the returned value is implementation-defined, and may or may not be different for different types.

◆ operator==()

bool nom::ObjectTypeInfo::operator== ( const self_type & rhs) const

Equality comparison operator.

Remarks
This operator overload is provided so that we are able to conveniently compare two nom::ObjectTypeInfo objects with minimal effort – note that we could not have ::type declared under private scope if not for this provision.

Member Data Documentation

◆ type_

value_type nom::ObjectTypeInfo::type_
private

Type information container.

Definition at line 104 of file ObjectTypeInfo.hpp.


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