home/src/hooks_manager.hh

34 lines
691 B
C++
Raw Normal View History

2011-11-25 15:26:29 +01:00
#ifndef hooks_manager_hh_INCLUDED
#define hooks_manager_hh_INCLUDED
#include "context.hh"
2011-11-25 15:26:29 +01:00
#include "utils.hh"
#include <unordered_map>
namespace Kakoune
{
typedef std::function<void (const std::string&, const Context&)> HookFunc;
2011-11-25 15:26:29 +01:00
class HooksManager
2011-11-25 15:26:29 +01:00
{
public:
void add_hook(const std::string& hook_name, HookFunc hook);
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:
std::unordered_map<std::string, std::vector<HookFunc>> m_hooks;
};
class GlobalHooksManager : public HooksManager,
public Singleton<GlobalHooksManager>
{
};
2011-11-25 15:26:29 +01:00
}
#endif // hooks_manager_hh_INCLUDED