PowerToys/src/runner/powertoy_module.h
2021-05-20 15:07:34 +03:00

54 lines
1.1 KiB
C++

#pragma once
#include <interface/powertoy_module_interface.h>
#include <string>
#include <memory>
#include <mutex>
#include <vector>
#include <functional>
#include <common/utils/json.h>
struct PowertoyModuleDeleter
{
void operator()(PowertoyModuleIface* pt_module) const
{
if (pt_module)
{
pt_module->destroy();
}
}
};
struct PowertoyModuleDLLDeleter
{
using pointer = HMODULE;
void operator()(HMODULE handle) const
{
FreeLibrary(handle);
}
};
class PowertoyModule
{
public:
PowertoyModule(PowertoyModuleIface* pt_module, HMODULE handle);
inline PowertoyModuleIface* operator->()
{
return pt_module.get();
}
json::JsonObject json_config() const;
void update_hotkeys();
void UpdateHotkeyEx();
private:
std::unique_ptr<HMODULE, PowertoyModuleDLLDeleter> handle;
std::unique_ptr<PowertoyModuleIface, PowertoyModuleDeleter> pt_module;
};
PowertoyModule load_powertoy(const std::wstring_view filename);
std::map<std::wstring, PowertoyModule>& modules();