00001 00002 /* 00003 * 00004 * Copyright (c) 2005-2008 Instigate cjsc, Yerevan, Armenia. 00005 * All rights reserved. 00006 * 00007 */ 00008 00009 00010 #ifndef INSTIGATE_GEOMETRY_CONCEPT_POINT_INTERFACE 00011 #define INSTIGATE_GEOMETRY_CONCEPT_POINT_INTERFACE 00012 00042 // Headers from this project 00043 00044 // Headers from other projects 00045 #include <stl/concept.hpp> 00046 #include <stl/concept.hpp> 00047 #include <generic/base.hpp> 00048 00049 // Headers from standard libraries 00050 #include <limits> 00051 00052 // Forward declarations 00053 namespace instigate { 00058 namespace geometry { 00059 namespace concept { 00060 namespace point { 00061 template<typename T> struct interface; 00062 template<typename T> struct requirements; 00063 } 00064 } 00065 } 00066 } 00067 00095 template<typename T> 00096 struct instigate::geometry::concept::point::interface 00097 : public instigate::default_constructible::interface<T> 00098 , public instigate::assignable::interface<T> 00099 00100 { 00102 public: 00108 typedef typename T::coordinate_type coordinate_type; 00109 00110 public: 00122 static void set_x(T& p, const coordinate_type& v) 00123 { 00124 p.set_x(v); 00125 } 00126 00138 static void set_y(T& p, const coordinate_type& v) 00139 { 00140 p.set_y(v); 00141 } 00142 00143 00154 static coordinate_type get_x(const T& p) 00155 { 00156 return p.get_x(); 00157 } 00158 00159 00170 static coordinate_type get_y(const T& p) 00171 { 00172 return p.get_y(); 00173 } 00174 00175 }; // struct instigate::geometry::concept::point::interface 00176 00184 template <typename T> 00185 struct instigate::geometry::concept::point::requirements 00186 : public instigate::default_constructible::requirements<T> 00187 , public instigate::assignable::requirements<T> 00188 { 00196 void require_nested_typename_coordinate_type() 00197 { 00198 typedef instigate::geometry::concept::point:: 00199 interface<T> PC; 00200 typedef typename PC::coordinate_type P; 00201 } 00202 00211 void require_numeric_coordinate_type() 00212 { 00213 namespace P = concept::point; 00214 typedef typename P::interface<T>::coordinate_type C; 00215 CHECK(generic::require<std::numeric_limits<C>:: 00216 is_specialized>); 00217 } 00218 00227 void require_set_x(T& p, typename instigate::geometry:: 00228 concept::point::interface<T>::coordinate_type a) 00229 { 00230 typedef instigate::geometry::concept::point:: 00231 interface<T> PC; 00232 PC::set_x(p, a); 00233 } 00234 00243 void require_set_y(T& p, typename instigate::geometry:: 00244 concept::point::interface<T>::coordinate_type a) 00245 { 00246 typedef instigate::geometry::concept::point:: 00247 interface<T> PC; 00248 PC::set_y(p, a); 00249 } 00250 00258 typename instigate::geometry::concept::point::interface<T>:: 00259 coordinate_type require_get_x(const T& p) 00260 { 00261 typedef instigate::geometry::concept::point:: 00262 interface<T> PC; 00263 return PC::get_x(p); 00264 } 00265 00273 typename instigate::geometry::concept::point::interface<T>:: 00274 coordinate_type require_get_y(const T& p) 00275 { 00276 typedef instigate::geometry::concept::point:: 00277 interface<T> PC; 00278 return PC::get_y(p); 00279 } 00280 00293 public: requirements() 00294 { 00295 (void)&requirements<T>::require_nested_typename_coordinate_type; 00296 (void)&requirements<T>::require_numeric_coordinate_type; 00297 (void)&requirements<T>::require_set_x; 00298 (void)&requirements<T>::require_set_y; 00299 (void)&requirements<T>::require_get_x; 00300 (void)&requirements<T>::require_get_y; 00301 } 00302 00303 }; // struct instigate::geometry::concept::point::requirements 00304 00305 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00306 00307 #endif // INSTIGATE_GEOMETRY_CONCEPT_POINT_INTERFACE 00308