esp::metadata::managers::AssetAttributesManager class

Base classes

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

Public static variables

static const std::map<PrimObjTypes, const char*> PrimitiveNames3DMap
Constant Map holding names of all Magnum 3D primitive classes supported, keyed by PrimObjTypes enum entry. Note final entry is not a valid primitive.

Constructors, destructors, conversion operators

AssetAttributesManager()

Public functions

auto createObject(const std::string& primClassName, bool registerTemplate = true) -> attributes::AbstractPrimitiveAttributes::ptr override
Should only be called internally. Creates an instance of a primtive asset attributes template described by passed string. For primitive assets this is the Magnum primitive class name.
auto buildObjectFromJSONDoc(const std::string& filename, const io::JsonGenericValue& jsonConfig) -> attributes::AbstractPrimitiveAttributes::ptr override
Parse passed JSON Document specifically for esp::metadata::attributes::AbstractPrimitiveAttributes object. It always returns a valid esp::metadata::attributes::AbstractPrimitiveAttributes shared_ptr object.
void setValsFromJSONDoc(AttribsPtr attribs, const io::JsonGenericValue& jsonConfig) override
Method to take an existing attributes and set its values from passed json config file.
auto createTemplateFromHandle(const std::string& templateHandle, bool registerTemplate = true) -> attributes::AbstractPrimitiveAttributes::ptr
Creates a template based on the provided template handle. Since the primitive asset attributes templates encode their structure in their handles, and these handles are not user editable, a properly configured handle can be used to build a template.
auto getOrCreateTemplateFromHandle(const std::string& templateHandle, bool registerTemplate = true) -> attributes::AbstractPrimitiveAttributes::cptr
Retrieves the template specified by the supplied handle, creating the template if none exists. Since the primitive asset attributes templates encode their structure in their handles, and these handles are not user editable, a properly configured handle can be used to build a template.
auto createObject(PrimObjTypes primObjType, bool registerTemplate = true) -> attributes::AbstractPrimitiveAttributes::ptr
Should only be called internally. Creates an instance of a primtive asset attributes template described by passed enum value. For primitive assets this mapes to the Magnum primitive class name.
auto getTemplateHandlesByPrimType(PrimObjTypes primType, bool contains = true) const -> std::vector<std::string>
Get list of primitive asset template handles used as keys in objectLibrary_ related to passed primitive descriptor enum.
auto getDefaultCapsuleTemplate(bool isWireFrame) -> attributes::CapsulePrimitiveAttributes::ptr
Return a copy of the default capsule template, either solid or wireframe.
auto getCapsuleTemplate(const std::string& templateHndle) -> attributes::CapsulePrimitiveAttributes::ptr
Return the specified capsule template.
auto getDefaultConeTemplate(bool isWireFrame) -> attributes::ConePrimitiveAttributes::ptr
Return the default cone template, either solid or wireframe.
auto getConeTemplate(const std::string& templateHndle) -> attributes::ConePrimitiveAttributes::ptr
Return the specified cone template, either solid or wireframe.
auto getDefaultCubeTemplate(bool isWireFrame) -> attributes::CubePrimitiveAttributes::ptr
Return the default cube template, either solid or wireframe.
auto getCubeTemplate(const std::string& templateHndle) -> attributes::CubePrimitiveAttributes::ptr
Return the specified cube template.
auto getDefaultCylinderTemplate(bool isWireFrame) -> attributes::CylinderPrimitiveAttributes::ptr
Return the default cylinder template, either solid or wireframe.
auto getCylinderTemplate(const std::string& templateHndle) -> attributes::CylinderPrimitiveAttributes::ptr
Return the specified cylinder template.
auto getDefaultIcosphereTemplate(bool isWireFrame) -> attributes::IcospherePrimitiveAttributes::ptr
Return the default icosphere template, either solid or wireframe.
auto getIcosphereTemplate(const std::string& templateHndle) -> attributes::IcospherePrimitiveAttributes::ptr
Return the specified icosphere template.
auto getDefaultUVSphereTemplate(bool isWireFrame) -> attributes::UVSpherePrimitiveAttributes::ptr
Return the default UVSphere template, either solid or wireframe.
auto getUVSphereTemplate(const std::string& templateHndle) -> attributes::UVSpherePrimitiveAttributes::ptr
Return the specified UVSphere template.
void setDefaultObject(attributes::AbstractPrimitiveAttributes::ptr& _defaultObj) override
Set the object to provide default values upon construction of esp::core::managedContainers::AbstractManagedObject. Override if object should not have defaults. Currently not supported for AbstractPrimitiveAttributes.
auto isValidPrimitiveAttributes(const std::string& handle) const -> bool
Check if currently configured primitive asset template library has passed handle.

