2011-09-08 02:11:48 +02:00
|
|
|
#ifndef buffer_manager_hh_INCLUDED
|
|
|
|
#define buffer_manager_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "buffer.hh"
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class BufferManager
|
|
|
|
{
|
|
|
|
public:
|
2011-09-22 20:55:23 +02:00
|
|
|
typedef std::unordered_map<std::string, std::unique_ptr<Buffer>> BufferMap;
|
|
|
|
|
|
|
|
struct iterator : public BufferMap::const_iterator
|
|
|
|
{
|
|
|
|
typedef BufferMap::const_iterator parent_type;
|
|
|
|
|
|
|
|
iterator() {}
|
|
|
|
iterator(const parent_type& other) : parent_type(other) {}
|
|
|
|
Buffer& operator*() const { return *(parent_type::operator*().second); }
|
|
|
|
Buffer* operator->() const { return parent_type::operator*().second.get(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
iterator begin() const { return iterator(m_buffers.begin()); }
|
|
|
|
iterator end() const { return iterator(m_buffers.end()); }
|
|
|
|
|
2011-09-08 02:11:48 +02:00
|
|
|
void register_buffer(Buffer* buffer);
|
|
|
|
void delete_buffer(Buffer* buffer);
|
|
|
|
|
|
|
|
Buffer* get_buffer(const std::string& name);
|
|
|
|
|
|
|
|
static BufferManager& instance();
|
|
|
|
static void delete_instance();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BufferManager();
|
|
|
|
static BufferManager* ms_instance;
|
2011-09-22 20:55:23 +02:00
|
|
|
BufferMap m_buffers;
|
2011-09-08 02:11:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // buffer_manager_hh_INCLUDED
|