template<class T, ManagedObjectAccess Access>
esp::metadata::managers::AbstractObjectAttributesManager class

Class template defining responsibilities and functionality for managing esp::metadata::attributes::AbstractObjectAttributes constructs.

Template parameters
T the type of managed attributes a particular specialization of this class works with. Must inherit from esp::metadata::attributes::AbstractObjectAttributes.
Access

Base classes

template<class T, ManagedObjectAccess Access>
class AttributesManager<T, Access>
Class template defining responsibilities and functionality for managing esp::metadata::attributes::AbstractAttributes constructs.

Public types

using AbsObjAttrPtr = std::shared_ptr<T>

Constructors, destructors, conversion operators

AbstractObjectAttributesManager(const std::string& attrType, const std::string& JSONTypeExt)
~AbstractObjectAttributesManager() defaulted override

Public functions

auto createObject(const std::string& attributesTemplateHandle, bool registerTemplate = true) -> AbsObjAttrPtr override
Creates an instance of an object or stage template. The passed string should be either a file name or a reference to a primitive asset template that should be used in the construction of the object or stage; any other strings will result in a new default template being created.
auto createPrimBasedAttributesTemplate(const std::string& primAttrTemplateHandle, bool registerTemplate = true) -> AbsObjAttrPtr pure virtual
Creates an instance of an object or stage template described by passed string, which should be a reference to an existing primitive asset template to be used in the construction of the object or stage (as render and collision mesh). It returns existing instance if there is one, and nullptr if fails.

Protected functions

auto loadAbstractObjectAttributesFromJson(AbsObjAttrPtr attributes, const io::JsonGenericValue& jsonDoc) -> AbsObjAttrPtr
Populate an existing metadata::attributes::AbstractObjectAttributes from a JSON config. Also will populate render mesh and collision mesh handles with value(s) specified in JSON. If one is blank will use other for both.
auto setJSONAssetHandleAndType(AbsObjAttrPtr attributes, const io::JsonGenericValue& jsonDoc, const char* jsonMeshTypeTag, const char* jsonMeshHandleTag, std::string& assetName, const std::function<void(int)>& meshTypeSetter) -> std::string
Only used by esp::metadata::attributes::AbstractObjectAttributes derived-attributes. Set the asset type and mesh asset filename from json file. If mesh asset filename has changed in json, but type has not been specified in json, re-run file-path-driven configuration to get asset type and possibly orientation frame, if appropriate.
void setDefaultAssetNameBasedAttributes(AbsObjAttrPtr attributes, bool setFrame, const std::string& assetName, const std::function<void(int)>& meshTypeSetter) pure virtual
Perform asset-name-based attributes initialization. This is to take the place of the AssetInfo::fromPath functionality, and is only intended to provide default values and other help if certain mistakes are made by the user, such as specifying an asset handle in json but not specifying the asset type corresponding to that handle. These settings should not restrict anything, only provide defaults.

Function documentation

template<class T, ManagedObjectAccess Access>
AbsObjAttrPtr esp::metadata::managers::AbstractObjectAttributesManager<T, Access>::createObject(const std::string& attributesTemplateHandle, bool registerTemplate = true) override

Creates an instance of an object or stage template. The passed string should be either a file name or a reference to a primitive asset template that should be used in the construction of the object or stage; any other strings will result in a new default template being created.

Parameters
attributesTemplateHandle the origin of the desired template to be created, either a file name or an existing primitive asset template. If this is neither a recognized file name nor the handle of an existing primitive asset, a new default template will be created.
registerTemplate whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to true. If specified as true, then this function returns a copy of the registered template.
Returns a reference to the desired template.

If a template exists with this handle, this existing template will be overwritten with the newly created one if registerTemplate is true.

template<class T, ManagedObjectAccess Access>
AbsObjAttrPtr esp::metadata::managers::AbstractObjectAttributesManager<T, Access>::createPrimBasedAttributesTemplate(const std::string& primAttrTemplateHandle, bool registerTemplate = true) pure virtual

Creates an instance of an object or stage template described by passed string, which should be a reference to an existing primitive asset template to be used in the construction of the object or stage (as render and collision mesh). It returns existing instance if there is one, and nullptr if fails.

Parameters
primAttrTemplateHandle The handle to an existing primitive asset template. Fails if does not exist.
registerTemplate whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to true.
Returns a reference to the desired stage template, or nullptr if fails.

template<class T, ManagedObjectAccess Access>
AbsObjAttrPtr esp::metadata::managers::AbstractObjectAttributesManager<T, Access>::loadAbstractObjectAttributesFromJson(AbsObjAttrPtr attributes, const io::JsonGenericValue& jsonDoc) protected

Populate an existing metadata::attributes::AbstractObjectAttributes from a JSON config. Also will populate render mesh and collision mesh handles with value(s) specified in JSON. If one is blank will use other for both.

Parameters
attributes the attributes to populate with
jsonDoc JSON document to parse
Returns an appropriately cast attributes pointer with base class fields filled in.

template<class T, ManagedObjectAccess Access>
std::string esp::metadata::managers::AbstractObjectAttributesManager<T, Access>::setJSONAssetHandleAndType(AbsObjAttrPtr attributes, const io::JsonGenericValue& jsonDoc, const char* jsonMeshTypeTag, const char* jsonMeshHandleTag, std::string& assetName, const std::function<void(int)>& meshTypeSetter) protected

Only used by esp::metadata::attributes::AbstractObjectAttributes derived-attributes. Set the asset type and mesh asset filename from json file. If mesh asset filename has changed in json, but type has not been specified in json, re-run file-path-driven configuration to get asset type and possibly orientation frame, if appropriate.

Parameters
attributes The AbstractObjectAttributes object to be populated
jsonDoc The json document
jsonMeshTypeTag The string tag denoting the desired mesh type in the json.
jsonMeshHandleTag The string for the mesh asset handle.
assetName [in/out] On entry this is old mesh handle, on exit is new mesh handle, or empty.
meshTypeSetter Function pointer to the appropriate mesh type setter in the Attributes object.
Returns Either the previously set asset handle or a new one based on what was read from JSON config document.

template<class T, ManagedObjectAccess Access>
void esp::metadata::managers::AbstractObjectAttributesManager<T, Access>::setDefaultAssetNameBasedAttributes(AbsObjAttrPtr attributes, bool setFrame, const std::string& assetName, const std::function<void(int)>& meshTypeSetter) pure virtual protected

Perform asset-name-based attributes initialization. This is to take the place of the AssetInfo::fromPath functionality, and is only intended to provide default values and other help if certain mistakes are made by the user, such as specifying an asset handle in json but not specifying the asset type corresponding to that handle. These settings should not restrict anything, only provide defaults.

Parameters
attributes The AbstractObjectAttributes object to be configured
setFrame whether the frame should be set or not (only for render assets in scenes)
assetName Mesh Handle to check.
meshTypeSetter Setter for mesh type.