Protected types

using Map_Of_PrimTypeCtors = std::unordered_map<std::string, attributes::AbstractPrimitiveAttributes::ptr(AssetAttributesManager::*)()>
Define a map type referencing function pointers to createPrimAttributes() keyed by string names of classes being instanced, as defined in PrimitiveNames3DMap.

Protected functions

void deleteObjectInternalFinalize(int templateID, const std::string& templateHandle) override
This method will perform any necessary updating that is attributesManager-specific upon template removal, such as removing a specific template handle from the list of file-based template handles in ObjectAttributesManager. This should only be called esp::core::managedContainers::ManagedContainerBase.
auto verifyTemplateHandle(const std::string& templateHandle, const std::string& attrType) -> bool
Verify that passed template handle describes attributes of type specified by passed primtive name (ie "cube", "capsule")
auto preRegisterObjectFinalize(attributes::AbstractPrimitiveAttributes::ptr attributesTemplate, const std::string& objectHandle, bool forceRegistration) -> core::managedContainers::ManagedObjectPreregistration override
This method will perform any essential updating to the managed object before registration is performed. If this updating fails, registration will also fail. Specifically, it will set the primitive attributes template's registration handle.
void postRegisterObjectHandling(int objectID, const std::string& objectHandle) override
Not required for this manager.
auto initNewObjectInternal(const std::string& primClassName, bool builtFromConfig) -> attributes::AbstractPrimitiveAttributes::ptr override
Used Internally. Create and configure newly-created attributes with any default values, before any specific values are set.
template<typename T, bool isWireFrame, PrimObjTypes primitiveType>
auto createPrimAttributes() -> attributes::AbstractPrimitiveAttributes::ptr
Build a shared pointer to the appropriate attributes for passed object type as defined in PrimObjTypes, where each entry except PrimObjTypes::END_PRIM_OBJ_TYPES corresponds to a Magnum Primitive type.
void resetFinalize() override
Any Assset-attributes-specific resetting that needs to happen on reset.

Protected variables

Map_Of_PrimTypeCtors primTypeConstructorMap_
Map of function pointers to instantiate a primitive attributes object, keyed by the Magnum primitive class name as listed in PrimitiveNames3DMap. A primitive attributes object is instanced by accessing the approrpiate function pointer.
std::unordered_map<std::string, std::string> defaultPrimAttributeHandles_
Map relating primitive class name to default attributes template handle. There should always be a template for each of these handles.

Function documentation

attributes::AbstractPrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::createObject(const std::string& primClassName, bool registerTemplate = true) override

Should only be called internally. Creates an instance of a primtive asset attributes template described by passed string. For primitive assets this is the Magnum primitive class name.

Parameters
primClassName A string descriptor of the primitive asset template to be created, corresponding to the Magnum Primitive class name.
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.

attributes::AbstractPrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::buildObjectFromJSONDoc(const std::string& filename, const io::JsonGenericValue& jsonConfig) override

Parse passed JSON Document specifically for esp::metadata::attributes::AbstractPrimitiveAttributes object. It always returns a valid esp::metadata::attributes::AbstractPrimitiveAttributes shared_ptr object.

Parameters
filename the name of the file describing the asset attributes, used to determine type of attributes template.
jsonConfig json document to parse
Returns a reference to the desired template.

