2011-11-25 18:26:29 +04:00
|
|
|
#ifndef hooks_manager_hh_INCLUDED
|
|
|
|
#define hooks_manager_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "utils.hh"
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-01-23 17:56:43 +04:00
|
|
|
class Context;
|
2011-11-26 22:34:10 +04:00
|
|
|
typedef std::function<void (const std::string&, const Context&)> HookFunc;
|
2011-11-25 18:26:29 +04:00
|
|
|
|
2012-01-23 17:40:42 +04:00
|
|
|
class HooksManager
|
2011-11-25 18:26:29 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
void add_hook(const std::string& hook_name, HookFunc hook);
|
2011-11-26 22:34:10 +04:00
|
|
|
void run_hook(const std::string& hook_name, const std::string& param,
|
|
|
|
const Context& context) const;
|
2011-11-25 18:26:29 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::unordered_map<std::string, std::vector<HookFunc>> m_hooks;
|
|
|
|
};
|
|
|
|
|
2012-01-23 17:40:42 +04:00
|
|
|
class GlobalHooksManager : public HooksManager,
|
|
|
|
public Singleton<GlobalHooksManager>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2011-11-25 18:26:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // hooks_manager_hh_INCLUDED
|
|
|
|
|