9#include <Common/assertion.h>
18template<
typename StructType>
26template<
typename StructType>
32 constexpr auto noticeReceiver = [](std::string noticeMsg,
EFieldImportance importance)
36 PH_LOG_STRING(
SdlStruct, Note, noticeMsg);
40 PH_LOG_STRING(
SdlStruct, Warning, noticeMsg);
49 *(obj.
get<StructType>()),
56template<
typename StructType>
61 for(std::size_t fieldIdx = 0; fieldIdx < m_fields.numFields(); ++fieldIdx)
63 const auto& field = m_fields[fieldIdx];
66 field.ownedValueToDefault(*(obj.
get<StructType>()));
70template<
typename StructType>
78 for(std::size_t fieldIdx = 0; fieldIdx < m_fields.numFields(); ++fieldIdx)
84 field.
toSdl(*(obj.
get<StructType>()), clause, ctx);
89template<
typename StructType>
92 std::vector<const ISdlResource*>& out_resources)
const
96 for(std::size_t fieldIdx = 0; fieldIdx < m_fields.numFields(); ++fieldIdx)
98 m_fields[fieldIdx].ownedResources(*(obj.
get<StructType>()), out_resources);
102template<
typename StructType>
108 static_assert(std::is_base_of_v<SdlField, T>,
109 "T is not a SdlField thus cannot be added.");
111 m_fields.
addField(std::move(sdlField));
116template<
typename StructType>
117template<
typename StructObjType>
122 static_assert(std::is_base_of_v<SdlStruct, StructObjType>,
123 "StructObjType is not a SdlStruct thus cannot be added.");
125 PH_ASSERT(structObjPtr);
132template<
typename StructType>
133template<
typename StructObjType>
135 StructObjType StructType::* const structObjPtr,
141 static_assert(std::is_base_of_v<SdlStruct, StructObjType>,
142 "StructObjType is not a SdlStruct thus cannot be added.");
144 PH_ASSERT(structObjPtr);
146 m_fields.addFields(structFieldStump.genFieldSet(structObjPtr));
151template<
typename StructType>
154 setFieldsToDefaults(structObj);
157template<
typename StructType>
160 return m_fields.numFields();
163template<
typename StructType>
166 return m_fields.getField(index);
169template<
typename StructType>
176template<
typename StructType>
180 setDescription(std::move(descriptionStr));
184template<
typename StructType>
187 for(std::size_t fieldIdx = 0; fieldIdx < m_fields.numFields(); ++fieldIdx)
189 const auto& field = m_fields[fieldIdx];
192 field.ownedValueToDefault(structObj);
Data that SDL input process can rely on.
Definition SdlInputContext.h:19
Carries SDL representation of various data during the output process. Helps to write output data such...
Definition SdlOutputClause.h:14
Definition SdlOutputClauses.h:14
SdlOutputClause & createClause()
Definition SdlOutputClauses.h:34
Data that SDL output process can rely on.
Definition SdlOutputContext.h:19
Definition SdlStructFieldStump.h:12
Definition SdlStruct.h:25
auto * get() const
Definition TAnyPtr.h:72
A set of fields, with basic functionalities.
Definition TSdlBruteForceFieldSet.h:32
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
SDL binding type for a typical C++ struct.
Definition TSdlOwnerStruct.h:18
void saveObject(AnyConstPtr obj, SdlOutputClauses &clauses, const SdlOutputContext &ctx) const override
Definition TSdlOwnerStruct.ipp:71
TSdlOwnerStruct & addStruct(StructObjType StructType::*structObjPtr)
void referencedResources(AnyConstPtr obj, std::vector< const ISdlResource * > &out_resources) const override
Get all SDL resources referenced by obj.
Definition TSdlOwnerStruct.ipp:90
void initObject(AnyNonConstPtr obj, SdlInputClauses &clauses, const SdlInputContext &ctx) const override
Initialize a struct object from value clauses. How the object will be initialized depends on the stru...
Definition TSdlOwnerStruct.ipp:27
std::size_t numFields() const override
Definition TSdlOwnerStruct.ipp:158
TSdlOwnerStruct & description(std::string descriptionStr)
Definition TSdlOwnerStruct.ipp:177
void initDefaultObject(AnyNonConstPtr obj) const override
Initialize a struct object to default values. Default values are defined by the struct's SDL definiti...
Definition TSdlOwnerStruct.ipp:57
auto getFields() const -> const TSdlBruteForceFieldSet< TSdlOwnedField< StructType > > &
Definition TSdlOwnerStruct.ipp:170
void initDefaultStruct(StructType &structObj) const
Initialize the struct object to default values.
Definition TSdlOwnerStruct.ipp:152
TSdlOwnerStruct(std::string name)
Definition TSdlOwnerStruct.ipp:19
const SdlField * getField(std::size_t index) const override
Definition TSdlOwnerStruct.ipp:164
TSdlOwnerStruct & addField(T sdlField)
void load_fields_from_sdl(Owner &owner, FieldSet &fieldSet, SdlInputClauses &clauses, const SdlInputContext &ctx, NoticeReceiver noticeReceiver=NoOpNoticeReceiver())
Definition field_set_op.ipp:21
void save_field_id(const SdlField *const sdlField, SdlOutputClause &clause)
Save the identity of the field to output clause.
Definition sdl_helpers.cpp:16
The root for all renderer implementations.
Definition EEngineProject.h:6
EFieldImportance
Definition EFieldImportance.h:7