TODO : currently do not support file-based Primitive Assets, so no actual JSON parsing.

void esp::metadata::managers::AssetAttributesManager::setValsFromJSONDoc(AttribsPtr attribs, const io::JsonGenericValue& jsonConfig) override

Method to take an existing attributes and set its values from passed json config file.

Parameters
attribs (out) an existing attributes to be modified.
jsonConfig json document to parse

attributes::AbstractPrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::createTemplateFromHandle(const std::string& templateHandle, bool registerTemplate = true)

Creates a template based on the provided template handle. Since the primitive asset attributes templates encode their structure in their handles, and these handles are not user editable, a properly configured handle can be used to build a template.

Parameters
templateHandle The template handle to use to create the attributes.
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 The attributes that most closely matches the given handle.

attributes::AbstractPrimitiveAttributes::cptr esp::metadata::managers::AssetAttributesManager::getOrCreateTemplateFromHandle(const std::string& templateHandle, bool registerTemplate = true)

Retrieves the template specified by the supplied handle, creating the template if none exists. Since the primitive asset attributes templates encode their structure in their handles, and these handles are not user editable, a properly configured handle can be used to build a template.

Parameters
templateHandle The template handle to use to create the attributes.
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 The attributes that most closely matches the given handle.

attributes::AbstractPrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::createObject(PrimObjTypes primObjType, bool registerTemplate = true)

Should only be called internally. Creates an instance of a primtive asset attributes template described by passed enum value. For primitive assets this mapes to the Magnum primitive class name.

Parameters
primObjType an enum value denoting the class of the primitive to instantiate
registerTemplate whether to add this template to the library or not. If the user is going to edit this template, this should be false.
Returns a reference to the desired template.

std::vector<std::string> esp::metadata::managers::AssetAttributesManager::getTemplateHandlesByPrimType(PrimObjTypes primType, bool contains = true) const

Get list of primitive asset template handles used as keys in objectLibrary_ related to passed primitive descriptor enum.

Parameters
primType Enum describing primitive type
contains whether to search for keys containing, or not containing, subStr
Returns list containing 0 or more string keys corresponding to templates in objectLibrary_ that contain the passed substring

attributes::CapsulePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getDefaultCapsuleTemplate(bool isWireFrame)

Return a copy of the default capsule template, either solid or wireframe.

Parameters
isWireFrame whether should be wireframe or solid template
Returns appropriately cast template

attributes::CapsulePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getCapsuleTemplate(const std::string& templateHndle)

Return the specified capsule template.

Parameters
templateHndle The handle of the desired capsule template. Verifies that handle is to specified template type
Returns appropriately cast template, or nullptr if template handle incorrectly specified.

attributes::ConePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getDefaultConeTemplate(bool isWireFrame)

Return the default cone template, either solid or wireframe.

Parameters
isWireFrame whether should be wireframe or solid template
Returns appropriately cast template

attributes::ConePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getConeTemplate(const std::string& templateHndle)

Return the specified cone template, either solid or wireframe.

Parameters
templateHndle The handle of the desired cone template. Verifies that handle is to specified template type
Returns appropriately cast template, or nullptr if template handle incorrectly specified.

attributes::CubePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getDefaultCubeTemplate(bool isWireFrame)

Return the default cube template, either solid or wireframe.

Parameters
isWireFrame whether should be wireframe or solid template
Returns appropriately cast template

attributes::CubePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getCubeTemplate(const std::string& templateHndle)

Return the specified cube template.

Parameters
templateHndle The handle of the desired cube template. Verifies that handle is to specified template type
Returns appropriately cast template, or nullptr if template handle incorrectly specified.

attributes::CylinderPrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getDefaultCylinderTemplate(bool isWireFrame)

Return the default cylinder template, either solid or wireframe.

Parameters
isWireFrame whether should be wireframe or solid template
Returns appropriately cast template

attributes::CylinderPrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getCylinderTemplate(const std::string& templateHndle)

Return the specified cylinder template.

