Fcitx
addoninstance.cpp
1 /*
2  * SPDX-FileCopyrightText: 2016-2016 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 
8 #include "addoninstance.h"
9 
10 namespace fcitx {
11 
13 public:
14  std::unordered_map<std::string, AddonFunctionAdaptorBase *> callbackMap_;
15 };
16 
17 AddonInstance::AddonInstance()
18  : d_ptr(std::make_unique<AddonInstancePrivate>()) {}
19 AddonInstance::~AddonInstance() = default;
20 
21 void AddonInstance::registerCallback(const std::string &name,
22  AddonFunctionAdaptorBase *adaptor) {
23  FCITX_D();
24  d->callbackMap_[name] = adaptor;
25 }
26 
27 AddonFunctionAdaptorBase *AddonInstance::findCall(const std::string &name) {
28  FCITX_D();
29  auto iter = d->callbackMap_.find(name);
30  if (iter == d->callbackMap_.end()) {
31  throw std::runtime_error(name.c_str());
32  }
33  return iter->second;
34 }
35 } // namespace fcitx
Definition: action.cpp:12
Addon For fcitx.