C++ Client-Side SDK
LaunchDarkly SDK
context_index.hpp
1 #pragma once
2 
3 #include <chrono>
4 #include <mutex>
5 #include <string>
6 #include <vector>
7 
8 #include <boost/json.hpp>
9 
10 namespace launchdarkly::client_side::flag_manager {
11 
24 class ContextIndex {
25  public:
29  struct IndexEntry {
30  IndexEntry() = default;
31  IndexEntry(
32  std::string id,
33  std::chrono::time_point<std::chrono::system_clock> timestamp);
34  std::string id;
35  std::chrono::time_point<std::chrono::system_clock> timestamp;
36  };
37 
38  using Index = std::vector<IndexEntry>;
39  ContextIndex() = default;
40  explicit ContextIndex(Index);
41 
50  void Notice(std::string id,
51  std::chrono::time_point<std::chrono::system_clock> timestamp);
52 
53  [[nodiscard]] Index const& Entries() const;
54 
61  std::vector<std::string> Prune(std::size_t maxContexts);
62 
63  private:
64  Index index_;
65 };
66 
67 void tag_invoke(boost::json::value_from_tag const& unused,
68  boost::json::value& json_value,
69  ContextIndex const& index);
70 
71 ContextIndex tag_invoke(boost::json::value_to_tag<ContextIndex> const& unused,
72  boost::json::value const& json_value);
73 } // namespace launchdarkly::client_side::flag_manager
void Notice(std::string id, std::chrono::time_point< std::chrono::system_clock > timestamp)
Definition: context_index.cpp:14
std::vector< std::string > Prune(std::size_t maxContexts)
Definition: context_index.cpp:26