blob: 94643ce0f5ffa2aafc3fa88ecbd4e5ae350d952e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#pragma once
#include "Mapper.hpp"
#include <memory>
#include <vector>
namespace cru::ui::mapper {
class CRU_UI_API MapperRegistry {
public:
static MapperRegistry* GetInstance();
MapperRegistry();
CRU_DELETE_COPY(MapperRegistry)
CRU_DELETE_MOVE(MapperRegistry)
~MapperRegistry();
const std::vector<MapperBase*>& GetAllMappers() const { return mapper_list_; }
template <typename T>
BasicMapper<T>* GetMapper() const {
for (auto mapper : mapper_list_) {
if (mapper->GetTypeIndex() == typeid(T)) {
return static_cast<BasicMapper<T>*>(mapper);
}
}
return nullptr;
}
void RegisterMapper(MapperBase* mapper);
void UnregisterMapper(MapperBase* mapper);
private:
std::vector<MapperBase*> mapper_list_;
};
} // namespace cru::ui::mapper
|