Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::TSdlOwnedField< Owner > Class Template Referenceabstract

Abstraction for a value that is owned by some owner type. Governs how a field should be initialized on the policy level. More...

#include <TSdlOwnedField.h>

Inheritance diagram for ph::TSdlOwnedField< Owner >:
ph::SdlField ph::TSdlAbstractValue< bool, Owner > ph::TSdlAbstractValue< EnumType, Owner > ph::TSdlAbstractValue< integer, Owner > ph::TSdlAbstractValue< Path, Owner > ph::TSdlAbstractValue< math::TQuaternion< real >, Owner > ph::TSdlAbstractValue< real, Owner > ph::TSdlAbstractValue< std::vector< real >, Owner > ph::TSdlAbstractValue< ResourceIdentifier, Owner > ph::TSdlAbstractValue< math::Spectrum, Owner > ph::TSdlAbstractValue< std::string, Owner > ph::TSdlAbstractValue< math::TVector2< Element >, Owner > ph::TSdlAbstractValue< math::TVector3< real >, Owner > ph::TSdlAbstractValue< math::TVector4< real >, Owner > ph::TSdlAbstractValue< T, Owner > ph::TSdlReference< T, Owner > ph::TSdlReferenceArray< T, Owner > ph::TSdlStructArray< Struct, Owner >

Public Member Functions

 TSdlOwnedField (std::string typeName, std::string valueName)
 
 TSdlOwnedField (std::string typeName, std::string valueName, std::string typeSignature)
 
virtual void ownedValueToDefault (Owner &owner) const =0
 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.
 
virtual std::string valueToString (const Owner &owner) const =0
 Convert the value of the field to human-readable string.
 
virtual void ownedResources (const Owner &owner, std::vector< const ISdlResource * > &out_resources) const =0
 Get all SDL resources associated by owner.
 
virtual SdlNativeData ownedNativeData (Owner &owner) const =0
 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.
 
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 (Owner &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 Owner &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

virtual void loadFromSdl (Owner &owner, const SdlInputClause &clause, const SdlInputContext &ctx) const =0
 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.
 
virtual void saveToSdl (const Owner &owner, SdlOutputClause &out_clause, const SdlOutputContext &ctx) const =0
 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)
 

Friends

template<typename OuterType , typename InnerType >
class TSdlNestedField
 

Detailed Description

template<typename Owner>
class ph::TSdlOwnedField< Owner >

Abstraction for a value that is owned by some owner type. Governs how a field should be initialized on the policy level.

Template Parameters
OwnerThe owner type. May be any C++ class/struct type including SDL resource types.

Constructor & Destructor Documentation

◆ TSdlOwnedField() [1/2]

template<typename Owner >
ph::TSdlOwnedField< Owner >::TSdlOwnedField ( std::string typeName,
std::string valueName )
inline

◆ TSdlOwnedField() [2/2]

template<typename Owner >
ph::TSdlOwnedField< Owner >::TSdlOwnedField ( std::string typeName,
std::string valueName,
std::string typeSignature )
inline

Member Function Documentation

◆ fromSdl()

template<typename Owner >
void ph::TSdlOwnedField< Owner >::fromSdl ( Owner & owner,
const SdlInputClause & clause,
const SdlInputContext & ctx ) const
inline

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.

◆ loadFromSdl()

template<typename Owner >
virtual void ph::TSdlOwnedField< Owner >::loadFromSdl ( Owner & owner,
const SdlInputClause & clause,
const SdlInputContext & ctx ) const
protectedpure virtual

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.

Implemented in ph::TSdlAbstractValue< T, Owner >, ph::TSdlAbstractValue< bool, Owner >, ph::TSdlAbstractValue< EnumType, Owner >, ph::TSdlAbstractValue< integer, Owner >, ph::TSdlAbstractValue< math::Spectrum, Owner >, ph::TSdlAbstractValue< math::TQuaternion< real >, Owner >, ph::TSdlAbstractValue< math::TVector2< Element >, Owner >, ph::TSdlAbstractValue< math::TVector3< real >, Owner >, ph::TSdlAbstractValue< math::TVector4< real >, Owner >, ph::TSdlAbstractValue< Path, Owner >, ph::TSdlAbstractValue< real, Owner >, ph::TSdlAbstractValue< ResourceIdentifier, Owner >, ph::TSdlAbstractValue< std::string, Owner >, ph::TSdlAbstractValue< std::vector< real >, Owner >, ph::TSdlBool< Owner, SdlValueType >, ph::TSdlEnumField< Owner, EnumType, SdlValueType >, ph::TSdlInteger< Owner, IntType, SdlValueType >, ph::TSdlNestedField< OuterType, InnerType >, ph::TSdlOptionalValue< T, Owner >, ph::TSdlPath< Owner, SdlValueType >, ph::TSdlQuaternion< Owner, Element, SdlValueType >, ph::TSdlReal< Owner, FloatType, SdlValueType >, ph::TSdlRealArray< Owner, Element, SdlValueType >, ph::TSdlReference< T, Owner >, ph::TSdlReferenceArray< T, Owner >, ph::TSdlResourceIdentifier< Owner, IS_SRI, SdlValueType >, ph::TSdlSpectrum< Owner, SdlValueType >, ph::TSdlString< Owner, SdlValueType >, ph::TSdlStructArray< Struct, Owner >, ph::TSdlValue< T, Owner >, ph::TSdlValue< bool, Owner >, ph::TSdlValue< EnumType, Owner >, ph::TSdlValue< integer, Owner >, ph::TSdlValue< math::Spectrum, Owner >, ph::TSdlValue< math::TQuaternion< real >, Owner >, ph::TSdlValue< math::TVector2< Element >, Owner >, ph::TSdlValue< math::TVector3< real >, Owner >, ph::TSdlValue< math::TVector4< real >, Owner >, ph::TSdlValue< Path, Owner >, ph::TSdlValue< real, Owner >, ph::TSdlValue< ResourceIdentifier, Owner >, ph::TSdlValue< std::string, Owner >, ph::TSdlValue< std::vector< real >, Owner >, ph::TSdlVector2< Owner, Element, SdlValueType >, ph::TSdlVector3< Owner, Element, SdlValueType >, and ph::TSdlVector4< Owner, Element, SdlValueType >.

