template<class AttribsPtr>
esp::assets::managers::AttributesManager class

Template Class defining responsibilities for managing attributes for different types of objects, such as scenes, primitive assets, physical objects, etc.

Template parameters
AttribsPtr the type of attributes shared pointer object this class references

Constructors, destructors, conversion operators

AttributesManager(assets::ResourceManager& resourceManager, const std::string& attrType)
~AttributesManager() defaulted virtual

Public functions

auto createAttributesTemplate(const std::string& attributesTemplateHandle, bool registerTemplate = true) -> AttribsPtr pure virtual
Creates an instance of a template described by passed string. For physical objects, this is either a file name or a reference to a primitive template used in the construction of the object. For primitive assets, this is the class name used to construct the underlying primitive.
auto createDefaultAttributesTemplate(const std::string& templateName, bool registerTemplate = false) -> AttribsPtr pure virtual
Creates an instance of a template holding default values.
auto registerAttributesTemplate(AttribsPtr attributesTemplate, const std::string& attributesTemplateHandle = "") -> int
Add a copy of AbstractAttributes object to the templateLibrary_.
auto registerAttributesTemplateAndUpdate(AttribsPtr attributesTemplate) -> int
Register template and call appropriate ResourceManager method to execute appropriate post-registration processes due to change in attributes. Use if user wishes to update existing objects built by attributes with new attributes data and such objects support this kind of update. Requires the use of Attributes' assigned handle in order to reference existing constructions built from the original version of this attributes.
void reset()
clears maps of handle-keyed attributes and ID-keyed handles.
auto isValidFileName(const std::string& handle) const -> bool
Utility function to check if passed string represents an existing, user-accessible file.
auto setTemplateLock(const std::string& templateHandle, bool lock) -> bool
Sets/Clears lock state for a template, preventing or allowing deletion of template.
auto setTemplateLockByHandles(const std::vector<std::string>& templateHandles, bool lock) -> std::vector<std::string>
Sets/Clears lock state for a template, preventing or allowing deletion of template.
auto setTemplatesLockBySubstring(bool lock, const std::string& subStr = "", bool contains = true) -> std::vector<std::string>
set lock state on all templates that contain passed substring.
auto getNumTemplates() const -> int
Gets the number of object templates stored in the templateLibrary_.
auto getTemplateLibHasHandle(const std::string& handle) const -> bool
Checks whether template library has passed string handle as key.
auto getTemplateByID(int attributesTemplateID) const -> AttribsPtr
Get a reference to the attributes template identified by the attributesTemplateID. Should only be used internally. Users should only ever access copies of templates.
auto getTemplateByHandle(const std::string& templateHandle) const -> AttribsPtr
Get a reference to the attributes template for the asset identified by the passed templateHandle. Should only be used internally. Users should only ever access copies of templates.
auto removeTemplateByID(int attributesTemplateID) -> AttribsPtr
Remove the template referenced by the passed string handle. Will emplace template ID within deque of usable IDs and return the template being removed.
auto removeTemplateByHandle(const std::string& templateHandle) -> AttribsPtr
Remove the template referenced by the passed string handle. Will emplace template ID within deque of usable IDs and return the template being removed.
auto removeAllTemplates() -> std::vector<AttribsPtr>
Remove all templates that have not been marked as default/non-removable, and return a vector of the templates removed.
auto removeTemplatesBySubstring(const std::string& subStr = "", bool contains = true) -> std::vector<AttribsPtr>
remove templates that contain passed substring and that have not been marked as default/non-removable, and return a vector of the templates removed.
auto getTemplateHandleByID(const int templateID) const -> std::string
Get the key in templateLibrary_ for the object template with the given unique ID.
auto getTemplateIDByHandle(const std::string& templateHandle) -> int
Get the ID of the template in templateLibrary_ for the given template Handle, if exists.
auto getTemplateHandlesBySubstring(const std::string& subStr = "", bool contains = true) const -> std::vector<std::string>
Get a list of all templates whose origin handles contain subStr, ignoring subStr's case.
auto getRandomTemplateHandle() const -> std::string
Get the handle for a random attributes template registered to this manager.
auto getTemplateCopyByID(int attributesTemplateID) -> AttribsPtr
Get a copy of the attributes template identified by the attributesTemplateID.
auto getTemplateCopyByHandle(const std::string& templateHandle) -> AttribsPtr
Return a reference to a copy of the object specified by passed handle. This is the version that should be accessed by the user.
template<class U>
auto getTemplateCopyByID(int attributesTemplateID) -> std::shared_ptr<U>
Get a copy of the attributes template identified by the attributesTemplateID, casted to the appropriate derived asset attributes class.
template<class U>
auto getTemplateCopyByHandle(const std::string& templateHandle) -> std::shared_ptr<U>
Return a reference to a copy of the object specified by passed handle, casted to the appropriate derived asset attributes class This is the version that should be accessed by the user.
auto getUndeletableTemplateHandles() const -> std::vector<std::string>
returns a vector of template handles representing the system-specified undeletable templates this manager manages. These templates cannot be deleted, although they can be edited.
auto getUserLockedTemplateHandles() const -> std::vector<std::string>
returns a vector of template handles representing templates that have been locked by the user. These templates cannot be deleted until they have been unlocked, although they can be edited while locked.

