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

« back to all changes in this revision

Viewing changes to include/ggl/core/coordinate_type.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
#ifndef GGL_CORE_COORDINATE_TYPE_HPP
 
10
#define GGL_CORE_COORDINATE_TYPE_HPP
 
11
 
 
12
#include <boost/type_traits/remove_const.hpp>
 
13
 
 
14
#include <ggl/core/point_type.hpp>
 
15
 
 
16
namespace ggl {
 
17
 
 
18
namespace traits {
 
19
 
 
20
/*!
 
21
    \brief Traits class which indicate the coordinate type (double,float,...) of a point
 
22
    \ingroup traits
 
23
    \par Geometries:
 
24
        - point
 
25
    \par Specializations should provide:
 
26
        - typedef T type; (double,float,int,etc)
 
27
*/
 
28
template <typename P>
 
29
struct coordinate_type {};
 
30
 
 
31
} // namespace traits
 
32
 
 
33
#ifndef DOXYGEN_NO_DISPATCH
 
34
namespace core_dispatch
 
35
{
 
36
 
 
37
template <typename GeometryTag, typename G>
 
38
struct coordinate_type
 
39
{
 
40
    typedef typename point_type<GeometryTag, G>::type point_type;
 
41
 
 
42
    // Call its own specialization on point-tag
 
43
    typedef typename coordinate_type<point_tag, point_type>::type type;
 
44
};
 
45
 
 
46
template <typename P>
 
47
struct coordinate_type<point_tag, P>
 
48
{
 
49
    typedef typename traits::coordinate_type<P>::type type;
 
50
};
 
51
 
 
52
} // namespace core_dispatch
 
53
#endif // DOXYGEN_NO_DISPATCH
 
54
 
 
55
/*!
 
56
    \brief Meta-function which defines coordinate type (int, float, double, etc) of any geometry
 
57
    \ingroup core
 
58
*/
 
59
template <typename G>
 
60
struct coordinate_type
 
61
{
 
62
    typedef typename boost::remove_const<G>::type ncg;
 
63
    typedef typename core_dispatch::coordinate_type
 
64
        <
 
65
            typename tag<G>::type,
 
66
            ncg
 
67
        >::type type;
 
68
};
 
69
 
 
70
} // namespace ggl
 
71
 
 
72
#endif // GGL_CORE_COORDINATE_TYPE_HPP