Parameters
templateHndle The handle of the desired cylinder template. Verifies that handle is to specified template type
Returns appropriately cast template, or nullptr if template handle incorrectly specified.

attributes::IcospherePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getDefaultIcosphereTemplate(bool isWireFrame)

Return the default icosphere template, either solid or wireframe.

Parameters
isWireFrame whether should be wireframe or solid template
Returns appropriately cast template

attributes::IcospherePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getIcosphereTemplate(const std::string& templateHndle)

Return the specified icosphere template.

Parameters
templateHndle The handle of the desired icosphere template. Verifies that handle is to specified template type
Returns appropriately cast template, or nullptr if template handle incorrectly specified.

attributes::UVSpherePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getDefaultUVSphereTemplate(bool isWireFrame)

Return the default UVSphere template, either solid or wireframe.

Parameters
isWireFrame whether should be wireframe or solid template
Returns appropriately cast template

attributes::UVSpherePrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::getUVSphereTemplate(const std::string& templateHndle)

Return the specified UVSphere template.

Parameters
templateHndle The handle of the desired UVSphere template. Verifies that handle is to specified template type
Returns appropriately cast template, or nullptr if template handle incorrectly specified.

void esp::metadata::managers::AssetAttributesManager::setDefaultObject(attributes::AbstractPrimitiveAttributes::ptr& _defaultObj) override

Set the object to provide default values upon construction of esp::core::managedContainers::AbstractManagedObject. Override if object should not have defaults. Currently not supported for AbstractPrimitiveAttributes.

Parameters
_defaultObj the object to use for defaults;

bool esp::metadata::managers::AssetAttributesManager::isValidPrimitiveAttributes(const std::string& handle) const

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

void esp::metadata::managers::AssetAttributesManager::deleteObjectInternalFinalize(int templateID, const std::string& templateHandle) override protected

This method will perform any necessary updating that is attributesManager-specific upon template removal, such as removing a specific template handle from the list of file-based template handles in ObjectAttributesManager. This should only be called esp::core::managedContainers::ManagedContainerBase.

Parameters
templateID the ID of the template to remove
templateHandle the string key of the attributes desired.

bool esp::metadata::managers::AssetAttributesManager::verifyTemplateHandle(const std::string& templateHandle, const std::string& attrType) protected

Verify that passed template handle describes attributes of type specified by passed primtive name (ie "cube", "capsule")

Parameters
templateHandle The handle to test.
attrType Type of primitive the attributes owning templateHandle describe.
Returns If template handle describes template for objects of desired primitive class name

core::managedContainers::ManagedObjectPreregistration esp::metadata::managers::AssetAttributesManager::preRegisterObjectFinalize(attributes::AbstractPrimitiveAttributes::ptr attributesTemplate, const std::string& objectHandle, bool forceRegistration) override protected

This method will perform any essential updating to the managed object before registration is performed. If this updating fails, registration will also fail. Specifically, it will set the primitive attributes template's registration handle.

Parameters
attributesTemplate The attributes template.
objectHandle Not used for asset attributes templates - handle is derived by configuration.
forceRegistration Will register object even if conditional registration checks fail.
Returns Whether the preregistration has succeeded and what handle to use to register the object if it has.

void esp::metadata::managers::AssetAttributesManager::postRegisterObjectHandling(int objectID, const std::string& objectHandle) override protected

Not required for this manager.

Parameters
objectID the ID of the successfully registered managed object
objectHandle The name of the managed objbect

This method will perform any final manager-related handling after successfully registering an object.

See esp::attributes::managers::ObjectAttributesManager for an example.

attributes::AbstractPrimitiveAttributes::ptr esp::metadata::managers::AssetAttributesManager::initNewObjectInternal(const std::string& primClassName, bool builtFromConfig) override protected

Used Internally. Create and configure newly-created attributes with any default values, before any specific values are set.

Parameters
primClassName Primitive Magnum class name.
builtFromConfig Whether this Primitive Asset Attributes object is being created from a config file (i.e. a json file) or from some other source.
Returns newAttributes Newly created attributes.