Protected types

using Map_Of_CopyCtors = std::map<std::string, AttribsPtr(AttributesManager<AttribsPtr>::*)(AttribsPtr&)>
Define a map type referencing function pointers to createAttributesCopy keyed by string names of classes being instanced, (for asset attributes these are the names of of classes being instanced defined in AssetAttributesManager::PrimNames3D.)

Protected functions

auto verifyLoadJson(const std::string& filename, io::JsonDocument& jsonDoc) -> bool
Verify passed filename is legal json document, return loaded document or nullptr if fails.
template<typename U>
auto createPhysicsAttributesFromJson(const std::string& filename, const io::JsonDocument& jsonDoc) -> AttribsPtr
Create either an object or a scene attributes from a json config. Since both object attributes and scene attributes inherit from AbstractPhysicsAttributes, the functionality to populate these fields from json can be shared. Also will will populate render mesh and collision mesh handles in object and scene attributes with value(s) specified in json. If one is blank will use other for both.
auto setJSONAssetHandleAndType(AttribsPtr attributes, const io::JsonDocument& jsonDoc, const char* jsonMeshTypeTag, const char* jsonMeshHandleTag, std::string& fileName, std::function<void(int)> meshTypeSetter) -> bool
Only used by AbstractPhysicsAttributes 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.
auto postCreateRegister(AttribsPtr attributes, bool registerTemplate) -> AttribsPtr
Perform post creation registration if specified.
void setDefaultFileNameBasedAttributes(AttribsPtr attributes, bool setFrame, const std::string& fileName, std::function<void(int)> meshTypeSetter) pure virtual
Perform file-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.
void setFileDirectoryFromHandle(AttribsPtr attributes)
Get directory component of attributes handle and call attributes->setFileDirectory legitimate directory exists in handle.
auto initNewAttribsInternal(AttribsPtr newAttributes) -> AttribsPtr pure virtual
Used Internally. Configure newly-created attributes with any default values, before any specific values are set.
auto removeTemplateInternal(const std::string& templateHandle, const std::string& src) -> AttribsPtr
Used Internally. Remove the template referenced by the passed string handle. Will emplace template ID within deque of usable IDs and return the template being removed.
void updateTemplateHandleLists(int templateID, const std::string& templateHandle) pure virtual
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 internally.
auto getTemplateIDByHandleOrNew(const std::string& templateHandle, bool getNext) -> int
Used Internally. Get the ID of the template in templateLibrary_ for the given template Handle, if exists. If the template is not in the library and getNext is true then returns next available id, otherwise throws assertion and returns ID_UNDEFINED.
auto registerAttributesTemplateFinalize(AttribsPtr attributesTemplate, const std::string& attributesTemplateHandle) -> int pure virtual
implementation of attributes type-specific registration
auto checkExistsWithMessage(const std::string& templateHandle, const std::string& src) const -> bool
Used Internally. Checks if template handle exists in map; if not prints an error message, returns false; Otherwise returns true;.
void resetFinalize() pure virtual
Any implementation-specific resetting that needs to happen on reset.
template<typename U>
auto createAttributesCopy(AttribsPtr& orig) -> AttribsPtr
Build a shared pointer to the appropriate attributes for passed object type.
void buildCtorFuncPtrMaps() pure virtual
This function will build the appropriate function pointer map for this object's attributes, keyed on its attributes' class type.
auto copyAttributes(AttribsPtr& origAttr) -> AttribsPtr
Build an Attributes object of type associated with passed object.
auto addTemplateToLibrary(AttribsPtr attributesTemplate, const std::string& attributesHandle) -> int
add passed template to library, setting attributesTemplateID appropriately. Called internally by registerTemplate.
auto getRandomTemplateHandlePerType(const std::map<int, std::string>& mapOfHandles, const std::string& type) const -> std::string
Return a random handle selected from the passed map.
auto getTemplateHandlesBySubStringPerType(const std::map<int, std::string>& mapOfHandles, const std::string& subStr, bool contains) const -> std::vector<std::string>
Get a list of all templates of passed type whose origin handles contain subStr, ignoring subStr's case.

