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"
|
2014-12-16 19:57:19 +01:00
|
|
|
#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
|
|
|
|
2012-06-29 18:37:17 +02:00
|
|
|
#include <functional>
|
2012-02-10 00:47:55 +01:00
|
|
|
|
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&)>;
|
2012-06-29 18:37:17 +02:00
|
|
|
|
2011-09-23 16:31:57 +02:00
|
|
|
class RegisterManager : public Singleton<RegisterManager>
|
|
|
|
{
|
|
|
|
public:
|
2014-06-06 01:48:18 +02:00
|
|
|
Register& operator[](StringView reg);
|
|
|
|
Register& operator[](Codepoint c);
|
2012-06-29 18:37:17 +02:00
|
|
|
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
|