00001 00002 /* 00003 * 00004 * Copyright (c) 2005-2008 Instigate cjsc, Yerevan, Armenia. 00005 * All rights reserved. 00006 * 00007 * This file is part of Instigate Application Framework. It is property of 00008 * Instigate cjsc, Yerevan, Armenia. Only users who have received written 00009 * authorization from Instigate cjsc are allowed to use, copy or modify this 00010 * code. Use at your own risk. Instigate is not responsible for any damage 00011 * caused directly or indirectly by using this code. 00012 * 00013 */ 00014 00015 00016 #ifndef INSTIGATE_GEOMETRY_POINT 00017 #define INSTIGATE_GEOMETRY_POINT 00018 00030 // Headers from this project 00031 #include "concept_point.hpp" 00032 00033 // Headers from other projects 00034 00035 // Headers from standard libraries 00036 00037 // Forward declarations 00038 00039 namespace instigate { 00040 namespace geometry { 00041 class point; 00042 } 00043 } 00044 00050 class instigate::geometry::point 00051 { 00053 public: 00055 typedef double coordinate_type; 00056 private: 00057 coordinate_type m_x; 00058 coordinate_type m_y; 00059 public: 00068 void set_x(const coordinate_type& v) throw(); 00069 00078 void set_y(const coordinate_type& v) throw(); 00079 00088 coordinate_type get_x() const throw(); 00089 00098 coordinate_type get_y() const throw(); 00099 00101 public: 00103 ~point() throw() 00104 {} 00105 00107 point() throw() 00108 : m_x(0) 00109 , m_y(0) 00110 {} 00111 00118 point(coordinate_type x, coordinate_type y) throw(); 00119 00125 point(const point& p) throw(); 00126 00134 template <typename P> 00135 point(const P& p) 00136 : m_x(geometry::concept::point::interface<P>::get_x(p)) 00137 , m_y(geometry::concept::point::interface<P>::get_y(p)) 00138 { 00139 CHECK( concept::point::requirements<P> ); 00140 } 00141 00147 point& operator=(const point& p) throw(); 00148 00157 template <typename P> 00158 point& operator=(const P& p) 00159 { 00160 CHECK(concept::point::requirements<P>); 00161 typedef instigate::geometry::concept::point:: 00162 interface<P> PI; 00163 typedef typename PI::coordinate_type C; 00164 CHECK_CONVERTIBILITY(C, coordinate_type); 00165 if (this != &p) { 00166 m_x = concept::point::interface<P>::get_x(p); 00167 m_y = concept::point::interface<P>::get_y(p); 00168 } 00169 return *this; 00170 } 00171 00172 }; // class instigate::geometry::point 00173 00174 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00175 00176 #endif // INSTIGATE_GEOMETRY_POINT 00177