Protected variables

Map_Of_CopyCtors copyConstructorMap_
Map of function pointers to instantiate a primitive attributes object, keyed by the Magnum primitive class name as listed in PrimNames3D. A primitive attributes object is instanced by accessing the approrpiate function pointer.
assets::ResourceManager& resourceManager_
A reference to a esp::assets::ResourceManager which holds assets that can be accessed by this PhysicsManager.
const std::string attrType_
A descriptive name of the attributes being managed by this manager.
std::map<std::string, AttribsPtr> templateLibrary_
Maps string keys to attributes templates.
std::map<int, std::string> templateLibKeyByID_
Maps all object attribute IDs to the appropriate handles used by lib.
std::deque<int> availableTemplateIDs_
Deque holding all IDs of deleted objects. These ID's should be recycled before using map-size-based IDs.
std::set<std::string> undeletableTemplateNames_
set holding string template handles of all system-locked templates, to make sure they are never deleted. Should not be overridden by user.
std::set<std::string> userLockedTemplateNames_
set holding string template handles of all user-locked templates, to make sure they are not deleted unless the user unlocks them.

Function documentation

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::createAttributesTemplate(const std::string& attributesTemplateHandle, bool registerTemplate = true) pure virtual

Creates an instance of a template described by passed string. For physical objects, this is either a file name or a reference to a primitive template used in the construction of the object. For primitive assets, this is the class name used to construct the underlying primitive.

Parameters
attributesTemplateHandle the origin of the desired template to be created, either a file name or an existing primitive asset template. If is not an origin handle to an existing primitive, assumes is file name.
registerTemplate whether to add this template to the library or not. If the user is going to edit this template, this should be false. 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, the existing template will be overwritten with the newly created one if registerTemplate is true.

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::createDefaultAttributesTemplate(const std::string& templateName, bool registerTemplate = false) pure virtual

Creates an instance of a template holding default values.

Parameters
templateName The desired handle for this template.
registerTemplate whether to add this template to the library or not. If the user is going to edit this template, this should be false. If specified as true, then this function returns a copy of the registered template. Defaults to false. 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, the existing template will be overwritten with the newly created one if registerTemplate is true. This method is specifically intended to directly construct an attributes template for editing, and so defaults to false for registerTemplate

template<class AttribsPtr>
int esp::assets::managers::AttributesManager<AttribsPtr>::registerAttributesTemplate(AttribsPtr attributesTemplate, const std::string& attributesTemplateHandle = "")

Add a copy of AbstractAttributes object to the templateLibrary_.

Parameters
attributesTemplate The attributes template.
attributesTemplateHandle The key for referencing the template in the templateLibrary_. Will be set as origin handle for template. If empty string, use existing origin handle.
Returns The unique ID of the template being registered, or ID_UNDEFINED if failed

template<class AttribsPtr>
int esp::assets::managers::AttributesManager<AttribsPtr>::registerAttributesTemplateAndUpdate(AttribsPtr attributesTemplate)

Register template and call appropriate ResourceManager method to execute appropriate post-registration processes due to change in attributes. Use if user wishes to update existing objects built by attributes with new attributes data and such objects support this kind of update. Requires the use of Attributes' assigned handle in order to reference existing constructions built from the original version of this attributes.

Parameters
attributesTemplate The attributes template.
Returns The unique ID of the template being registered, or ID_UNDEFINED if failed

template<class AttribsPtr>
bool esp::assets::managers::AttributesManager<AttribsPtr>::isValidFileName(const std::string& handle) const

Utility function to check if passed string represents an existing, user-accessible file.