◆ nativeData()

template<typename Owner >
SdlNativeData ph::TSdlOwnedField< Owner >::nativeData ( SdlNonConstInstance instance) const
inlineoverridevirtual

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.

Implements ph::SdlField.

◆ ownedNativeData()

template<typename Owner >
virtual SdlNativeData ph::TSdlOwnedField< Owner >::ownedNativeData ( Owner & owner) const
pure virtual

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.

Implemented in ph::TSdlAbstractValue< T, Owner >, ph::TSdlAbstractValue< bool, Owner >, ph::TSdlAbstractValue< EnumType, Owner >, ph::TSdlAbstractValue< integer, Owner >, ph::TSdlAbstractValue< math::Spectrum, Owner >, ph::TSdlAbstractValue< math::TQuaternion< real >, Owner >, ph::TSdlAbstractValue< math::TVector2< Element >, Owner >, ph::TSdlAbstractValue< math::TVector3< real >, Owner >, ph::TSdlAbstractValue< math::TVector4< real >, Owner >, ph::TSdlAbstractValue< Path, Owner >, ph::TSdlAbstractValue< real, Owner >, ph::TSdlAbstractValue< ResourceIdentifier, Owner >, ph::TSdlAbstractValue< std::string, Owner >, ph::TSdlAbstractValue< std::vector< real >, Owner >, ph::TSdlBool< Owner, SdlValueType >, ph::TSdlEnumField< Owner, EnumType, SdlValueType >, ph::TSdlInteger< Owner, IntType, SdlValueType >, ph::TSdlNestedField< OuterType, InnerType >, ph::TSdlOptionalValue< T, Owner >, ph::TSdlPath< Owner, SdlValueType >, ph::TSdlQuaternion< Owner, Element, SdlValueType >, ph::TSdlReal< Owner, FloatType, SdlValueType >, ph::TSdlRealArray< Owner, Element, SdlValueType >, ph::TSdlReference< T, Owner >, ph::TSdlReferenceArray< T, Owner >, ph::TSdlResourceIdentifier< Owner, IS_SRI, SdlValueType >, ph::TSdlSpectrum< Owner, SdlValueType >, ph::TSdlString< Owner, SdlValueType >, ph::TSdlStructArray< Struct, Owner >, ph::TSdlValue< T, Owner >, ph::TSdlValue< bool, Owner >, ph::TSdlValue< EnumType, Owner >, ph::TSdlValue< integer, Owner >, ph::TSdlValue< math::Spectrum, Owner >, ph::TSdlValue< math::TQuaternion< real >, Owner >, ph::TSdlValue< math::TVector2< Element >, Owner >, ph::TSdlValue< math::TVector3< real >, Owner >, ph::TSdlValue< math::TVector4< real >, Owner >, ph::TSdlValue< Path, Owner >, ph::TSdlValue< real, Owner >, ph::TSdlValue< ResourceIdentifier, Owner >, ph::TSdlValue< std::string, Owner >, ph::TSdlValue< std::vector< real >, Owner >, ph::TSdlVector2< Owner, Element, SdlValueType >, ph::TSdlVector3< Owner, Element, SdlValueType >, and ph::TSdlVector4< Owner, Element, SdlValueType >.

◆ ownedResources()

◆ ownedValueToDefault()

template<typename Owner >
virtual void ph::TSdlOwnedField< Owner >::ownedValueToDefault ( Owner & owner) const
pure virtual

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.

