Imported Upstream version 1.71.0
[platform/upstream/boost.git] / boost / geometry / srs / projections / shared_grids.hpp
1 // Boost.Geometry
2
3 // This file was modified by Oracle on 2018.
4 // Modifications copyright (c) 2018, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_SRS_PROJECTIONS_SHARED_GRIDS_HPP
12 #define BOOST_GEOMETRY_SRS_PROJECTIONS_SHARED_GRIDS_HPP
13
14
15 #include <boost/geometry/srs/projections/impl/pj_gridinfo.hpp>
16
17 #include <boost/thread.hpp>
18
19 #include <vector>
20
21
22 namespace boost { namespace geometry
23 {
24     
25
26 namespace projections { namespace detail
27 {
28
29 // Forward declaration for functions declarations below
30 class shared_grids;
31
32 // Forward declaratios of shared_grids friends
33 template <typename StreamPolicy>
34 inline bool pj_gridlist_merge_gridfile(std::string const& gridname,
35                                        StreamPolicy const& stream_policy,
36                                        shared_grids & grids,
37                                        std::vector<std::size_t> & gridindexes);
38 template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range>
39 inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
40                                  Range & range,
41                                  shared_grids & grids,
42                                  std::vector<std::size_t> const& gridindexes);
43
44
45 class shared_grids
46 {
47 public:
48     std::size_t size() const
49     {
50         boost::shared_lock<boost::shared_mutex> lock(mutex);
51         return gridinfo.size();
52     }
53
54     bool empty() const
55     {
56         boost::shared_lock<boost::shared_mutex> lock(mutex);
57         return gridinfo.empty();
58     }
59
60 private:
61     template <typename StreamPolicy>
62     friend inline bool projections::detail::pj_gridlist_merge_gridfile(
63                             std::string const& gridname,
64                             StreamPolicy const& stream_policy,
65                             shared_grids & grids,
66                             std::vector<std::size_t> & gridindexes);
67     template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range>
68     friend inline bool projections::detail::pj_apply_gridshift_3(
69                             StreamPolicy const& stream_policy,
70                             Range & range,
71                             shared_grids & grids,
72                             std::vector<std::size_t> const& gridindexes);
73
74     projections::detail::pj_gridinfo gridinfo;
75     mutable boost::shared_mutex mutex;
76 };
77
78 }} // namespace projections::detail
79
80
81 }} // namespace boost::geometry
82
83
84 #endif // BOOST_GEOMETRY_SRS_PROJECTIONS_SHARED_GRIDS_HPP