Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ResourceIdentifier.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <Common/Utility/string_utils.h>
6
7#include <string>
8#include <variant>
9
10namespace ph
11{
12
13class IResourceIdentifierResolver;
14
20{
21public:
25
28 explicit ResourceIdentifier(std::string identifier);
29
33
36 bool isResolved() const;
37
43 bool hasIdentifier() const;
44
45 const std::string& getIdentifier() const;
46 Path getPath() const;
47 std::string getString() const;
48
53 void setPath(Path path);
54
58 bool isEmpty() const;
59
60 std::string toString() const;
61
62private:
64
65 void setResolved(Path resolved);
66 void setResolved(std::string resolved);
67 void clearResolved();
68
69 using ResolvedIdentifier = std::variant<
70 std::monostate,
71 Path,
72 std::string>;
73
74 std::string m_identifier;
75 ResolvedIdentifier m_resolvedIdentifier;
76};
77
78}// end namespace ph
79
PH_DEFINE_INLINE_TO_STRING_FORMATTER(ph::ResourceIdentifier)
Definition IResourceIdentifierResolver.h:12
General path representation. Does not check whether the target actually exists (e....
Definition Path.h:21
An general identifier that points to some resource. This is the most general form of a resource ident...
Definition ResourceIdentifier.h:20
const std::string & getIdentifier() const
Definition ResourceIdentifier.cpp:55
std::string getString() const
Definition ResourceIdentifier.cpp:67
Path getPath() const
Definition ResourceIdentifier.cpp:60
std::string toString() const
Definition ResourceIdentifier.cpp:79
bool resolve(IResourceIdentifierResolver &resolver)
Work out the resource the identifier points to.
Definition ResourceIdentifier.cpp:19
void setPath(Path path)
Directly set a path to resource. This will also clear any existing identifier as we cannot automatica...
Definition ResourceIdentifier.cpp:24
ResourceIdentifier()
Creates empty identifier that refers to nothing.
Definition ResourceIdentifier.cpp:10
bool isEmpty() const
Whether any information is contained.
Definition ResourceIdentifier.cpp:74
bool isResolved() const
Whether the target resource is identified.
Definition ResourceIdentifier.cpp:45
bool hasIdentifier() const
Whether there is an identifier. An identifier may not exist in the following situations:
Definition ResourceIdentifier.cpp:50
The root for all renderer implementations.
Definition EEngineProject.h:6