Parameters
handle the string to check
Returns whether the file exists in the file system and whether the user has access

template<class AttribsPtr>
bool esp::assets::managers::AttributesManager<AttribsPtr>::setTemplateLock(const std::string& templateHandle, bool lock)

Sets/Clears lock state for a template, preventing or allowing deletion of template.

Parameters
templateHandle handle of template to set state of
lock boolean to set or clear lock
Returns whether successful or not.

template<class AttribsPtr>
std::vector<std::string> esp::assets::managers::AttributesManager<AttribsPtr>::setTemplateLockByHandles(const std::vector<std::string>& templateHandles, bool lock)

Sets/Clears lock state for a template, preventing or allowing deletion of template.

Parameters
templateHandles Vector of handles of templates to set state of
lock boolean to set or clear lock for all templates
Returns the list of handles actually set to desired lock state.

template<class AttribsPtr>
std::vector<std::string> esp::assets::managers::AttributesManager<AttribsPtr>::setTemplatesLockBySubstring(bool lock, const std::string& subStr = "", bool contains = true)

set lock state on all templates that contain passed substring.

Parameters
lock boolean to set or clear lock on templates
subStr substring to search for within existing primitive object templates
contains whether to search for keys containing, or excluding, subStr
Returns A vector containing the template handles of templates whose lock state has been set to passed state.

template<class AttribsPtr>
int esp::assets::managers::AttributesManager<AttribsPtr>::getNumTemplates() const

Gets the number of object templates stored in the templateLibrary_.

Returns The size of the templateLibrary_.

template<class AttribsPtr>
bool esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateLibHasHandle(const std::string& handle) const

Checks whether template library has passed string handle as key.

Parameters
handle the key to look for

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateByID(int attributesTemplateID) const

Get a reference to the attributes template identified by the attributesTemplateID. Should only be used internally. Users should only ever access copies of templates.

Parameters
attributesTemplateID The ID of the template. Is mapped to the key referencing the asset in templateLibrary_ by templateLibKeyByID_.
Returns A mutable reference to the object template, or nullptr if does not exist

Can be used to manipulate a template before instancing new objects.

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateByHandle(const std::string& templateHandle) const

Get a reference to the attributes template for the asset identified by the passed templateHandle. Should only be used internally. Users should only ever access copies of templates.

Parameters
templateHandle The key referencing the asset in templateLibrary_.
Returns A reference to the object template, or nullptr if does not exist

Can be used to manipulate a template before instancing new objects.

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::removeTemplateByID(int attributesTemplateID)

Remove the template referenced by the passed string handle. Will emplace template ID within deque of usable IDs and return the template being removed.

Returns the desired attributes being deleted, or nullptr if does not exist

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::removeTemplateByHandle(const std::string& templateHandle)

Remove the template referenced by the passed string handle. Will emplace template ID within deque of usable IDs and return the template being removed.

Parameters
templateHandle the string key of the attributes desired.
Returns the desired attributes being deleted, or nullptr if does not exist

template<class AttribsPtr>
std::vector<AttribsPtr> esp::assets::managers::AttributesManager<AttribsPtr>::removeAllTemplates()

Remove all templates that have not been marked as default/non-removable, and return a vector of the templates removed.

Returns A vector containing all the templates that have been removed from the library.

template<class AttribsPtr>
std::vector<AttribsPtr> esp::assets::managers::AttributesManager<AttribsPtr>::removeTemplatesBySubstring(const std::string& subStr = "", bool contains = true)

remove templates that contain passed substring and that have not been marked as default/non-removable, and return a vector of the templates removed.

Parameters
subStr substring to search for within existing primitive object templates
contains whether to search for keys containing, or excluding, subStr
Returns A vector containing all the templates that have been removed from the library.

template<class AttribsPtr>
std::string esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateHandleByID(const int templateID) const

Get the key in templateLibrary_ for the object template with the given unique ID.

Parameters
templateID The unique ID of the desired template.
Returns The key referencing the template in templateLibrary_, or nullptr if does not exist.

template<class AttribsPtr>
int esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateIDByHandle(const std::string& templateHandle)

Get the ID of the template in templateLibrary_ for the given template Handle, if exists.

Parameters
templateHandle The string key referencing the template in templateLibrary_. Usually the origin handle.
Returns The object ID for the template with the passed handle, or ID_UNDEFINED if none exists.

