Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TSdlOptionalValue.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <Common/assertion.h>
6
7#include <string_view>
8#include <optional>
9
10namespace ph
11{
12
20template<typename T, typename Owner>
21class TSdlOptionalValue : public TSdlAbstractValue<T, Owner>
22{
23public:
25 std::string typeName,
26 std::string valueName,
27 std::optional<T> Owner::* valuePtr);
28
30 std::string typeName,
31 std::string valueName,
32 std::string typeSignature,
33 std::optional<T> Owner::* valuePtr);
34
35 std::string valueAsString(const T& value) const override = 0;
36 SdlNativeData ownedNativeData(Owner& owner) const override = 0;
37
38 void setValue(Owner& owner, T value) const override;
39 T* getValue(Owner& owner) const override;
40 const T* getConstValue(const Owner& owner) const override;
41 void ownedValueToDefault(Owner& owner) const override;
42
43 TSdlOptionalValue& description(std::string descriptionStr);
44
45protected:
47 Owner& owner,
48 const SdlInputClause& clause,
49 const SdlInputContext& ctx) const override = 0;
50
52 const Owner& owner,
53 SdlOutputClause& out_clause,
54 const SdlOutputContext& ctx) const override = 0;
55
56 std::optional<T>& valueRef(Owner& owner) const;
57
58private:
59 std::optional<T> Owner::* m_valuePtr;
60};
61
62}// end namespace ph
63
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
General concept of a SDL value type.
Definition TSdlAbstractValue.h:17
Abstractions for a SDL value type that can be empty.
Definition TSdlOptionalValue.h:22
SdlNativeData ownedNativeData(Owner &owner) const override=0
Direct access to the field memory of an owner. Short-lived owner objects such as function parameter s...
TSdlOptionalValue(std::string typeName, std::string valueName, std::optional< T > Owner::*valuePtr)
Definition TSdlOptionalValue.ipp:11
void ownedValueToDefault(Owner &owner) const override
Set the value of the field to a default one. Since the field class is templatized by Owner type,...
Definition TSdlOptionalValue.ipp:67
std::optional< T > & valueRef(Owner &owner) const
Definition TSdlOptionalValue.ipp:73
void saveToSdl(const Owner &owner, SdlOutputClause &out_clause, const SdlOutputContext &ctx) const override=0
Convert actual value back to SDL value. Saving a loaded value as SDL value should rarely fail–as load...
std::string valueAsString(const T &value) const override=0
Human-readable representation of the value.
TSdlOptionalValue & description(std::string descriptionStr)
Definition TSdlOptionalValue.ipp:39
void loadFromSdl(Owner &owner, const SdlInputClause &clause, const SdlInputContext &ctx) const override=0
Load SDL value to actual value and store it in the owner's field. Implementations are highly encourag...
void setValue(Owner &owner, T value) const override
Store a value.
Definition TSdlOptionalValue.ipp:47
T * getValue(Owner &owner) const override
Get a pointer to the stored value.
Definition TSdlOptionalValue.ipp:53
const T * getConstValue(const Owner &owner) const override
Get a pointer to the stored value.
Definition TSdlOptionalValue.ipp:60
The root for all renderer implementations.
Definition EEngineProject.h:6