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

PhxTemplates.h

Go to the documentation of this file.
00001 #ifndef PHX_TEMPLATES_H
00002 #define PHX_TEMPLATES_H
00003 
00011 #include <Phx/PhxConfig.h>
00012 #include <iostream>
00013 
00014 namespace Phx {
00015 
00046   template <class TypeName, class T>
00047     class ValueType {
00048     public:
00049     // Default constructor sets to 0.
00050     ValueType() : mValue(0) {}
00051 
00052     explicit ValueType(T val) : mValue(val) {}
00053     
00054     bool operator==(const ValueType<TypeName, T>& rhs) const {
00055       return mValue == rhs.mValue;
00056     }
00057     
00058     bool operator!=(const ValueType<TypeName, T>& rhs) const {
00059       return !operator==(rhs);
00060     }
00061 
00062     bool operator<(const ValueType<TypeName, T>& rhs) const {
00063       return mValue < rhs.mValue;
00064     }
00065     bool operator<=(const ValueType<TypeName, T>& rhs) const {
00066       return mValue <= rhs.mValue;
00067     }
00068     bool operator>(const ValueType<TypeName, T>& rhs) const {
00069       return mValue > rhs.mValue;
00070     }
00071     bool operator>=(const ValueType<TypeName, T>& rhs) const {
00072       return mValue >= rhs.mValue;
00073     }
00074 
00075     const ValueType<TypeName, T>&
00076       operator=(const ValueType<TypeName, T>& rhs) {
00077       mValue = rhs.mValue;
00078       return *this;
00079     }
00080     
00081     T value() const { return mValue; }
00082     void value(T v) { mValue = v; }
00083 
00084     private:
00085     T mValue;
00086   };
00087 
00088   // stream operators for ValueType's
00089   template <class TypeName, class T>
00090     std::ostream& operator<<(std::ostream& os, const ValueType<TypeName, T>& v) {
00091     os << v.value();
00092     return os;
00093   }
00094 
00095   template <class TypeName, class T>
00096     std::istream& operator>>(std::istream& is, ValueType<TypeName, T>& v) {
00097     T newV;
00098     is >> newV;
00099     v.value(newV);
00100     return is;
00101   }
00102 
00103 };
00104 
00105 #endif /* PHX_TEMPLATES_H */

Generated on Mon Jul 10 19:45:29 2006 for Phoenix OSFS by  doxygen 1.4.2