Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / geometry / algorithms / detail / overlay / visit_info.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4
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 BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_VISIT_INFO_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_VISIT_INFO_HPP
11
12
13 namespace boost { namespace geometry
14 {
15
16 #ifndef DOXYGEN_NO_DETAIL
17 namespace detail { namespace overlay
18 {
19
20 class visit_info
21 {
22 private :
23     static const int NONE = 0;
24     static const int STARTED = 1;
25     static const int VISITED = 2;
26     static const int FINISHED = 3;
27     static const int REJECTED = 4;
28
29     int m_visit_code;
30     bool m_rejected;
31
32 public:
33     inline visit_info()
34         : m_visit_code(0)
35         , m_rejected(false)
36     {}
37
38     inline void set_visited() { m_visit_code = VISITED; }
39     inline void set_started() { m_visit_code = STARTED; }
40     inline void set_finished() { m_visit_code = FINISHED; }
41     inline void set_rejected()
42     {
43         m_visit_code = REJECTED;
44         m_rejected = true;
45     }
46
47     inline bool none() const { return m_visit_code == NONE; }
48     inline bool visited() const { return m_visit_code == VISITED; }
49     inline bool started() const { return m_visit_code == STARTED; }
50     inline bool finished() const { return m_visit_code == FINISHED; }
51     inline bool rejected() const { return m_rejected; }
52
53     inline void clear()
54     {
55         if (! rejected())
56         {
57             m_visit_code = NONE;
58         }
59     }
60
61 #ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
62     friend std::ostream& operator<<(std::ostream &os, visit_info const& v)
63     {
64         if (v.m_visit_code != 0)
65         {
66             os << " VIS: " << int(v.m_visit_code);
67         }
68         return os;
69     }
70 #endif
71
72 };
73
74
75 }} // namespace detail::overlay
76 #endif //DOXYGEN_NO_DETAIL
77
78
79 }} // namespace boost::geometry
80
81
82 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_VISIT_INFO_HPP