librime: module.h Source File

| librime 1.2 Rime Input Method Engine, the core library

module.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2013-10-17 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_MODULE_H_
8#define RIME_MODULE_H_
9
10#include <unordered_set>
11#include <rime/common.h>
12
13struct rime_module_t;
14 typedef struct rime_module_t RimeModule;
15
16namespace rime {
17
18 class ModuleManager {
19 public:
20 // module is supposed to be a pointer to static variable
21 void Register(const string& name, RimeModule* module);
22 RimeModule* Find(const string& name);
23
24 void LoadModule(RimeModule* module);
25 void UnloadModules();
26
27 static ModuleManager& instance();
28
29 private:
30 ModuleManager() {}
31
32 // module registry
33 using ModuleMap = map<string, RimeModule*>;
34 ModuleMap map_;
35 // set of loaded modules
36 std::unordered_set<RimeModule*> loaded_;
37};
38
39} // namespace rime
40
41#endif // RIME_MODULE_H_
common.h
RimeModule
struct rime_module_t RimeModule
Definition module.h:14
rime
Definition algebra.cc:12
rime::ModuleManager::LoadModule
void LoadModule(RimeModule *module)
Definition module.cc:25
rime::ModuleManager::UnloadModules
void UnloadModules()
Definition module.cc:39
rime::ModuleManager::Register
void Register(const string &name, RimeModule *module)
Definition module.cc:13
rime::ModuleManager::Find
RimeModule * Find(const string &name)
Definition module.cc:17
rime::ModuleManager::instance
static ModuleManager & instance()
Definition module.cc:48
rime_module_t
Definition rime_api.h:244