1 /* === S I N F G =========================================================== */
3 ** \brief Template Header
5 ** $Id: distance.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_DISTANCE_H
25 #define __SINFG_DISTANCE_H
27 /* === H E A D E R S ======================================================= */
32 /* === M A C R O S ========================================================= */
34 /* === T Y P E D E F S ===================================================== */
36 /* === C L A S S E S & S T R U C T S ======================================= */
45 typedef Real value_type;
55 SYSTEM_MILLIMETERS, //!<
56 SYSTEM_CENTIMETERS, //!<
58 SYSTEM_END //!< \internal
72 Distance(const value_type& value, System system):value_(value),system_(system) { }
73 explicit Distance(const sinfg::String& string);
75 operator Real()const { return value_; }
77 Distance& operator=(const Real& rhs) { value_=rhs; return *this; }
79 Distance& operator=(const sinfg::String& rhs);
81 sinfg::String get_string(int digits=4)const;
83 const System& get_system()const { return system_; }
85 const Real& get()const { return value_; }
87 Real get(System system, const RendDesc& rend_desc)const;
89 void convert(System system, const RendDesc& rend_desc);
92 Real meters(const RendDesc& rend_desc)const;
93 Real units(const RendDesc& rend_desc)const;
95 static Real meters_to_system(Real x, System target_system);
96 static System ident_system(const sinfg::String& str);
97 static sinfg::String system_name(System system);
98 static sinfg::String system_local_name(System system);
100 const Distance& operator+=(const Distance &rhs) { value_+=meters_to_system(rhs.meters(),system_); return *this; }
101 const Distance& operator-=(const Distance &rhs) { value_-=meters_to_system(rhs.meters(),system_); return *this; }
103 const Distance& operator+=(const float &rhs) { value_+=rhs; return *this; }
104 const Distance& operator-=(const float &rhs) { value_-=rhs; return *this; }
105 const Distance& operator*=(const float &rhs) { value_*=rhs; return *this; }
106 const Distance& operator/=(const float &rhs) { value_/=rhs; return *this; }
109 template<typename U> const Time& operator+=(const U &rhs) { value_+=rhs; return *this; }
110 template<typename U> const Time& operator-=(const U &rhs) { value_-=rhs; return *this; }
111 template<typename U> const Time& operator*=(const U &rhs) { value_*=rhs; return *this; }
112 template<typename U> const Time& operator/=(const U &rhs) { value_/=rhs; return *this; }
114 template<typename U> Time operator+(const U &rhs)const { return value_+rhs; }
115 template<typename U> Time operator-(const U &rhs)const { return value_-rhs; }
116 template<typename U> Time operator*(const U &rhs)const { return value_*rhs; }
117 template<typename U> Time operator/(const U &rhs)const { return value_/rhs; }
119 Time operator-()const { return -value_; }
121 }; // END of class Distance
123 }; // END of namespace sinfg
125 /* === E N D =============================================================== */