Kagome
Polkadot Runtime Engine in C++17
module.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_RUNTIME_MODULE_HPP
7 #define KAGOME_CORE_RUNTIME_MODULE_HPP
8 
9 #include <optional>
10 
11 #include "outcome/outcome.hpp"
13 
14 namespace kagome::runtime {
15 
16  class ModuleInstance;
17 
24  class Module {
25  public:
26  virtual ~Module() = default;
27 
28  virtual outcome::result<std::shared_ptr<ModuleInstance>> instantiate()
29  const = 0;
30  };
31 
38  public:
43  void set(std::shared_ptr<Module> module) {
44  module_ = module;
45  }
46 
51  std::optional<std::shared_ptr<Module>> try_extract() {
52  auto module = module_;
53  module_.reset();
54  return module;
55  }
56 
57  private:
58  std::optional<std::shared_ptr<Module>> module_;
59  };
60 
61 } // namespace kagome::runtime
62 
63 #endif // KAGOME_CORE_RUNTIME_MODULE_HPP
std::optional< std::shared_ptr< Module > > try_extract()
Definition: module.hpp:51
virtual ~Module()=default
std::optional< std::shared_ptr< Module > > module_
Definition: module.hpp:58
virtual outcome::result< std::shared_ptr< ModuleInstance > > instantiate() const =0