Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TSdlAbstractValue.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <Common/assertion.h>
6
7#include <string>
8#include <vector>
9
10namespace ph
11{
12
15template<typename T, typename Owner>
16class TSdlAbstractValue : public TSdlOwnedField<Owner>
17{
18public:
20 std::string typeName,
21 std::string valueName);
22
24 std::string typeName,
25 std::string valueName,
26 std::string typeSignature);
27
30 virtual std::string valueAsString(const T& value) const = 0;
31
34 virtual void setValue(Owner& owner, T value) const = 0;
35
39 virtual T* getValue(Owner& owner) const = 0;
40
44 virtual const T* getConstValue(const Owner& owner) const = 0;
45
46 void ownedValueToDefault(Owner& owner) const override = 0;
47
48 SdlNativeData ownedNativeData(Owner& owner) const override = 0;
49
50 std::string valueToString(const Owner& owner) const override;
51
52 void ownedResources(
53 const Owner& owner,
54 std::vector<const ISdlResource*>& out_resources) const override;
55
56protected:
58 Owner& owner,
59 const SdlInputClause& clause,
60 const SdlInputContext& ctx) const override = 0;
61
63 const Owner& owner,
64 SdlOutputClause& out_clause,
65 const SdlOutputContext& ctx) const override = 0;
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
General concept of a SDL value type.
Definition TSdlAbstractValue.h:17
std::string valueToString(const Owner &owner) const override
Convert the value of the field to human-readable string.
Definition TSdlAbstractValue.ipp:31
virtual void setValue(Owner &owner, T value) const =0
Store a value.
virtual std::string valueAsString(const T &value) const =0
Human-readable representation of the value.
virtual T * getValue(Owner &owner) const =0
Get a pointer to the stored value.
virtual const T * getConstValue(const Owner &owner) const =0
Get a pointer to the stored value.
void ownedResources(const Owner &owner, std::vector< const ISdlResource * > &out_resources) const override
Get all SDL resources associated by owner.
Definition TSdlAbstractValue.ipp:38
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...
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...
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...
TSdlAbstractValue(std::string typeName, std::string valueName)
Definition TSdlAbstractValue.ipp:9
void ownedValueToDefault(Owner &owner) const override=0
Set the value of the field to a default one. Since the field class is templatized by Owner type,...
Abstraction for a value that is owned by some owner type. Governs how a field should be initialized o...
Definition TSdlOwnedField.h:15
The root for all renderer implementations.
Definition EEngineProject.h:6