00001 00002 /* 00003 * 00004 * Copyright (c) 2005-2008 Instigate cjsc, Yerevan, Armenia. 00005 * All rights reserved. 00006 * 00007 */ 00008 00009 00010 #ifndef INSTIGATE_GEOMETRY_LINE 00011 #define INSTIGATE_GEOMETRY_LINE 00012 00024 // Headers from this project 00025 #include "concept_line.hpp" 00026 #include "point.hpp" 00027 00028 // Headers from other projects 00029 #include <generic/base.hpp> 00030 00031 // Headers from standard libraries 00032 00033 // Forward declarations 00034 00035 namespace instigate { 00036 namespace geometry { 00037 class line; 00038 } 00039 } 00040 00047 class instigate::geometry::line 00048 { 00050 public: 00051 typedef point point_type; 00052 00054 public: 00055 typedef point::coordinate_type coordinate_type; 00056 00057 private: 00058 coordinate_type m_source_x; 00059 coordinate_type m_source_y; 00060 coordinate_type m_target_x; 00061 coordinate_type m_target_y; 00062 00063 public: 00072 void set_source_x(const coordinate_type& v) throw(); 00073 00082 void set_source_y(const coordinate_type& v) throw(); 00083 00092 void set_target_x(const coordinate_type& v) throw(); 00093 00102 void set_target_y(const coordinate_type& v) throw(); 00103 00112 const coordinate_type& get_source_x() const throw(); 00113 00122 const coordinate_type& get_source_y() const throw(); 00123 00132 const coordinate_type& get_target_x() const throw(); 00133 00142 const coordinate_type& get_target_y() const throw(); 00143 00145 public: 00147 ~line() throw(); 00148 00150 line() throw(); 00151 00160 line(coordinate_type a, 00161 coordinate_type b, 00162 coordinate_type c, 00163 coordinate_type d) throw(); 00164 00170 line(const line& l) throw(); 00171 00179 template <typename L> 00180 line(const L& l) 00181 : m_source_x(geometry::concept::line::interface<L>:: 00182 get_source_x(l)) 00183 , m_source_y(geometry::concept::line::interface<L>:: 00184 get_source_y(l)) 00185 , m_target_x(geometry::concept::line::interface<L>:: 00186 get_target_x(l)) 00187 , m_target_y(geometry::concept::line::interface<L>:: 00188 get_target_y(l)) 00189 { 00190 CHECK( concept::line::requirements<L> ); 00191 } 00192 00198 line& operator=(const line& l) throw(); 00199 00208 template <typename L> 00209 line& operator=(const L& l) 00210 { 00211 CHECK( concept::line::requirements<L> ); 00212 if (this != &l) { 00213 m_source_x = concept::line::interface<L>:: 00214 get_source_x(l); 00215 m_source_y = concept::line::interface<L>:: 00216 get_source_y(l); 00217 m_target_x = concept::line::interface<L>:: 00218 get_target_x(l); 00219 m_target_y = concept::line::interface<L>:: 00220 get_target_y(l); 00221 } 00222 return *this; 00223 } 00224 00225 }; // class instigate::geometry::line 00226 00227 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00228 00229 #endif // INSTIGATE_GEOMETRY_LINE 00230