diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-02-29 12:10:44 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-02-29 12:10:44 +1100 |
| commit | 7d3ddac0eaea207aee187729e3beec95d8d201dc (patch) | |
| tree | 4b4545e725697663a4768630c48f49e8bbb8cf59 /src/lua/include/lua_registry.hpp | |
| parent | d41f9f703375171d5766840c9edec32ff47bb25d (diff) | |
| parent | 9fca08f8434a05e1fe93a1c4f8133f0e7fc118bf (diff) | |
| download | tangara-fw-7d3ddac0eaea207aee187729e3beec95d8d201dc.tar.gz | |
Merge branch 'main' into seek-support
Diffstat (limited to 'src/lua/include/lua_registry.hpp')
| -rw-r--r-- | src/lua/include/lua_registry.hpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/lua/include/lua_registry.hpp b/src/lua/include/lua_registry.hpp new file mode 100644 index 00000000..abc5063e --- /dev/null +++ b/src/lua/include/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 "bridge.hpp" +#include "lua_thread.hpp" +#include "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 |
