Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TSdlOwnedField.h
Go to the documentation of this file.
1#pragma once
2
4#include "SDL/sdl_fwd.h"
5
6namespace ph
7{
8
13template<typename Owner>
15{
16public:
18 std::string typeName,
19 std::string valueName);
20
22 std::string typeName,
23 std::string valueName,
24 std::string typeSignature);
25
30 virtual void ownedValueToDefault(Owner& owner) const = 0;
31
34 virtual std::string valueToString(const Owner& owner) const = 0;
35
41 virtual void ownedResources(
42 const Owner& owner,
43 std::vector<const ISdlResource*>& out_resources) const = 0;
44
49 virtual SdlNativeData ownedNativeData(Owner& owner) const = 0;
50
51 SdlNativeData nativeData(SdlNonConstInstance instance) const override;
52
57 void fromSdl(
58 Owner& owner,
59 const SdlInputClause& clause,
60 const SdlInputContext& ctx) const;
61
62 void toSdl(
63 const Owner& owner,
64 SdlOutputClause& out_clause,
65 const SdlOutputContext& ctx) const;
66
67protected:
76 virtual void loadFromSdl(
77 Owner& owner,
78 const SdlInputClause& clause,
79 const SdlInputContext& ctx) const = 0;
80
89 virtual void saveToSdl(
90 const Owner& owner,
91 SdlOutputClause& out_clause,
92 const SdlOutputContext& ctx) const = 0;
93
94private:
95 // Nested field need the ability to wrap calls including non-public ones
96 // Note that friend with partial specializations is not supported
97 // in C++17. We resort to making more friend classes than needed.
98 //
99 // The following friend statement is not yet supported:
100 //
101 // template<typename InnerType>
102 // friend class TSdlNestedField<Owner, InnerType>;
103 //
104 // See https://stackoverflow.com/questions/44213761/partial-template-specialization-for-friend-classes
105 //
106 template<typename OuterType, typename InnerType>
107 friend class TSdlNestedField;
108};
109
110}// end namespace ph
111
Definition SdlField.h:19
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
References a SDL object. This is a lightweight utility for referencing SDL objects....
Definition TSdlAnyInstance.h:20
A field that lives within an inner object.
Definition TSdlNestedField.h:25
Abstraction for a value that is owned by some owner type. Governs how a field should be initialized o...
Definition TSdlOwnedField.h:15
void toSdl(const Owner &owner, SdlOutputClause &out_clause, const SdlOutputContext &ctx) const
Definition TSdlOwnedField.ipp:101
virtual std::string valueToString(const Owner &owner) const =0
Convert the value of the field to human-readable string.
virtual void loadFromSdl(Owner &owner, const SdlInputClause &clause, const SdlInputContext &ctx) const =0
Load SDL value to actual value and store it in the owner's field. Implementations are highly encourag...
virtual void saveToSdl(const Owner &owner, SdlOutputClause &out_clause, const SdlOutputContext &ctx) const =0
Convert actual value back to SDL value. Saving a loaded value as SDL value should rarely fail–as load...
virtual void ownedResources(const Owner &owner, std::vector< const ISdlResource * > &out_resources) const =0
Get all SDL resources associated by owner.
virtual SdlNativeData ownedNativeData(Owner &owner) const =0
Direct access to the field memory of an owner. Short-lived owner objects such as function parameter s...
void fromSdl(Owner &owner, const SdlInputClause &clause, const SdlInputContext &ctx) const
Acquire value and store in the owner's field. The loading process will follow a series of preset poli...
Definition TSdlOwnedField.ipp:64
TSdlOwnedField(std::string typeName, std::string valueName)
Definition TSdlOwnedField.ipp:21
SdlNativeData nativeData(SdlNonConstInstance instance) const override
Direct access to the field memory of a SDL instance. Note that this field may not necessarily be boun...
Definition TSdlOwnedField.ipp:43
virtual void ownedValueToDefault(Owner &owner) const =0
Set the value of the field to a default one. Since the field class is templatized by Owner type,...
The root for all renderer implementations.
Definition EEngineProject.h:6