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 AbstractAttributesManager<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.
void setAssetAttributesManager(AssetAttributesManager::cptr assetAttributesMgr)
Set a reference to the current metadata::managers::AssetAttributesManager to use for primitive-based stages and objects. Also build any default object or stage attributes referencing primitives as render assets.
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 parseMarkerSets(const AbsObjAttrPtr& attribs, const io::JsonGenericValue& jsonConfig) const -> bool
Parse Marker_sets object in json, if present.
auto setAbstractObjectAttributesFromJson(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.
void createDefaultPrimBasedAttributesTemplates() pure virtual
Create and save default primitive asset-based object templates, saving their handles as non-deletable default handles.
auto isValidPrimitiveAttributes(const std::string& handle) const -> bool
Check if currently configured primitive asset template library has passed handle.
auto setJSONAssetHandleAndType(AbsObjAttrPtr attributes, const io::JsonGenericValue& jsonDoc, const char* jsonMeshTypeTag, const char* jsonMeshHandleTag, std::string& assetName, const std::function<void(AssetType)>& 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(AssetType)>& assetTypeSetter) 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.

Protected variables

AssetAttributesManager::cptr assetAttributesMgr_
Reference to AssetAttributesManager to give access to primitive attributes for object construction.

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>
bool esp::metadata::managers::AbstractObjectAttributesManager<T, Access>::parseMarkerSets(const AbsObjAttrPtr& attribs, const io::JsonGenericValue& jsonConfig) const protected

Parse Marker_sets object in json, if present.

Parameters
attribs (out) an existing attributes to be modified.
jsonConfig json document to parse
Returns true if tag is found, of appropriate configuration, and holds actual values.

template<class T, ManagedObjectAccess Access>
AbsObjAttrPtr esp::metadata::managers::AbstractObjectAttributesManager<T, Access>::setAbstractObjectAttributesFromJson(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>
bool esp::metadata::managers::AbstractObjectAttributesManager<T, Access>::isValidPrimitiveAttributes(const std::string& handle) const protected

Check if currently configured primitive asset template library has passed handle.

Parameters
handle String name of primitive asset attributes desired
Returns whether handle exists or not in asset attributes library

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(AssetType)>& 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(AssetType)>& assetTypeSetter) 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.
assetTypeSetter