PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/test/test_geometries/all_custom_ring.hpp

http://hadesmem.googlecode.com/
C++ Header | 142 lines | 89 code | 37 blank | 16 comment | 0 complexity | 078e990a85359b70f319521ed2642757 MD5 | raw file
  1// Boost.Geometry (aka GGL, Generic Geometry Library) 
  2// Unit Test
  3
  4// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
  5
  6// Use, modification and distribution is subject to the Boost Software License,
  7// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8// http://www.boost.org/LICENSE_1_0.txt)
  9
 10#ifndef GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_RING_HPP
 11#define GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_RING_HPP
 12
 13#include <cstddef>
 14
 15#include <boost/range.hpp>
 16
 17
 18#include <boost/geometry/core/mutable_range.hpp>
 19#include <boost/geometry/core/tag.hpp>
 20#include <boost/geometry/core/tags.hpp>
 21
 22#include <test_geometries/all_custom_container.hpp>
 23
 24
 25template <typename P>
 26class all_custom_ring : public all_custom_container<P>
 27{};
 28
 29
 30// Note that the things below are nearly all identical to implementation
 31// in *linestring, but it seems not possible to re-use this (without macro's)
 32// (the only thing DIFFERENT is the tag)
 33
 34
 35// 1. Adapt to Boost.Geometry
 36namespace boost { namespace geometry
 37{
 38
 39namespace traits
 40{
 41    template <typename Point>
 42    struct tag<all_custom_ring<Point> >
 43    {
 44        typedef ring_tag type;
 45    };
 46
 47
 48    // Implement traits for mutable actions
 49    // These are all optional traits (normally / default they are implemented
 50    // conforming std:: functionality)
 51
 52    template <typename Point>
 53    struct clear<all_custom_ring<Point> >
 54    {
 55        static inline void apply(all_custom_ring<Point>& acr)
 56        {
 57            acr.custom_clear();
 58        }
 59    };
 60
 61    template <typename Point>
 62    struct push_back<all_custom_ring<Point> >
 63    {
 64        static inline void apply(all_custom_ring<Point>& acr, Point const& point)
 65        {
 66            acr.custom_push_back(point);
 67        }
 68    };
 69
 70    template <typename Point>
 71    struct resize<all_custom_ring<Point> >
 72    {
 73        static inline void apply(all_custom_ring<Point>& acr, std::size_t new_size)
 74        {
 75            acr.custom_resize(new_size);
 76        }
 77    };
 78
 79} // namespace traits
 80
 81}} // namespace boost::geometry
 82
 83
 84// 2a. Adapt to Boost.Range, meta-functions
 85namespace boost
 86{
 87    template<typename Point>
 88    struct range_mutable_iterator<all_custom_ring<Point> >
 89    {
 90        typedef typename all_custom_ring<Point>::custom_iterator_type type;
 91    };
 92
 93    template<typename Point>
 94    struct range_const_iterator<all_custom_ring<Point> >
 95    {
 96        typedef typename all_custom_ring<Point>::custom_const_iterator_type  type;
 97    };
 98
 99} // namespace boost
100
101
102// 2b. Adapt to Boost.Range, part 2, ADP
103
104template<typename Point>
105inline typename all_custom_ring<Point>::custom_iterator_type
106    range_begin(all_custom_ring<Point>& acr)
107{
108    return acr.custom_begin();
109}
110
111template<typename Point>
112inline typename all_custom_ring<Point>::custom_const_iterator_type
113    range_begin(all_custom_ring<Point> const& acr)
114{
115    return acr.custom_begin();
116}
117
118template<typename Point>
119inline typename all_custom_ring<Point>::custom_iterator_type
120    range_end(all_custom_ring<Point>& acr)
121{
122    return acr.custom_end();
123}
124
125template<typename Point>
126inline typename all_custom_ring<Point>::custom_const_iterator_type
127    range_end(all_custom_ring<Point> const& acr)
128{
129    return acr.custom_end();
130}
131
132// (Optional)
133template<typename Point>
134inline std::size_t range_calculate_size(all_custom_ring<Point> const& acr)
135{
136    return acr.custom_size();
137}
138
139
140
141
142#endif // GEOMETRY_TEST_TEST_GEOMETRIES_ALL_CUSTOM_RING_HPP