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);
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(packages) });
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;
Represents a collection of JARs or other Java entities that should be provided as the --classpath to ...
size_type size() const
How many registrations have been registered?
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)
package_registry()
Create an empty registry.
Represents a version of the data.