Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::TSdlNestedField< OuterType, InnerType > Class Template Reference

A field that lives within an inner object. More...

#include <TSdlNestedField.h>

Inheritance diagram for ph::TSdlNestedField< OuterType, InnerType >:
ph::TSdlOwnedField< OuterType > ph::SdlField

Public Member Functions

 TSdlNestedField (InnerType OuterType::*innerObjPtr, const TSdlOwnedField< InnerType > *innerObjField)
 
void ownedValueToDefault (OuterType &outerObj) const override
 Set the value of the field to a default one. Since the field class is templatized by Owner type, we are able to define default value on a per owner type basis.
 
std::string valueToString (const OuterType &outerObj) const override
 Convert the value of the field to human-readable string.
 
void ownedResources (const OuterType &outerObj, std::vector< const ISdlResource * > &out_resources) const override
 Get all SDL resources associated by owner.
 
SdlNativeData ownedNativeData (OuterType &outerObj) const override
 Direct access to the field memory of an owner. Short-lived owner objects such as function parameter structs must be kept alive during during this call and any further usages of the returned native data.
 
- Public Member Functions inherited from ph::TSdlOwnedField< OuterType >
 TSdlOwnedField (std::string typeName, std::string valueName)
 
 TSdlOwnedField (std::string typeName, std::string valueName, std::string typeSignature)
 
SdlNativeData nativeData (SdlNonConstInstance instance) const override
 Direct access to the field memory of a SDL instance. Note that this field may not necessarily be bound to a SDL resource type (e.g., may bound to any function parameter structs). Empty native data info will be returned in cases where this field is not owned by (or being part of) the input instance. Obtaining native data requires the input instance be valid during this call and any further usages of the returned native data.
 
void fromSdl (OuterType &owner, const SdlInputClause &clause, const SdlInputContext &ctx) const
 Acquire value and store in the owner's field. The loading process will follow a series of preset policy. In addition, failed loading attempt may be recovered if needed.
 
void toSdl (const OuterType &owner, SdlOutputClause &out_clause, const SdlOutputContext &ctx) const
 
- Public Member Functions inherited from ph::SdlField
 SdlField (std::string typeName, std::string fieldName)
 
 SdlField (std::string typeName, std::string fieldName, std::string typeSignature)
 
virtual ~SdlField ()
 
std::string genPrettyName () const
 
std::string_view getTypeName () const
 
std::string_view getFieldName () const
 
std::string_view getDescription () const
 
std::string_view getTypeSignature () const
 
EFieldImportance getImportance () const
 
bool isFallbackEnabled () const
 Whether the field want to use built-in mechanism to handle I/O problems. An example of this is default field value. With fallback enabled, the field may set itself to the default value supplied (if available) on error. By default, fallback is enabled.
 

Protected Member Functions

void loadFromSdl (OuterType &outerObj, 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 encouraged to throw SdlLoadError if the loading process is not successful. This will allow things such as automatic fallback to work according to field policies.
 
void saveToSdl (const OuterType &outerObj, 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 loaded value has been properly handled by the loading process already. In case of failure, throw SdlSaveError and provide detailed reason describing the event.
 
- Protected Member Functions inherited from ph::SdlField
SdlFieldsetDescription (std::string descriptionStr)
 
SdlFieldsetImportance (EFieldImportance importance)
 Sets the importance of the field. Different importance affect the underlying policy used during the import and export of the field, e.g., whether warnings are emitted.
 
SdlFieldsetEnableFallback (bool isFallbackEnabled)
 

Detailed Description

template<typename OuterType, typename InnerType>
class ph::TSdlNestedField< OuterType, InnerType >

A field that lives within an inner object.

Field properties (importance, fall back, etc.) are initialized to the same values as inner field, and can be overridden by manually setting the properties later.

Constructor & Destructor Documentation

◆ TSdlNestedField()

template<typename OuterType , typename InnerType >
ph::TSdlNestedField< OuterType, InnerType >::TSdlNestedField ( InnerType OuterType::* innerObjPtr,
const TSdlOwnedField< InnerType > * innerObjField )
inline

Member Function Documentation

◆ loadFromSdl()

template<typename OuterType , typename InnerType >
void ph::TSdlNestedField< OuterType, InnerType >::loadFromSdl ( OuterType & owner,
const SdlInputClause & clause,
const SdlInputContext & ctx ) const
inlineoverrideprotectedvirtual

Load SDL value to actual value and store it in the owner's field. Implementations are highly encouraged to throw SdlLoadError if the loading process is not successful. This will allow things such as automatic fallback to work according to field policies.

Parameters
ownerInstance that owns the field.
clauseThe SDL representation to be loaded into actual value.
ctxThe context for loading.

Implements ph::TSdlOwnedField< OuterType >.

◆ ownedNativeData()

template<typename OuterType , typename InnerType >
SdlNativeData ph::TSdlNestedField< OuterType, InnerType >::ownedNativeData ( OuterType & owner) const
inlineoverridevirtual

Direct access to the field memory of an owner. Short-lived owner objects such as function parameter structs must be kept alive during during this call and any further usages of the returned native data.

Implements ph::TSdlOwnedField< OuterType >.

◆ ownedResources()

template<typename OuterType , typename InnerType >
void ph::TSdlNestedField< OuterType, InnerType >::ownedResources ( const OuterType & owner,
std::vector< const ISdlResource * > & out_resources ) const
inlineoverridevirtual

Get all SDL resources associated by owner.

Parameters
ownerOwner instance in question.
out_resourcesSDL resources associated with this field by the owner. Never contains null. Appends to existing ones.

Implements ph::TSdlOwnedField< OuterType >.

◆ ownedValueToDefault()

template<typename OuterType , typename InnerType >
void ph::TSdlNestedField< OuterType, InnerType >::ownedValueToDefault ( OuterType & owner) const
inlineoverridevirtual

Set the value of the field to a default one. Since the field class is templatized by Owner type, we are able to define default value on a per owner type basis.

Implements ph::TSdlOwnedField< OuterType >.

◆ saveToSdl()

template<typename OuterType , typename InnerType >
void ph::TSdlNestedField< OuterType, InnerType >::saveToSdl ( const OuterType & owner,
SdlOutputClause & out_clause,
const SdlOutputContext & ctx ) const
overrideprotectedvirtual

Convert actual value back to SDL value. Saving a loaded value as SDL value should rarely fail–as loaded value has been properly handled by the loading process already. In case of failure, throw SdlSaveError and provide detailed reason describing the event.

Parameters
ownerInstance that owns the field.
out_clauseThe SDL representation for the actual value.
ctxThe context for saving.

Implements ph::TSdlOwnedField< OuterType >.

◆ valueToString()

template<typename OuterType , typename InnerType >
std::string ph::TSdlNestedField< OuterType, InnerType >::valueToString ( const OuterType & owner) const
inlineoverridevirtual

Convert the value of the field to human-readable string.

Implements ph::TSdlOwnedField< OuterType >.


The documentation for this class was generated from the following file: