Unravel Engine C++ Reference
Loading...
Searching...
No Matches
asset_watcher.h
Go to the documentation of this file.
1#pragma once
2#include <context/context.hpp>
3#include <filesystem/syncer.h>
4#include <ospp/event.h>
5
6#include <deque>
7#include <mutex>
8
9namespace unravel
10{
12{
13public:
16
17 auto init(rtti::context& ctx) -> bool;
18 auto deinit(rtti::context& ctx) -> bool;
19
20 void watch_assets(rtti::context& ctx, const std::string& protocol, bool wait = false);
21 void unwatch_assets(rtti::context& ctx, const std::string& protocol);
22
23private:
24 void on_os_event(rtti::context& ctx, os::event& e);
25
26 void setup_directory(rtti::context& ctx, fs::syncer& syncer);
27 void setup_meta_syncer(rtti::context& ctx,
28 std::vector<uint64_t>& watchers,
29 fs::syncer& syncer,
30 const fs::path& data_dir,
31 const fs::path& meta_dir,
32 bool wait);
33 void setup_cache_syncer(rtti::context& ctx,
34 std::vector<uint64_t>& watchers,
35 fs::syncer& syncer,
36 const fs::path& meta_dir,
37 const fs::path& cache_dir,
38 bool wait);
39
40 struct watched
41 {
42 fs::syncer meta_syncer;
43 fs::syncer cache_syncer;
44 std::vector<std::uint64_t> watchers;
45 };
46
47 std::map<std::string, watched> watched_protocols_{};
48 std::shared_ptr<int> sentinel_ = std::make_shared<int>(0);
49
50};
51} // namespace unravel
auto deinit(rtti::context &ctx) -> bool
void watch_assets(rtti::context &ctx, const std::string &protocol, bool wait=false)
auto init(rtti::context &ctx) -> bool
void unwatch_assets(rtti::context &ctx, const std::string &protocol)