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

« back to all changes in this revision

Viewing changes to include/ggl/core/concepts/box_concept.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2009-09-13 00:52:12 UTC
  • mto: (1.2.7 upstream) (0.1.3 upstream) (3.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090913005212-pjecal8zxm07x0fj
ImportĀ upstreamĀ versionĀ 0.14+svnfixes~20090912

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
 
 
10
#ifndef GGL_CORE_CONCEPTS_BOX_CONCEPT_HPP
 
11
#define GGL_CORE_CONCEPTS_BOX_CONCEPT_HPP
 
12
 
 
13
 
 
14
#include <boost/concept_check.hpp>
 
15
 
 
16
 
 
17
#include <ggl/core/access.hpp>
 
18
#include <ggl/core/point_type.hpp>
 
19
 
 
20
 
 
21
 
 
22
namespace ggl { namespace concept {
 
23
 
 
24
 
 
25
/*!
 
26
    \brief Checks box concept, using Boost Concept Check Library and metafunctions
 
27
    \ingroup concepts
 
28
*/
 
29
template <typename B>
 
30
struct Box
 
31
{
 
32
    private :
 
33
        typedef typename point_type<B>::type P;
 
34
 
 
35
        /// Internal structure to check if access is OK for all dimensions
 
36
        template <size_t C, size_t D, size_t N>
 
37
        struct dimension_checker
 
38
        {
 
39
            static void check()
 
40
            {
 
41
                B* b;
 
42
                ggl::set<C, D>(*b, ggl::get<C, D>(*b));
 
43
                dimension_checker<C, D + 1, N>::check();
 
44
            }
 
45
        };
 
46
 
 
47
        template <size_t C, size_t N>
 
48
        struct dimension_checker<C, N, N>
 
49
        {
 
50
            static void check() {}
 
51
        };
 
52
 
 
53
    public :
 
54
        /// BCCL macro to check the Box concept
 
55
        BOOST_CONCEPT_USAGE(Box)
 
56
        {
 
57
            static const size_t N = dimension<B>::value;
 
58
            dimension_checker<min_corner, 0, N>::check();
 
59
            dimension_checker<max_corner, 0, N>::check();
 
60
        }
 
61
};
 
62
 
 
63
 
 
64
/*!
 
65
    \brief Checks Box concept (const version)
 
66
    \ingroup concepts
 
67
    \details The ConstBox concept check the same as the Box concept,
 
68
    but does not check write access.
 
69
*/
 
70
template <typename B>
 
71
struct ConstBox
 
72
{
 
73
    private :
 
74
        typedef typename point_type<B>::type P;
 
75
        typedef typename coordinate_type<B>::type T;
 
76
 
 
77
        /// Internal structure to check if access is OK for all dimensions
 
78
        template <size_t C, size_t D, size_t N>
 
79
        struct dimension_checker
 
80
        {
 
81
            static void check()
 
82
            {
 
83
                const B* b = 0;
 
84
                T coord(ggl::get<C, D>(*b));
 
85
                boost::ignore_unused_variable_warning(coord);
 
86
                dimension_checker<C, D + 1, N>::check();
 
87
            }
 
88
        };
 
89
 
 
90
        template <size_t C, size_t N>
 
91
        struct dimension_checker<C, N, N>
 
92
        {
 
93
            static void check() {}
 
94
        };
 
95
 
 
96
    public :
 
97
        /// BCCL macro to check the ConstBox concept
 
98
        BOOST_CONCEPT_USAGE(ConstBox)
 
99
        {
 
100
            static const size_t N = dimension<B>::value;
 
101
            dimension_checker<min_corner, 0, N>::check();
 
102
            dimension_checker<max_corner, 0, N>::check();
 
103
        }
 
104
};
 
105
 
 
106
}} // namespace ggl::concept
 
107
 
 
108
 
 
109
#endif // GGL_CORE_CONCEPTS_BOX_CONCEPT_HPP