Pioneer
PropertyMap.h
Go to the documentation of this file.
1// Copyright © 2008-2022 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#ifndef PROPERTYMAP_H
5#define PROPERTYMAP_H
6
7#include "LuaManager.h"
8#include "LuaRef.h"
9#include "LuaTable.h"
10
12public:
14
15 template <class Value>
16 void Set(const std::string &k, const Value &v)
17 {
18 ScopedTable(m_table).Set(k, v);
19 SendSignal(k);
20 }
21
22 template <class Value>
23 void Get(const std::string &k, Value &v) const
24 {
25 v = ScopedTable(m_table).Get<Value>(k, v);
26 }
27
28 void PushLuaTable();
29
30 sigc::connection Connect(const std::string &k, const sigc::slot<void, PropertyMap &, const std::string &> &fn)
31 {
32 return m_signals[k].connect(fn);
33 }
34
35 void SaveToJson(Json &jsonObj);
36 void LoadFromJson(const Json &jsonObj);
37
38private:
39 LuaRef m_table;
40
41 void SendSignal(const std::string &k);
42 std::map<std::string, sigc::signal<void, PropertyMap &, const std::string &>> m_signals;
43};
44
45#endif
nlohmann::json Json
Definition: Json.h:8
Definition: LuaManager.h:9
Definition: LuaRef.h:12
Value Get(const Key &key) const
Definition: LuaTable.h:326
LuaTable Set(const Key &key, const Value &value) const
Definition: LuaTable.h:346
Definition: PropertyMap.h:11
void Set(const std::string &k, const Value &v)
Definition: PropertyMap.h:16
void SaveToJson(Json &jsonObj)
Definition: PropertyMap.cpp:32
void PushLuaTable()
Definition: PropertyMap.cpp:27
void LoadFromJson(const Json &jsonObj)
Definition: PropertyMap.cpp:37
void Get(const std::string &k, Value &v) const
Definition: PropertyMap.h:23
PropertyMap(LuaManager *lua)
Definition: PropertyMap.cpp:8
sigc::connection Connect(const std::string &k, const sigc::slot< void, PropertyMap &, const std::string & > &fn)
Definition: PropertyMap.h:30
Definition: LuaTable.h:284
IMGUI_API void Value(const char *prefix, const std::string &str)
Definition: PerfInfo.cpp:181