zookeeper-cpp
ZooKeeper Client for C++
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
package_registry.hpp
1 #pragma once
2 
3 #include <zk/config.hpp>
4 #include <zk/optional.hpp>
5 
6 #include <cstddef>
7 #include <map>
8 #include <memory>
9 #include <mutex>
10 #include <string>
11 
12 #include "classpath.hpp"
13 
14 namespace zk::server
15 {
16 
19 
25 class package_registry final
26 {
27 public:
28  using size_type = std::size_t;
29 
30  struct registration_info;
31  using registration = std::shared_ptr<registration_info>;
32 
33 public:
36 
37  ~package_registry() noexcept;
38 
46  registration register_classpath_server(std::string version, classpath packages);
47 
54  bool unregister_server(registration reg);
55  bool unregister_server(const registration_info& reg);
57 
59  size_type size() const;
60 
62  bool empty() const
63  {
64  return size() == size_type(0);
65  }
66 
68  optional<classpath> find_newest_classpath() const;
69 
70 private:
71  mutable std::mutex _protect;
72  std::shared_ptr<void> _lifetime;
73  std::map<std::string, classpath> _registrations;
74 };
75 
77 
78 }
Represents a collection of JARs or other Java entities that should be provided as the --classpath to ...
Definition: classpath.hpp:18
size_type size() const
How many registrations have been registered?
Imports of optional and nullopt_t types, as well as the nullopt constexpr.
optional< classpath > find_newest_classpath() const
Get the classpath for running the newest registered server version.
registration register_classpath_server(std::string version, classpath packages)
Register a server that can be created via the specified Java classpath.
bool unregister_server(registration reg)
The package registry tracks configuration of classpaths and JARs needed to run various ZooKeeper vers...
package_registry()
Create an empty registry.
bool empty() const
Is this registry empty?
Represents a version of the data.
Definition: types.hpp:158