template<class AttribsPtr>
std::vector<std::string> esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateHandlesBySubstring(const std::string& subStr = "", bool contains = true) const

Get a list of all templates whose origin handles contain subStr, ignoring subStr's case.

Parameters
subStr substring to search for within existing templates.
contains whether to search for keys containing, or excluding, passed subStr
Returns vector of 0 or more template handles containing the passed substring

template<class AttribsPtr>
std::string esp::assets::managers::AttributesManager<AttribsPtr>::getRandomTemplateHandle() const

Get the handle for a random attributes template registered to this manager.

Returns a randomly selected handle corresponding to a known object attributes template, or empty string if none found

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateCopyByID(int attributesTemplateID)

Get a copy of the attributes template identified by the attributesTemplateID.

Parameters
attributesTemplateID The ID of the template. Is mapped to the key referencing the asset in templateLibrary_ by templateLibKeyByID_.
Returns A mutable reference to the object template, or nullptr if does not exist

Can be used to manipulate a template before instancing new objects.

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateCopyByHandle(const std::string& templateHandle)

Return a reference to a copy of the object specified by passed handle. This is the version that should be accessed by the user.

Parameters
templateHandle the string key of the attributes desired.
Returns a copy of the desired attributes, or nullptr if does not exist

template<class AttribsPtr> template<class U>
std::shared_ptr<U> esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateCopyByID(int attributesTemplateID)

Get a copy of the attributes template identified by the attributesTemplateID, casted to the appropriate derived asset attributes class.

Parameters
attributesTemplateID The ID of the template. Is mapped to the key referencing the asset in templateLibrary_ by templateLibKeyByID_.
Returns A mutable reference to the object template, or nullptr if does not exist

Can be used to manipulate a template before instancing new objects.

template<class AttribsPtr> template<class U>
std::shared_ptr<U> esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateCopyByHandle(const std::string& templateHandle)

Return a reference to a copy of the object specified by passed handle, casted to the appropriate derived asset attributes class This is the version that should be accessed by the user.

Parameters
templateHandle the string key of the attributes desired.
Returns a copy of the desired attributes, or nullptr if does not exist

template<class AttribsPtr>
bool esp::assets::managers::AttributesManager<AttribsPtr>::verifyLoadJson(const std::string& filename, io::JsonDocument& jsonDoc) protected

Verify passed filename is legal json document, return loaded document or nullptr if fails.

Parameters
filename name of potential json document to load
jsonDoc a reference to the json document to be parsed
Returns whether document has been loaded successfully or not

template<class AttribsPtr> template<typename U>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::createPhysicsAttributesFromJson(const std::string& filename, const io::JsonDocument& jsonDoc) protected

Create either an object or a scene attributes from a json config. Since both object attributes and scene attributes inherit from AbstractPhysicsAttributes, the functionality to populate these fields from json can be shared. Also will will populate render mesh and collision mesh handles in object and scene attributes with value(s) specified in json. If one is blank will use other for both.

Parameters
filename name of json descriptor file
jsonDoc json document to parse
Returns an appropriately cast attributes pointer with base class fields filled in.

template<class AttribsPtr>
bool esp::assets::managers::AttributesManager<AttribsPtr>::setJSONAssetHandleAndType(AttribsPtr attributes, const io::JsonDocument& jsonDoc, const char* jsonMeshTypeTag, const char* jsonMeshHandleTag, std::string& fileName, std::function<void(int)> meshTypeSetter) protected

Only used by AbstractPhysicsAttributes 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 AbstractPhysicsAttributes 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.
fileName [in/out] On entry this is old mesh file handle, on exit is new mesh file handle, or empty.
meshTypeSetter Function pointer to the appropriate mesh type setter in the Attributes object.
Returns Whether the render asset name was specified in the json and should be set from fileName variable.

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::postCreateRegister(AttribsPtr attributes, bool registerTemplate) protected

Perform post creation registration if specified.

Parameters
attributes Attributes template
registerTemplate If template should be registered
Returns attributes template, or null ptr if registration failed.

template<class AttribsPtr>
void esp::assets::managers::AttributesManager<AttribsPtr>::setDefaultFileNameBasedAttributes(AttribsPtr attributes, bool setFrame, const std::string& fileName, std::function<void(int)> meshTypeSetter) pure virtual protected

