Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Phx::ValueType< TypeName, T > Class Template Reference

Provides a base class for standard value types. More...

#include <PhxTemplates.h>

List of all members.

Public Member Functions

 ValueType (T val)
bool operator== (const ValueType< TypeName, T > &rhs) const
bool operator!= (const ValueType< TypeName, T > &rhs) const
bool operator< (const ValueType< TypeName, T > &rhs) const
bool operator<= (const ValueType< TypeName, T > &rhs) const
bool operator> (const ValueType< TypeName, T > &rhs) const
bool operator>= (const ValueType< TypeName, T > &rhs) const
const ValueType< TypeName,
T > & 
operator= (const ValueType< TypeName, T > &rhs)
value () const
void value (T v)


Detailed Description

template<class TypeName, class T>
class Phx::ValueType< TypeName, T >

Provides a base class for standard value types.

The purpose of this class is to provide additional type safety and impose additional restrictions on the use of primitive types. Rather than simply typedef'ing types from primitives (like int or double), we encapsulate them in a class. This prevents accidental type conversions. The primary purpose of this class is to serve as a base for more complicated, safe value types.

Standard value types are characterized as types which represent quantities that are == comparable and assignable. Examples include Kilograms, AircraftSerialNumber. Examples of types that are NOT value types include Aircraft, Timer. While it is true that one _could_ define =/== for a Timer and Aircraft class, the semantics are specific to how that class was implemented -- it isn't clear from looking at either class _exactly_ when two instances are equal. Value types, however, encapsulating just one value with a specific meaning make it clear exactly when two objects will compare as equal.

 class KilogramsClass;
 typedef ValueType<KilogramsClass, double>  Kilograms;

The default constructor sets the internal value to 0. Clearly this means that any type for which a statement of the form: T t(0); is not legal will not work as a type for this class.


The documentation for this class was generated from the following file:
Generated on Wed Dec 21 22:05:39 2005 for Phoenix OSFS by  doxygen 1.4.2