shared_grids.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Boost.Geometry
  2. // This file was modified by Oracle on 2018.
  3. // Modifications copyright (c) 2018, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  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. #ifndef BOOST_GEOMETRY_SRS_PROJECTIONS_SHARED_GRIDS_HPP
  9. #define BOOST_GEOMETRY_SRS_PROJECTIONS_SHARED_GRIDS_HPP
  10. #include <boost/geometry/srs/projections/impl/pj_gridinfo.hpp>
  11. #include <boost/thread.hpp>
  12. #include <vector>
  13. namespace boost { namespace geometry
  14. {
  15. // Forward declarations
  16. namespace srs
  17. {
  18. // Forward declaration for functions declarations below
  19. class shared_grids;
  20. } // namespace srs
  21. namespace projections { namespace detail
  22. {
  23. // Forward declaratios of shared_grids friends
  24. template <typename StreamPolicy>
  25. inline bool pj_gridlist_merge_gridfile(std::string const& gridname,
  26. StreamPolicy const& stream_policy,
  27. srs::shared_grids & grids,
  28. std::vector<std::size_t> & gridindexes);
  29. template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range>
  30. inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
  31. Range & range,
  32. srs::shared_grids & grids,
  33. std::vector<std::size_t> const& gridindexes);
  34. }} // namespace projections::detail
  35. namespace srs
  36. {
  37. class shared_grids
  38. {
  39. public:
  40. std::size_t size() const
  41. {
  42. boost::shared_lock<boost::shared_mutex> lock(mutex);
  43. return gridinfo.size();
  44. }
  45. bool empty() const
  46. {
  47. boost::shared_lock<boost::shared_mutex> lock(mutex);
  48. return gridinfo.empty();
  49. }
  50. private:
  51. template <typename StreamPolicy>
  52. friend inline bool projections::detail::pj_gridlist_merge_gridfile(
  53. std::string const& gridname,
  54. StreamPolicy const& stream_policy,
  55. srs::shared_grids & grids,
  56. std::vector<std::size_t> & gridindexes);
  57. template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range>
  58. friend inline bool projections::detail::pj_apply_gridshift_3(
  59. StreamPolicy const& stream_policy,
  60. Range & range,
  61. srs::shared_grids & grids,
  62. std::vector<std::size_t> const& gridindexes);
  63. projections::detail::pj_gridinfo gridinfo;
  64. mutable boost::shared_mutex mutex;
  65. };
  66. } // namespace srs
  67. }} // namespace boost::geometry
  68. #endif // BOOST_GEOMETRY_SRS_PROJECTIONS_SHARED_GRIDS_HPP