Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TSdlReferenceArray.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <string>
7#include <string_view>
8#include <vector>
9#include <memory>
10#include <type_traits>
11
12namespace ph
13{
14
15class ISdlResource;
16
21template<typename T, typename Owner>
23{
24public:
25 TSdlReferenceArray(std::string valueName, std::vector<std::shared_ptr<T>> Owner::* valuePtr);
26
29 void ownedValueToDefault(Owner& owner) const override;
30
31 std::string valueToString(const Owner& owner) const override;
32
33 void ownedResources(
34 const Owner& owner,
35 std::vector<const ISdlResource*>& out_resources) const override;
36
37 SdlNativeData ownedNativeData(Owner& owner) const override;
38
39 void setValueVec(Owner& owner, std::vector<std::shared_ptr<T>> value) const;
40 const std::vector<std::shared_ptr<T>>& getValueVec(const Owner& owner) const;
41
43 TSdlReferenceArray& description(std::string descriptionStr);
47
48 template<typename ResourceType = T>
49 static std::vector<std::shared_ptr<T>> loadReferenceArray(
50 const SdlInputClause& clause,
51 const SdlInputContext& ctx);
52
53protected:
54 void loadFromSdl(
55 Owner& owner,
56 const SdlInputClause& clause,
57 const SdlInputContext& ctx) const override;
58
59 void saveToSdl(
60 const Owner& owner,
61 SdlOutputClause& out_clause,
62 const SdlOutputContext& ctx) const override;
63
64private:
65 std::vector<std::shared_ptr<T>> Owner::* m_valuePtr;
66};
67
68}// end namespace ph
69
Carries SDL representation of various data during the input process. Helps to read input data such as...
Definition SdlInputClause.h:15
Data that SDL input process can rely on.
Definition SdlInputContext.h:19
Definition SdlNativeData.h:88
Carries SDL representation of various data during the output process. Helps to write output data such...
Definition SdlOutputClause.h:14
Data that SDL output process can rely on.
Definition SdlOutputContext.h:19
Abstraction for a value that is owned by some owner type. Governs how a field should be initialized o...
Definition TSdlOwnedField.h:15
A value that points to an array of SDL resources.
Definition TSdlReferenceArray.h:23
static std::vector< std::shared_ptr< T > > loadReferenceArray(const SdlInputClause &clause, const SdlInputContext &ctx)
Definition TSdlReferenceArray.ipp:175
TSdlReferenceArray & description(std::string descriptionStr)
Definition TSdlReferenceArray.ipp:229
SdlNativeData ownedNativeData(Owner &owner) const override
Direct access to the field memory of an owner. Short-lived owner objects such as function parameter s...
Definition TSdlReferenceArray.ipp:70
void ownedValueToDefault(Owner &owner) const override
By default, default value of the array is empty.
Definition TSdlReferenceArray.ipp:41
TSdlReferenceArray & optional()
Definition TSdlReferenceArray.ipp:237
const std::vector< std::shared_ptr< T > > & getValueVec(const Owner &owner) const
Definition TSdlReferenceArray.ipp:107
TSdlReferenceArray(std::string valueName, std::vector< std::shared_ptr< T > > Owner::*valuePtr)
Definition TSdlReferenceArray.ipp:24
void ownedResources(const Owner &owner, std::vector< const ISdlResource * > &out_resources) const override
Get all SDL resources associated by owner.
Definition TSdlReferenceArray.ipp:58
TSdlReferenceArray & niceToHave()
Definition TSdlReferenceArray.ipp:244
std::string valueToString(const Owner &owner) const override
Convert the value of the field to human-readable string.
Definition TSdlReferenceArray.ipp:48
void saveToSdl(const Owner &owner, SdlOutputClause &out_clause, const SdlOutputContext &ctx) const override
Convert actual value back to SDL value. Saving a loaded value as SDL value should rarely fail–as load...
Definition TSdlReferenceArray.ipp:132
void setValueVec(Owner &owner, std::vector< std::shared_ptr< T > > value) const
Definition TSdlReferenceArray.ipp:99
TSdlReferenceArray & withImportance(EFieldImportance importance)
Definition TSdlReferenceArray.ipp:221
TSdlReferenceArray & required()
Definition TSdlReferenceArray.ipp:251
void loadFromSdl(Owner &owner, const SdlInputClause &clause, const SdlInputContext &ctx) const override
Load SDL value to actual value and store it in the owner's field. Implementations are highly encourag...
Definition TSdlReferenceArray.ipp:114
The root for all renderer implementations.
Definition EEngineProject.h:6
EFieldImportance
Definition EFieldImportance.h:7