Kagome
Polkadot Runtime Engine in C++17
instance_environment.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_RUNTIME_INSTANCE_ENVIRONMENT_HPP
7 #define KAGOME_CORE_RUNTIME_INSTANCE_ENVIRONMENT_HPP
8 
9 #include <functional>
10 #include <memory>
11 
12 namespace kagome::host_api {
13  class HostApi;
14 }
15 
16 namespace kagome::runtime {
17  class TrieStorageProvider;
18  class MemoryProvider;
19 
21  InstanceEnvironment(const InstanceEnvironment &) = delete;
22  InstanceEnvironment &operator=(const InstanceEnvironment &) = delete;
23 
25  std::shared_ptr<MemoryProvider> memory_provider,
26  std::shared_ptr<TrieStorageProvider> storage_provider,
27  std::shared_ptr<host_api::HostApi> host_api,
28  std::function<void(InstanceEnvironment &)> on_destruction)
29  : memory_provider(std::move(memory_provider)),
30  storage_provider(std::move(storage_provider)),
31  host_api(std::move(host_api)),
32  on_destruction(std::move(on_destruction)) {}
33 
35  : memory_provider(std::move(e.memory_provider)),
36  storage_provider(std::move(e.storage_provider)),
37  host_api(std::move(e.host_api)),
38  on_destruction(std::move(e.on_destruction)) {
39  e.on_destruction = {};
40  }
41  InstanceEnvironment &operator=(InstanceEnvironment &&) = default;
42 
44  if (on_destruction) {
45  on_destruction(*this);
46  }
47  }
48 
49  std::shared_ptr<MemoryProvider> memory_provider;
50  std::shared_ptr<TrieStorageProvider> storage_provider;
51  std::shared_ptr<host_api::HostApi> host_api;
52  std::function<void(InstanceEnvironment &)> on_destruction;
53  };
54 
55 } // namespace kagome::runtime
56 
57 #endif // KAGOME_CORE_RUNTIME_INSTANCE_ENVIRONMENT_HPP
std::function< void(InstanceEnvironment &)> on_destruction
STL namespace.
std::shared_ptr< TrieStorageProvider > storage_provider
InstanceEnvironment(std::shared_ptr< MemoryProvider > memory_provider, std::shared_ptr< TrieStorageProvider > storage_provider, std::shared_ptr< host_api::HostApi > host_api, std::function< void(InstanceEnvironment &)> on_destruction)
std::shared_ptr< MemoryProvider > memory_provider
std::shared_ptr< host_api::HostApi > host_api
InstanceEnvironment(InstanceEnvironment &&e) noexcept