PageRenderTime 26ms CodeModel.GetById 12ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/libs/geometry/test/test_common/with_pointer.hpp

https://github.com/delalond/boost_1_54_0-bgq
C++ Header | 87 lines | 49 code | 27 blank | 11 comment | 0 complexity | 6a90c9ed410993e02d430aa336a430fc MD5 | raw file
 1// Boost.Geometry (aka GGL, Generic Geometry Library) 
 2// Unit Test
 3
 4// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
 5// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
 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
11#ifndef GEOMETRY_TEST_COMMON_WITH_POINTER_HPP
12#define GEOMETRY_TEST_COMMON_WITH_POINTER_HPP
13
14
15#include <boost/geometry/core/access.hpp>
16#include <boost/geometry/core/coordinate_type.hpp>
17#include <boost/geometry/core/coordinate_system.hpp>
18#include <boost/geometry/core/coordinate_dimension.hpp>
19#include <boost/geometry/core/cs.hpp>
20#include <boost/geometry/core/tag.hpp>
21
22// NOTE: since Boost 1.51 the Point type may always be a pointer.
23// Therefore the traits class don't need to add a pointer.
24// This obsoletes this whole test-point-type
25
26
27
28namespace test
29{
30
31// Sample point, having x/y
32struct test_point_xy
33{
34    float x,y;
35};
36
37}
38
39
40namespace boost { namespace geometry { namespace traits {
41
42template<> struct tag<test::test_point_xy>
43{ typedef point_tag type; };
44
45template<> struct coordinate_type<test::test_point_xy>
46{ typedef double type; };
47
48template<> struct coordinate_system<test::test_point_xy>
49{ typedef cs::cartesian type; };
50
51template<> struct dimension<test::test_point_xy> : boost::mpl::int_<2> {};
52
53template<>
54struct access<test::test_point_xy, 0>
55{
56    static double get(test::test_point_xy const& p)
57    {
58        return p.x;
59    }
60
61    static void set(test::test_point_xy& p, double const& value)
62    {
63        p.x = value;
64    }
65
66};
67
68
69template<>
70struct access<test::test_point_xy, 1>
71{
72    static double get(test::test_point_xy const& p)
73    {
74        return p.y;
75    }
76
77    static void set(test::test_point_xy& p, double const& value)
78    {
79        p.y = value;
80    }
81
82};
83
84}}} // namespace bg::traits
85
86
87#endif // #ifndef GEOMETRY_TEST_COMMON_WITH_POINTER_HPP