kakoune/src/register_manager.hh

42 lines
916 B
C++
Raw Normal View History

2011-09-23 16:31:57 +02:00
#ifndef register_manager_hh_INCLUDED
#define register_manager_hh_INCLUDED
2015-04-23 22:51:48 +02:00
#include "array_view.hh"
2011-09-23 16:31:57 +02:00
#include "utils.hh"
#include "unordered_map.hh"
2015-04-23 22:51:48 +02:00
#include "string.hh"
2015-01-12 14:58:41 +01:00
#include "vector.hh"
2011-09-23 16:31:57 +02:00
#include <functional>
2011-09-23 16:31:57 +02:00
namespace Kakoune
{
2015-04-23 22:51:48 +02:00
class Context;
class Register
{
public:
virtual ~Register() {}
virtual Register& operator=(ConstArrayView<String> values) = 0;
virtual ConstArrayView<String> values(const Context& context) = 0;
};
2015-01-14 20:16:32 +01:00
using RegisterRetriever = std::function<Vector<String, MemoryDomain::Registers> (const Context&)>;
2011-09-23 16:31:57 +02:00
class RegisterManager : public Singleton<RegisterManager>
{
public:
Register& operator[](StringView reg);
Register& operator[](Codepoint c);
void register_dynamic_register(char reg, RegisterRetriever function);
2011-09-23 16:31:57 +02:00
protected:
2015-01-14 20:16:32 +01:00
UnorderedMap<char, std::unique_ptr<Register>, MemoryDomain::Registers> m_registers;
2011-09-23 16:31:57 +02:00
};
}
#endif // register_manager_hh_INCLUDED