00001 00002 /* 00003 * 00004 * Copyright (c) 2005-2008 Instigate cjsc, Yerevan, Armenia. 00005 * All rights reserved. 00006 * 00007 */ 00008 00009 00010 #ifndef INSTIGATE_GEOMETRY_RECTANGLE 00011 #define INSTIGATE_GEOMETRY_RECTANGLE 00012 00024 // Headers from this project 00025 #include "point.hpp" 00026 #include "concept_rectangle.hpp" 00027 00028 // Headers from other projects 00029 00030 // Headers from standard libraries 00031 00032 // Forward declarations 00033 00034 namespace instigate { 00035 namespace geometry { 00036 class rectangle; 00037 } 00038 } 00039 00046 class instigate::geometry::rectangle 00047 { 00049 public: 00054 typedef point::coordinate_type coordinate_type; 00055 private: 00056 coordinate_type m_left; 00057 coordinate_type m_bottom; 00058 coordinate_type m_right; 00059 coordinate_type m_top; 00060 public: 00069 coordinate_type get_left() const throw(); 00070 00079 coordinate_type get_bottom() const throw(); 00080 00089 coordinate_type get_right() const throw(); 00090 00099 coordinate_type get_top() const throw(); 00100 00118 void set_left(const coordinate_type& l) throw(); 00119 00137 void set_bottom(const coordinate_type& b) throw(); 00138 00156 void set_right(const coordinate_type& r) throw(); 00157 00175 void set_top(const coordinate_type& t) throw(); 00176 00178 public: 00180 ~rectangle() throw(); 00181 00183 rectangle() throw(); 00184 00193 rectangle(coordinate_type l, 00194 coordinate_type b, 00195 coordinate_type r, 00196 coordinate_type t) throw() 00197 : m_left(l) 00198 , m_bottom(b) 00199 , m_right(r) 00200 , m_top(t) 00201 { 00202 } 00203 00209 rectangle(const rectangle& r) throw(); 00210 00222 template <typename R> 00223 rectangle(const R& r) 00224 : m_left(concept::rectangle::interface<R>::get_left(r)) 00225 , m_bottom(concept::rectangle::interface<R>::get_bottom(r)) 00226 , m_right(concept::rectangle::interface<R>::get_right(r)) 00227 , m_top(concept::rectangle::interface<R>::get_top(r)) 00228 { 00229 } 00230 00236 rectangle& operator=(const rectangle& r) throw(); 00237 00246 template <typename R> 00247 rectangle& operator=(const R& r) 00248 { 00249 CHECK( concept::rectangle::requirements<R> ); 00250 if (this != &r) { 00251 m_left = concept::point::interface<R>::get_left(r); 00252 m_bottom = concept::point::interface<R>::get_bottom(r); 00253 m_right = concept::point::interface<R>::get_right(r); 00254 m_top = concept::point::interface<R>::get_top(r); 00255 } 00256 return *this; 00257 } 00258 }; // class instigate::geometry::rectangle 00259 00260 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00261 00262 #endif // INSTIGATE_GEOMETRY_RECTANGLE 00263