summaryrefslogtreecommitdiff
path: root/src/tangara/lua/lua_registry.hpp
diff options
context:
space:
mode:
authorcooljqln <cooljqln@noreply.codeberg.org>2024-05-03 04:48:17 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2024-05-03 04:48:17 +0000
commit3ceb8025ee4330c177101ed30ec17dfb0002f41e (patch)
tree58350210f15df7d00d967cac6f30eeceeb031a3c /src/tangara/lua/lua_registry.hpp
parent964da15a0b84f8e5f00e8abac2f7dfda0bf60488 (diff)
parent9fafd797a5504f458b5fcae4a1d28a68da936315 (diff)
downloadtangara-fw-3ceb8025ee4330c177101ed30ec17dfb0002f41e.tar.gz
Merge pull request 'Break dependency cycles with our components by merging co-dependent components together' (#68) from jqln/component-merge into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/68
Diffstat (limited to 'src/tangara/lua/lua_registry.hpp')
-rw-r--r--src/tangara/lua/lua_registry.hpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/tangara/lua/lua_registry.hpp b/src/tangara/lua/lua_registry.hpp
new file mode 100644
index 00000000..e556b6eb
--- /dev/null
+++ b/src/tangara/lua/lua_registry.hpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2023 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+#include "lua.hpp"
+
+#include "lua/bridge.hpp"
+#include "lua/lua_thread.hpp"
+#include "system_fsm/service_locator.hpp"
+
+namespace lua {
+
+class Registry {
+ public:
+ static auto instance(system_fsm::ServiceLocator&) -> Registry&;
+
+ auto uiThread() -> std::shared_ptr<LuaThread>;
+ auto newThread() -> std::shared_ptr<LuaThread>;
+
+ auto AddPropertyModule(
+ const std::string&,
+ std::vector<std::pair<std::string, std::variant<LuaFunction, Property*>>>)
+ -> void;
+
+ Registry(const Registry&) = delete;
+ Registry& operator=(const Registry&) = delete;
+
+ private:
+ Registry(system_fsm::ServiceLocator&);
+
+ system_fsm::ServiceLocator& services_;
+ std::unique_ptr<Bridge> bridge_;
+
+ std::shared_ptr<LuaThread> ui_thread_;
+ std::list<std::weak_ptr<LuaThread>> threads_;
+
+ std::vector<
+ std::pair<std::string,
+ std::vector<std::pair<std::string,
+ std::variant<LuaFunction, Property*>>>>>
+ modules_;
+};
+
+} // namespace lua