Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TSdlOwnerClass.h
Go to the documentation of this file.
1#pragma once
2
4#include "SDL/sdl_fwd.h"
8
9#include <Common/config.h>
10
11#include <string>
12#include <utility>
13#include <string_view>
14#include <array>
15
16namespace ph
17{
18
21template<typename Owner, typename FieldSet = TSdlBruteForceFieldSet<TSdlOwnedField<Owner>>>
23{
24public:
25 using OwnerType = Owner;
26
27public:
28 explicit TSdlOwnerClass(std::string displayName);
29
30 std::shared_ptr<ISdlResource> createResource() const override;
31
32 void initResource(
33 ISdlResource& resource,
34 SdlInputClauses& clauses,
35 const SdlInputContext& ctx) const override;
36
37 void initDefaultResource(ISdlResource& resource) const override;
38
39 void saveResource(
40 const ISdlResource& resource,
41 SdlOutputClauses& clauses,
42 const SdlOutputContext& ctx) const override;
43
44 void call(
45 std::string_view funcName,
46 ISdlResource* resource,
47 SdlInputClauses& clauses,
48 const SdlInputContext& ctx) const override;
49
51 const ISdlResource* targetResource,
52 std::vector<const ISdlResource*>& out_resources) const override;
53
54 std::size_t numFields() const override;
55 const SdlField* getField(std::size_t index) const override;
56 std::size_t numFunctions() const override;
57 const SdlFunction* getFunction(std::size_t index) const override;
58
64 Owner& owner,
65 SdlInputClauses& clauses,
66 const SdlInputContext& ctx) const;
67
72 void saveFieldsToSdl(
73 const Owner& owner,
74 SdlOutputClauses& clauses,
75 const SdlOutputContext& ctx) const;
76
77 const TSdlOwnedField<Owner>* getOwnedField(std::size_t index) const;
78
79 template<typename SdlFieldType>
80 TSdlOwnerClass& addField(SdlFieldType sdlField);
81
82 template<typename StructType>
83 TSdlOwnerClass& addStruct(StructType Owner::* structObjPtr);
84
85 template<typename StructType>
87 StructType Owner::* structObjPtr,
88 const SdlStructFieldStump& structFieldStump);
89
92 template<typename T>
94
95 auto description(std::string descriptionStr) -> TSdlOwnerClass&;
96
97 auto docName(std::string docName) -> TSdlOwnerClass&;
98
103 template<typename T>
104 auto baseOn() -> TSdlOwnerClass&;
105
108
109private:
114 void setFieldsToDefaults(Owner& owner) const;
115
120 template<typename DstType, typename SrcType>
121 DstType* castTo(SrcType* srcInstance) const;
122
124
125 FieldSet m_fields;
126 FunctionSet m_functions;
127};
128
129}// end namespace ph
130
Interface for all SDL resource.
Definition ISdlResource.h:22
Definition SdlClass.h:25
bool allowCreateFromClass() const
Whether a resource can be created by calling createResource(). This attribute is useful to decide whe...
Definition SdlClass.h:138
Definition SdlField.h:19
Definition SdlFunction.h:18
Container for input clauses.
Definition SdlInputClauses.h:18
Data that SDL input process can rely on.
Definition SdlInputContext.h:19
Definition SdlOutputClauses.h:14
Data that SDL output process can rely on.
Definition SdlOutputContext.h:19
Definition SdlStructFieldStump.h:12
Abstraction for a value that is owned by some owner type. Governs how a field should be initialized o...
Definition TSdlOwnedField.h:15
SDL binding type for a canonical SDL resource class.
Definition TSdlOwnerClass.h:23
void initDefaultResource(ISdlResource &resource) const override
Initialize a resource to default values. Default values are defined by the resource class's SDL defin...
Definition TSdlOwnerClass.ipp:74
const TSdlOwnedField< Owner > * getOwnedField(std::size_t index) const
Definition TSdlOwnerClass.ipp:190
TSdlOwnerClass & addStruct(StructType Owner::*structObjPtr, const SdlStructFieldStump &structFieldStump)
void referencedResources(const ISdlResource *targetResource, std::vector< const ISdlResource * > &out_resources) const override
Get all SDL resources referenced by targetResource.
Definition TSdlOwnerClass.ipp:144
auto docName(std::string docName) -> TSdlOwnerClass &
Definition TSdlOwnerClass.ipp:327
std::shared_ptr< ISdlResource > createResource() const override
Definition TSdlOwnerClass.ipp:32
TSdlOwnerClass & addStruct(StructType Owner::*structObjPtr)
void saveFieldsToSdl(const Owner &owner, SdlOutputClauses &clauses, const SdlOutputContext &ctx) const
Definition TSdlOwnerClass.ipp:303
void loadFieldsFromSdl(Owner &owner, SdlInputClauses &clauses, const SdlInputContext &ctx) const
Definition TSdlOwnerClass.ipp:249
void initResource(ISdlResource &resource, SdlInputClauses &clauses, const SdlInputContext &ctx) const override
Initialize a resource from value clauses. How the resource will be initialized depends on the resourc...
Definition TSdlOwnerClass.ipp:57
TSdlOwnerClass(std::string displayName)
Definition TSdlOwnerClass.ipp:21
bool allowCreateFromClass() const
Whether a resource can be created by calling createResource(). This attribute is useful to decide whe...
Definition SdlClass.h:138
const SdlField * getField(std::size_t index) const override
Definition TSdlOwnerClass.ipp:172
void call(std::string_view funcName, ISdlResource *resource, SdlInputClauses &clauses, const SdlInputContext &ctx) const override
Definition TSdlOwnerClass.ipp:106
Owner OwnerType
Definition TSdlOwnerClass.h:25
auto description(std::string descriptionStr) -> TSdlOwnerClass &
Definition TSdlOwnerClass.ipp:319
TSdlOwnerClass & addField(SdlFieldType sdlField)
auto baseOn() -> TSdlOwnerClass &
Set another SDL class as the base of this class.
Definition TSdlOwnerClass.ipp:336
TSdlOwnerClass & addFunction()
Adds a function that can later be called.
std::size_t numFields() const override
Definition TSdlOwnerClass.ipp:166
void saveResource(const ISdlResource &resource, SdlOutputClauses &clauses, const SdlOutputContext &ctx) const override
Definition TSdlOwnerClass.ipp:88
const SdlFunction * getFunction(std::size_t index) const override
Definition TSdlOwnerClass.ipp:184
std::size_t numFunctions() const override
Definition TSdlOwnerClass.ipp:178
The root for all renderer implementations.
Definition EEngineProject.h:6