~ubuntu-branches/ubuntu/saucy/merkaartor/saucy

« back to all changes in this revision

Viewing changes to include/builtin-ggl/ggl/geometries/adapted/c_array.hpp

Tags: upstream-0.15.3+svn20934
ImportĀ upstreamĀ versionĀ 0.15.3+svn20934

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Generic Geometry Library
 
2
//
 
3
// Copyright Bruno Lalande 2008, 2009
 
4
// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
 
5
// Use, modification and distribution is subject to the Boost Software License,
 
6
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 
7
// http://www.boost.org/LICENSE_1_0.txt)
 
8
 
 
9
#ifndef GGL_GEOMETRIES_ADAPTED_C_ARRAY_HPP
 
10
#define GGL_GEOMETRIES_ADAPTED_C_ARRAY_HPP
 
11
 
 
12
#include <cstddef>
 
13
 
 
14
#include <boost/type_traits/is_arithmetic.hpp>
 
15
 
 
16
#include <ggl/core/access.hpp>
 
17
#include <ggl/core/cs.hpp>
 
18
#include <ggl/core/coordinate_dimension.hpp>
 
19
#include <ggl/core/coordinate_type.hpp>
 
20
#include <ggl/core/tags.hpp>
 
21
 
 
22
namespace ggl
 
23
{
 
24
 
 
25
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
 
26
namespace traits
 
27
{
 
28
 
 
29
#ifndef DOXYGEN_NO_DETAIL
 
30
namespace detail
 
31
{
 
32
 
 
33
// Create class and specialization to indicate the tag
 
34
// for normal cases and the case that the type of the c-array is arithmetic
 
35
template <bool>
 
36
struct c_array_tag
 
37
{
 
38
    typedef geometry_not_recognized_tag type;
 
39
};
 
40
 
 
41
template <>
 
42
struct c_array_tag<true>
 
43
{
 
44
    typedef point_tag type;
 
45
};
 
46
 
 
47
} // namespace detail
 
48
#endif // DOXYGEN_NO_DETAIL
 
49
 
 
50
// Assign the point-tag, preventing arrays of points getting a point-tag
 
51
template <typename T, std::size_t N>
 
52
struct tag<T[N]> : detail::c_array_tag<boost::is_arithmetic<T>::value> {};
 
53
 
 
54
template <typename T, std::size_t N>
 
55
struct coordinate_type<T[N]>
 
56
{
 
57
    typedef T type;
 
58
};
 
59
 
 
60
template <typename T, std::size_t N>
 
61
struct dimension<T[N]>: boost::mpl::int_<N> {};
 
62
 
 
63
template <typename T, std::size_t N>
 
64
struct access<T[N]>
 
65
{
 
66
    template <std::size_t I>
 
67
    static inline T get(const T p[N])
 
68
    {
 
69
        return p[I];
 
70
    }
 
71
 
 
72
    template <std::size_t I>
 
73
    static inline void set(T p[N], const T& value)
 
74
    {
 
75
        p[I] = value;
 
76
    }
 
77
};
 
78
 
 
79
// The library user has
 
80
// 1) either to specify the coordinate system
 
81
// 2) or include <ggl/geometries/adapted/c_array_@.hpp> where @=cartesian,geographic,...
 
82
 
 
83
} // namespace traits
 
84
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
 
85
 
 
86
} // namespace ggl
 
87
 
 
88
#endif // GGL_GEOMETRIES_ADAPTED_C_ARRAY_HPP