mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-09-07 09:07:25 +00:00
major cleanup
This commit is contained in:
@@ -6,22 +6,17 @@ void component_loader::register_component(std::unique_ptr<component_interface>&&
|
||||
get_components().push_back(std::move(component_));
|
||||
}
|
||||
|
||||
|
||||
bool component_loader::post_start()
|
||||
{
|
||||
static auto handled = false;
|
||||
|
||||
if (handled) return true;
|
||||
handled = true;
|
||||
|
||||
try
|
||||
for (const auto& component_ : get_components())
|
||||
{
|
||||
for (const auto& component_ : get_components())
|
||||
{
|
||||
component_->post_start();
|
||||
}
|
||||
}
|
||||
catch (premature_shutdown_trigger&)
|
||||
{
|
||||
return false;
|
||||
component_->post_start();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -35,16 +30,9 @@ bool component_loader::post_load()
|
||||
|
||||
clean();
|
||||
|
||||
try
|
||||
for (const auto& component_ : get_components())
|
||||
{
|
||||
for (const auto& component_ : get_components())
|
||||
{
|
||||
component_->post_load();
|
||||
}
|
||||
}
|
||||
catch (premature_shutdown_trigger&)
|
||||
{
|
||||
return false;
|
||||
component_->post_load();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -107,11 +95,6 @@ void* component_loader::load_import(const std::string& library, const std::strin
|
||||
return function_ptr;
|
||||
}
|
||||
|
||||
void component_loader::trigger_premature_shutdown()
|
||||
{
|
||||
throw premature_shutdown_trigger();
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<component_interface>>& component_loader::get_components()
|
||||
{
|
||||
using component_vector = std::vector<std::unique_ptr<component_interface>>;
|
||||
|
@@ -4,14 +4,6 @@
|
||||
class component_loader final
|
||||
{
|
||||
public:
|
||||
class premature_shutdown_trigger final : public std::exception
|
||||
{
|
||||
[[nodiscard]] const char* what() const noexcept override
|
||||
{
|
||||
return "Premature shutdown requested";
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class installer final
|
||||
{
|
||||
@@ -48,8 +40,6 @@ public:
|
||||
|
||||
static void* load_import(const std::string& library, const std::string& function);
|
||||
|
||||
static void trigger_premature_shutdown();
|
||||
|
||||
private:
|
||||
static std::vector<std::unique_ptr<component_interface>>& get_components();
|
||||
};
|
||||
|
Reference in New Issue
Block a user