1 #include "package_registry.hpp"
10 std::weak_ptr<package_registry> owner;
14 owner(std::move(owner)),
20 if (
auto strong_owner = owner.lock())
21 strong_owner->unregister_server(*
this);
25 package_registry::package_registry() :
26 _lifetime(std::make_shared<int>())
29 package_registry::~package_registry() noexcept
31 std::unique_lock<std::mutex> ax(_protect);
37 std::unique_lock<std::mutex> ax(_protect);
39 auto ret = _registrations.insert({ std::move(version), std::move(classpath) });
41 throw std::invalid_argument(version +
" is already registered");
43 return std::make_shared<registration_info>(std::shared_ptr<package_registry>(_lifetime,
this), ret.first->first);
48 std::unique_lock<std::mutex> ax(_protect);
49 return _registrations.erase(reg.name) > 0U;
62 std::unique_lock<std::mutex> ax(_protect);
63 return _registrations.size();
68 std::unique_lock<std::mutex> ax(_protect);
69 if (_registrations.empty())
72 return _registrations.rbegin()->second;
size_type size() const
How many registrations have been registered?
optional< std::string > find_newest_classpath() const
Get the classpath for running the newest registered server version.
bool unregister_server(registration reg)
Attempt to unregister the server associated with the provided registration.
registration register_classpath_server(std::string version, std::string classpath)
Register a server that can be created via the specified Java classpath.
Represents a version of the data.