shared_grids.hpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. namespace projections { namespace detail
  16. {
  17. // Forward declaration for functions declarations below
  18. class shared_grids;
  19. // Forward declaratios of shared_grids friends
  20. template <typename StreamPolicy>
  21. inline bool pj_gridlist_merge_gridfile(std::string const& gridname,
  22. StreamPolicy const& stream_policy,
  23. shared_grids & grids,
  24. std::vector<std::size_t> & gridindexes);
  25. template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range>
  26. inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
  27. Range & range,
  28. shared_grids & grids,
  29. std::vector<std::size_t> const& gridindexes);
  30. class shared_grids
  31. {
  32. public:
  33. std::size_t size() const
  34. {
  35. boost::shared_lock<boost::shared_mutex> lock(mutex);
  36. return gridinfo.size();
  37. }
  38. bool empty() const
  39. {
  40. boost::shared_lock<boost::shared_mutex> lock(mutex);
  41. return gridinfo.empty();
  42. }
  43. private:
  44. template <typename StreamPolicy>
  45. friend inline bool projections::detail::pj_gridlist_merge_gridfile(
  46. std::string const& gridname,
  47. StreamPolicy const& stream_policy,
  48. shared_grids & grids,
  49. std::vector<std::size_t> & gridindexes);
  50. template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range>
  51. friend inline bool projections::detail::pj_apply_gridshift_3(
  52. StreamPolicy const& stream_policy,
  53. Range & range,
  54. shared_grids & grids,
  55. std::vector<std::size_t> const& gridindexes);
  56. projections::detail::pj_gridinfo gridinfo;
  57. mutable boost::shared_mutex mutex;
  58. };
  59. }} // namespace projections::detail
  60. }} // namespace boost::geometry
  61. #endif // BOOST_GEOMETRY_SRS_PROJECTIONS_SHARED_GRIDS_HPP