Implemented in ph::TSdlAbstractValue< T, Owner >, ph::TSdlAbstractValue< bool, Owner >, ph::TSdlAbstractValue< EnumType, Owner >, ph::TSdlAbstractValue< integer, Owner >, ph::TSdlAbstractValue< math::Spectrum, Owner >, ph::TSdlAbstractValue< math::TQuaternion< real >, Owner >, ph::TSdlAbstractValue< math::TVector2< Element >, Owner >, ph::TSdlAbstractValue< math::TVector3< real >, Owner >, ph::TSdlAbstractValue< math::TVector4< real >, Owner >, ph::TSdlAbstractValue< Path, Owner >, ph::TSdlAbstractValue< real, Owner >, ph::TSdlAbstractValue< ResourceIdentifier, Owner >, ph::TSdlAbstractValue< std::string, Owner >, ph::TSdlAbstractValue< std::vector< real >, Owner >, ph::TSdlNestedField< OuterType, InnerType >, ph::TSdlOptionalValue< T, Owner >, ph::TSdlReference< T, Owner >, ph::TSdlReferenceArray< T, Owner >, ph::TSdlStructArray< Struct, Owner >, ph::TSdlValue< T, Owner >, ph::TSdlValue< bool, Owner >, ph::TSdlValue< EnumType, Owner >, ph::TSdlValue< integer, Owner >, ph::TSdlValue< math::Spectrum, Owner >, ph::TSdlValue< math::TQuaternion< real >, Owner >, ph::TSdlValue< math::TVector2< Element >, Owner >, ph::TSdlValue< math::TVector3< real >, Owner >, ph::TSdlValue< math::TVector4< real >, Owner >, ph::TSdlValue< Path, Owner >, ph::TSdlValue< real, Owner >, ph::TSdlValue< ResourceIdentifier, Owner >, ph::TSdlValue< std::string, Owner >, and ph::TSdlValue< std::vector< real >, Owner >.

◆ saveToSdl()

template<typename Owner >
virtual void ph::TSdlOwnedField< Owner >::saveToSdl ( const Owner & owner,
SdlOutputClause & out_clause,
const SdlOutputContext & ctx ) const
protectedpure virtual

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.

Implemented in ph::TSdlAbstractValue< T, Owner >, ph::TSdlAbstractValue< bool, Owner >, ph::TSdlAbstractValue< EnumType, Owner >, ph::TSdlAbstractValue< integer, Owner >, ph::TSdlAbstractValue< math::Spectrum, Owner >, ph::TSdlAbstractValue< math::TQuaternion< real >, Owner >, ph::TSdlAbstractValue< math::TVector2< Element >, Owner >, ph::TSdlAbstractValue< math::TVector3< real >, Owner >, ph::TSdlAbstractValue< math::TVector4< real >, Owner >, ph::TSdlAbstractValue< Path, Owner >, ph::TSdlAbstractValue< real, Owner >, ph::TSdlAbstractValue< ResourceIdentifier, Owner >, ph::TSdlAbstractValue< std::string, Owner >, ph::TSdlAbstractValue< std::vector< real >, Owner >, ph::TSdlBool< Owner, SdlValueType >, ph::TSdlEnumField< Owner, EnumType, SdlValueType >, ph::TSdlInteger< Owner, IntType, SdlValueType >, ph::TSdlNestedField< OuterType, InnerType >, ph::TSdlOptionalValue< T, Owner >, ph::TSdlPath< Owner, SdlValueType >, ph::TSdlQuaternion< Owner, Element, SdlValueType >, ph::TSdlReal< Owner, FloatType, SdlValueType >, ph::TSdlRealArray< Owner, Element, SdlValueType >, ph::TSdlReference< T, Owner >, ph::TSdlReferenceArray< T, Owner >, ph::TSdlResourceIdentifier< Owner, IS_SRI, SdlValueType >, ph::TSdlSpectrum< Owner, SdlValueType >, ph::TSdlString< Owner, SdlValueType >, ph::TSdlStructArray< Struct, Owner >, ph::TSdlValue< T, Owner >, ph::TSdlValue< bool, Owner >, ph::TSdlValue< EnumType, Owner >, ph::TSdlValue< integer, Owner >, ph::TSdlValue< math::Spectrum, Owner >, ph::TSdlValue< math::TQuaternion< real >, Owner >, ph::TSdlValue< math::TVector2< Element >, Owner >, ph::TSdlValue< math::TVector3< real >, Owner >, ph::TSdlValue< math::TVector4< real >, Owner >, ph::TSdlValue< Path, Owner >, ph::TSdlValue< real, Owner >, ph::TSdlValue< ResourceIdentifier, Owner >, ph::TSdlValue< std::string, Owner >, ph::TSdlValue< std::vector< real >, Owner >, ph::TSdlVector2< Owner, Element, SdlValueType >, ph::TSdlVector3< Owner, Element, SdlValueType >, and ph::TSdlVector4< Owner, Element, SdlValueType >.

◆ toSdl()

template<typename Owner >
void ph::TSdlOwnedField< Owner >::toSdl ( const Owner & owner,
SdlOutputClause & out_clause,
const SdlOutputContext & ctx ) const
inline

◆ valueToString()

Friends And Related Symbol Documentation

◆ TSdlNestedField

template<typename Owner >
template<typename OuterType , typename InnerType >
friend class TSdlNestedField
friend

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