2012-04-03 14:01:01 +02:00
|
|
|
#ifndef hook_manager_hh_INCLUDED
|
|
|
|
#define hook_manager_hh_INCLUDED
|
2011-11-25 15:26:29 +01:00
|
|
|
|
|
|
|
#include "utils.hh"
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-01-23 14:56:43 +01:00
|
|
|
class Context;
|
2011-11-26 19:34:10 +01:00
|
|
|
typedef std::function<void (const std::string&, const Context&)> HookFunc;
|
2011-11-25 15:26:29 +01:00
|
|
|
|
2012-04-03 14:01:01 +02:00
|
|
|
class HookManager
|
2011-11-25 15:26:29 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
void add_hook(const std::string& hook_name, HookFunc hook);
|
2011-11-26 19:34:10 +01:00
|
|
|
void run_hook(const std::string& hook_name, const std::string& param,
|
|
|
|
const Context& context) const;
|
2011-11-25 15:26:29 +01:00
|
|
|
|
|
|
|
private:
|
2012-04-03 14:01:01 +02:00
|
|
|
std::unordered_map<std::string, std::vector<HookFunc>> m_hook;
|
2011-11-25 15:26:29 +01:00
|
|
|
};
|
|
|
|
|
2012-04-03 14:01:01 +02:00
|
|
|
class GlobalHookManager : public HookManager,
|
|
|
|
public Singleton<GlobalHookManager>
|
2012-01-23 14:40:42 +01:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2011-11-25 15:26:29 +01:00
|
|
|
}
|
|
|
|
|
2012-04-03 14:01:01 +02:00
|
|
|
#endif // hook_manager_hh_INCLUDED
|
2011-11-25 15:26:29 +01:00
|
|
|
|