estimated_document_count.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright 2018-present MongoDB Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <chrono>
  16. #include <bsoncxx/stdx/optional.hpp>
  17. #include <mongocxx/read_preference.hpp>
  18. #include <mongocxx/config/prelude.hpp>
  19. namespace mongocxx {
  20. MONGOCXX_INLINE_NAMESPACE_BEGIN
  21. namespace options {
  22. ///
  23. /// Class representing the optional arguments to mongocxx::collection::estimated_document_count
  24. ///
  25. class MONGOCXX_API estimated_document_count {
  26. public:
  27. ///
  28. /// Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
  29. ///
  30. /// @param max_time
  31. /// The max amount of time (in milliseconds).
  32. ///
  33. /// @return
  34. /// A reference to the object on which this member function is being called. This facilitates
  35. /// method chaining.
  36. ///
  37. /// @see https://docs.mongodb.com/master/reference/command/count/
  38. ///
  39. estimated_document_count& max_time(std::chrono::milliseconds max_time);
  40. ///
  41. /// The current max_time setting.
  42. ///
  43. /// @return The current max time (in milliseconds).
  44. ///
  45. /// @see https://docs.mongodb.com/master/reference/command/count/
  46. ///
  47. const bsoncxx::stdx::optional<std::chrono::milliseconds>& max_time() const;
  48. ///
  49. /// Sets the read_preference for this operation.
  50. ///
  51. /// @param rp
  52. /// The new read_preference.
  53. ///
  54. /// @return
  55. /// A reference to the object on which this member function is being called. This facilitates
  56. /// method chaining.
  57. ///
  58. /// @see https://docs.mongodb.com/master/reference/command/count/
  59. ///
  60. estimated_document_count& read_preference(class read_preference rp);
  61. ///
  62. /// The current read_preference for this operation.
  63. ///
  64. /// @return the current read_preference
  65. ///
  66. /// @see https://docs.mongodb.com/master/reference/command/count/
  67. ///
  68. const bsoncxx::stdx::optional<class read_preference>& read_preference() const;
  69. private:
  70. bsoncxx::stdx::optional<std::chrono::milliseconds> _max_time;
  71. bsoncxx::stdx::optional<class read_preference> _read_preference;
  72. };
  73. } // namespace options
  74. MONGOCXX_INLINE_NAMESPACE_END
  75. } // namespace mongocxx
  76. #include <mongocxx/config/postlude.hpp>