2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-02-02 04:29:58 +00:00
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
#include "hecl/Database.hpp"
|
2016-02-02 04:29:58 +00:00
|
|
|
#include "Space.hpp"
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-02-02 04:29:58 +00:00
|
|
|
|
|
|
|
/** Combines a ProjectPath with actively used Space references
|
|
|
|
*
|
|
|
|
* This class is intended to be heap-allocated in a hierarchical mapping, so the entire tree
|
|
|
|
* of resources is available in-memory to systems that need it. Refreshes of the index will
|
|
|
|
* continue to use existing allocations that haven't been deleted.
|
|
|
|
*
|
|
|
|
* The key purpose of this class is to centrally register observer-nodes for resources that
|
|
|
|
* are updated via editing, or external file changes.
|
|
|
|
*/
|
2018-12-08 05:30:43 +00:00
|
|
|
class Resource {
|
2016-02-02 04:29:58 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
using ProjectDataSpec = hecl::Database::Project::ProjectDataSpec;
|
|
|
|
|
2016-02-02 04:29:58 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::ProjectPath m_path;
|
|
|
|
Space::Class m_defaultClass = Space::Class::None;
|
|
|
|
// EditorSpace* m_editingSpace = nullptr;
|
|
|
|
std::vector<ViewerSpace*> m_viewingSpaces;
|
|
|
|
|
2016-02-02 04:29:58 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
static Space::Class DeduceDefaultSpaceClass(const hecl::ProjectPath& path);
|
|
|
|
explicit Resource(hecl::ProjectPath&& path)
|
|
|
|
: m_path(std::move(path)), m_defaultClass(DeduceDefaultSpaceClass(m_path)) {}
|
|
|
|
const hecl::ProjectPath& path() const { return m_path; }
|
2016-02-02 04:29:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Provides centralized hierarchical lookup and ownership of Resource nodes */
|
2018-12-08 05:30:43 +00:00
|
|
|
class ResourceTree {
|
2016-02-02 04:29:58 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
struct Node {
|
|
|
|
std::map<hecl::ProjectPath, std::unique_ptr<Node>> m_subnodes;
|
|
|
|
std::map<hecl::ProjectPath, std::unique_ptr<Resource>> m_resources;
|
|
|
|
};
|
|
|
|
|
2016-02-02 04:29:58 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<Node> m_rootNode;
|
2016-02-02 04:29:58 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|