Perform file-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 AbstractPhysicsAttributes object to be configured
setFrame whether the frame should be set or not (only for render assets in scenes)
fileName Mesh Handle to check.
meshTypeSetter Setter for mesh type.

template<class AttribsPtr>
void esp::assets::managers::AttributesManager<AttribsPtr>::setFileDirectoryFromHandle(AttribsPtr attributes) protected

Get directory component of attributes handle and call attributes->setFileDirectory legitimate directory exists in handle.

Parameters
attributes pointer to attributes to set

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::initNewAttribsInternal(AttribsPtr newAttributes) pure virtual protected

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

Parameters
newAttributes Newly created attributes.

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::removeTemplateInternal(const std::string& templateHandle, const std::string& src) protected

Used Internally. Remove the template referenced by the passed string handle. Will emplace template ID within deque of usable IDs and return the template being removed.

Parameters
templateHandle the string key of the attributes desired.
src String denoting the source of the remove request.
Returns the desired attributes being deleted, or nullptr if does not exist

template<class AttribsPtr>
void esp::assets::managers::AttributesManager<AttribsPtr>::updateTemplateHandleLists(int templateID, const std::string& templateHandle) pure virtual 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 internally.

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

template<class AttribsPtr>
int esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateIDByHandleOrNew(const std::string& templateHandle, bool getNext) protected

Used Internally. Get the ID of the template in templateLibrary_ for the given template Handle, if exists. If the template is not in the library and getNext is true then returns next available id, otherwise throws assertion and returns ID_UNDEFINED.

Parameters
templateHandle The string key referencing the template in templateLibrary_. Usually the origin handle.
getNext Whether to get the next available ID if not found, or to throw an assertion. Defaults to false
Returns The template's ID if found. The next available ID if not found and getNext is true. Otherwise ID_UNDEFINED.

template<class AttribsPtr>
int esp::assets::managers::AttributesManager<AttribsPtr>::registerAttributesTemplateFinalize(AttribsPtr attributesTemplate, const std::string& attributesTemplateHandle) pure virtual protected

implementation of attributes type-specific registration

Parameters
attributesTemplate the attributes template to be registered
attributesTemplateHandle the name to register the template with. Expected to be valid.
Returns The unique ID of the template being registered, or ID_UNDEFINED if failed

template<class AttribsPtr> template<typename U>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::createAttributesCopy(AttribsPtr& orig) protected

Build a shared pointer to the appropriate attributes for passed object type.

Parameters
orig original object of type AttribsPtr being copied

template<class AttribsPtr>
AttribsPtr esp::assets::managers::AttributesManager<AttribsPtr>::copyAttributes(AttribsPtr& origAttr) protected

Build an Attributes object of type associated with passed object.

Parameters
origAttr The original attributes object to copy

template<class AttribsPtr>
int esp::assets::managers::AttributesManager<AttribsPtr>::addTemplateToLibrary(AttribsPtr attributesTemplate, const std::string& attributesHandle) protected

add passed template to library, setting attributesTemplateID appropriately. Called internally by registerTemplate.

Parameters
attributesTemplate the template to add to the library
attributesHandle the origin handle/name of the template to add. The origin handle of the attributes template will be set to this here, in case attributes is constructed with a different handle.
Returns the attributesTemplateID of the template

template<class AttribsPtr>
std::string esp::assets::managers::AttributesManager<AttribsPtr>::getRandomTemplateHandlePerType(const std::map<int, std::string>& mapOfHandles, const std::string& type) const protected

Return a random handle selected from the passed map.

Parameters
mapOfHandles map containing the desired attribute-type template handles
type the type of attributes being retrieved, for debug message
Returns a random template handle of the chosen type, or the empty string if none loaded

template<class AttribsPtr>
std::vector<std::string> esp::assets::managers::AttributesManager<AttribsPtr>::getTemplateHandlesBySubStringPerType(const std::map<int, std::string>& mapOfHandles, const std::string& subStr, bool contains) const protected

Get a list of all templates of passed type whose origin handles contain subStr, ignoring subStr's case.

Parameters
mapOfHandles map containing the desired object-type template handles
subStr substring to search for within existing primitive object templates
contains Whether to search for handles containing, or not containting, subStr
Returns vector of 0 or more template handles containing/not containing the passed substring