Prepare steam proxy

This commit is contained in:
momo5502
2019-01-06 23:24:33 +01:00
parent 7b2698561b
commit 83c070f13b
9 changed files with 367 additions and 86 deletions

View File

@ -14,28 +14,46 @@ void module_loader::register_module(std::unique_ptr<module>&& module_)
modules_->push_back(std::move(module_));
}
void module_loader::post_start()
bool module_loader::post_start()
{
static auto handled = false;
if (handled || !modules_) return;
if (handled || !modules_) return true;
handled = true;
for (const auto& module_ : *modules_)
try
{
module_->post_start();
for (const auto& module_ : *modules_)
{
module_->post_start();
}
}
catch(premature_shutdown_trigger&)
{
return false;
}
return true;
}
void module_loader::post_load()
bool module_loader::post_load()
{
static auto handled = false;
if (handled || !modules_) return;
if (handled || !modules_) return true;
handled = true;
for (const auto& module_ : *modules_)
try
{
module_->post_load();
for (const auto& module_ : *modules_)
{
module_->post_load();
}
}
catch (premature_shutdown_trigger&)
{
return false;
}
return true;
}
void module_loader::pre_destroy()
@ -59,3 +77,8 @@ void module_loader::destroy_modules()
delete modules_;
modules_ = nullptr;
}
void module_loader::trigger_premature_shutdown()
{
throw premature_shutdown_trigger();
}

View File

@ -4,6 +4,14 @@
class module_loader final
{
public:
class premature_shutdown_trigger final : public std::exception
{
const char* what() const noexcept override
{
return "Premature shutdown requested";
}
};
template <typename T>
class installer final
{
@ -18,10 +26,12 @@ public:
static void register_module(std::unique_ptr<module>&& module);
static void post_start();
static void post_load();
static bool post_start();
static bool post_load();
static void pre_destroy();
static void trigger_premature_shutdown();
private:
static std::vector<std::unique_ptr<module>>* modules_;