le2d v0.4.7
2D game engine framework
 
Loading...
Searching...
No Matches
scope.hpp
Go to the documentation of this file.
1#pragma once
3#include <vector>
4
5namespace le::tweak {
7class Scope {
8 public:
9 Scope(Scope const&) = delete;
10 auto operator=(Scope const&) -> Scope& = delete;
11
12 Scope(Scope&&) = default;
13 auto operator=(Scope&&) -> Scope& = default;
14
15 explicit Scope(gsl::not_null<IStore*> store) : m_store(store) {}
16
18 for (auto const id : m_ids) { m_store->remove_tweakable(id); }
19 }
20
21 void add_tweakable(std::string_view const id, gsl::not_null<ITweakable*> tweakable) { m_store->add_tweakable(id, tweakable); }
22
23 private:
24 gsl::not_null<IStore*> m_store;
25 std::vector<std::string_view> m_ids{};
26};
27} // namespace le::tweak
RAII wrapper to erase added IDs on destruction.
Definition scope.hpp:7
auto operator=(Scope &&) -> Scope &=default
auto operator=(Scope const &) -> Scope &=delete
~Scope()
Definition scope.hpp:17
Scope(gsl::not_null< IStore * > store)
Definition scope.hpp:15
void add_tweakable(std::string_view const id, gsl::not_null< ITweakable * > tweakable)
Definition scope.hpp:21
Scope(Scope &&)=default
Scope(Scope const &)=delete
Definition parser.hpp:7