Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TSdlPath.h
Go to the documentation of this file.
1#pragma once
2
5#include "SDL/sdl_helpers.h"
6
7#include <Common/assertion.h>
8#include <Common/primitive_type.h>
9
10#include <string>
11
12namespace ph
13{
14
17template<typename Owner, typename SdlValueType = TSdlValue<Path, Owner>>
18class TSdlPath : public SdlValueType
19{
20 static_assert(std::is_base_of_v<TSdlAbstractValue<Path, Owner>, SdlValueType>,
21 "SdlValueType should be a subclass of TSdlAbstractValue.");
22
23public:
24 template<typename ValueType>
25 TSdlPath(std::string valueName, ValueType Owner::* const valuePtr) :
26 SdlValueType("path", std::move(valueName), valuePtr)
27 {}
28
29 std::string valueAsString(const Path& path) const override
30 {
31 return path.toString();
32 }
33
34 SdlNativeData ownedNativeData(Owner& owner) const override
35 {
36 Path* const path = this->getValue(owner);
39 }
40
41protected:
43 Owner& owner,
44 const SdlInputClause& clause,
45 const SdlInputContext& ctx) const override
46 {
47 this->setValue(owner, Path(clause.value));
48 }
49
51 const Owner& owner,
52 SdlOutputClause& out_clause,
53 const SdlOutputContext& ctx) const override
54 {
55 // Paths are always enclosed in double quotes, they have high chance to contain whitespaces
56 out_clause.value = '"';
57
58 if(const Path* path = this->getConstValue(owner); path)
59 {
60 out_clause.value += path->toString();
61 }
62
63 out_clause.value += '"';
64 }
65};
66
67}// end namespace ph
General path representation. Does not check whether the target actually exists (e....
Definition Path.h:21
std::string toString() const
Get a string representation of this path in generic format.
Definition Path.cpp:121
Carries SDL representation of various data during the input process. Helps to read input data such as...
Definition SdlInputClause.h:15
std::string value
Loaded stringified data of a clause. All potential SDL value prefixes or suffixes (e....
Definition SdlInputClause.h:25
Data that SDL input process can rely on.
Definition SdlInputContext.h:19
Definition SdlNativeData.h:88
static SdlNativeData fromSingleElement(ElementType *elementPtr, ESdlDataFormat elementContainer, ESdlDataType elementType, bool canSet=false, bool canDirectAccess=false)
Creates native data for a single element pointer.
Definition SdlNativeData.ipp:86
Carries SDL representation of various data during the output process. Helps to write output data such...
Definition SdlOutputClause.h:14
std::string value
Stores stringified data of a clause. As the output clause generator knows best how its data look like...
Definition SdlOutputClause.h:29
Data that SDL output process can rely on.
Definition SdlOutputContext.h:19
A field class that binds a Path member variable.
Definition TSdlPath.h:19
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 TSdlPath.h:50
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 TSdlPath.h:34
TSdlPath(std::string valueName, ValueType Owner::*const valuePtr)
Definition TSdlPath.h:25
std::string valueAsString(const Path &path) const override
Definition TSdlPath.h:29
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 TSdlPath.h:42
void setValue(Owner &owner, T value) const override
Store a value.
Definition TSdlValue.ipp:38
const T * getConstValue(const Owner &owner) const override
Get a pointer to the stored value.
Definition TSdlValue.ipp:50
T * getValue(Owner &owner) const override
Get a pointer to the stored value.
Definition TSdlValue.ipp:44
The root for all renderer implementations.
Definition EEngineProject.h:6
Definition TAABB2D.h:96
Low-level helpers for SDL. Helpers are in an additional sdl namespace.