template<class T, ManagedObjectAccess Access>
AbstractAttributesManager class
Class template defining responsibilities and functionality for managing esp::
Template parameters | |
---|---|
T | the type of managed attributes a particular specialization of this class works with. Must inherit from esp:: |
Access | Whether the default access (getters) for this container provides copies of the objects held, or the actual objects themselves. |
Base classes
-
template<class T, ManagedObjectAccess Access>class esp::core::managedContainers::ManagedFileBasedContainer<T, Access>
- Class template defining file-io-based responsibilities and functionality for managing esp::
core:: managedContainers:: AbstractFileBasedManagedObject constructs.
Derived classes
-
template<class T, ManagedObjectAccess Access>class AbstractObjectAttributesManager
- Class template defining responsibilities and functionality for managing esp::
metadata:: attributes:: AbstractObjectAttributes constructs. -
template<class T, ManagedObjectAccess Access>class AbstractObjectAttributesManager
- Class template defining responsibilities and functionality for managing esp::
metadata:: attributes:: AbstractObjectAttributes constructs. -
template<class T, ManagedObjectAccess Access>class AbstractObjectAttributesManager
- Class template defining responsibilities and functionality for managing esp::
metadata:: attributes:: AbstractObjectAttributes constructs.
Public types
-
using AttribsPtr = std::
shared_ptr<T>
Constructors, destructors, conversion operators
-
AbstractAttributesManager(const std::
string& attrType, const std:: string& JSONTypeExt) - Construct an attributes manager to manage shared pointers of attributes of type T.
- ~AbstractAttributesManager() defaulted override
Public functions
-
auto loadAllFileBasedTemplates(const std::
vector<std:: string>& tmpltFilenames, bool saveAsDefaults) -> std:: vector<int> - Load all file-based templates given string list of template file locations.
-
auto loadAllJSONConfigsFromPath(const std::
string& path, bool saveAsDefaults = false) -> std:: vector<int> - Load file-based templates for all JSONTypeExt_
files from the provided file or directory path. -
auto loadAllTemplatesFromPathAndExt(const std::
string& path, const std:: string& extType, bool saveAsDefaults = false) -> std:: vector<int> - Load file-based templates for all
extType
files from the provided file or directory path. -
void buildJSONCfgPathsFromJSONAndLoad(const std::
string& configDir, const io::JsonGenericValue& jsonPaths) - This builds a list of paths to this type of attributes's JSON Config files from the passed
jsonPaths
array element. It then will load all the configs it finds at each path. -
void buildAttrSrcPathsFromJSONAndLoad(const std::
string& configDir, const std:: string& extType, const io::JsonGenericValue& jsonPaths) - This builds a list of paths to the
extType
files to use to construct templates derived from the passedjsonPaths
array element. It then will load all the configs it finds at each path. -
auto buildObjectFromJSONDoc(const std::
string& templateName, const io::JsonGenericValue& jsonConfig) -> AttribsPtr override - Parse passed JSON Document for esp::
metadata:: attributes:: AbstractAttributes. It always returns a valid esp:: metadata:: attributes:: AbstractAttributes shared pointer. - void setValsFromJSONDoc(AttribsPtr attribs, const io::JsonGenericValue& jsonConfig) pure virtual
- Method to take an existing attributes and set its values from passed json config file.
- auto parseUserDefinedJsonVals(const attributes::AbstractAttributes::ptr& attribs, const io::JsonGenericValue& jsonConfig) const -> bool
- This function takes the json block specifying user-defined values and parses it into the passed existing attributes.
-
auto parseSubconfigJsonVals(const std::
string& subGroupName, const attributes::AbstractAttributes::ptr& attribs, const io::JsonGenericValue& jsonConfig) const -> bool - This function takes the passed json block
jsonConfig
, looks forsubGroupName
, and if found in json document and referencing an appropriately formatted object, will load the found values into a subconfig, keyed bysubGroupName
, placed intoattribs
' subconfig tree. -
auto getFullAttrNameFromStr(const std::
string& attrName) const -> std:: string - Returns actual attributes handle containing
attrName
as a substring, or the empty string if none exists. Does a substring search, and returns first value found. - void finalizeAttrPathsBeforeRegister(const AttribsPtr& attributes) const pure virtual
- This function will be called to finalize attributes' paths before registration, moving fully qualified paths to the appropriate hidden attribute fields. This can also be called without registration to make sure the paths specified in an attributes are properly configured.
Protected functions
-
void filterAttribsFilenames(const AttribsPtr& attributes,
const std::
string& curRelPathName, const std:: string& curFQPathName, const std:: function<void(const std:: string&)>& relPathSetter, const std:: function<void(const std:: string&)>& fqPathSetter) const - Called internally right before attribute registration. Filepaths in the json configs for Habitat SceneDatasets are specified relative to the location of the config in the file hierarchy. As the config is loaded, these filepaths will be fully qualified with absolute paths so that they can be easily found and consumed on command. However, saving fully qualified filepaths to JSON configs is undesirable.
-
auto createFromJsonOrDefaultInternal(const std::
string& filename, std:: string& msg, bool registerObj) -> AttribsPtr - Called intenrally from createObject. This will create either a file based AbstractAttributes or a default one based on whether the passed file name exists and has appropriate string tag/extension for esp::
metadata:: attributes:: AbstractAttributes. -
template<class M>void setEnumStringFromJsonDoc(const io::JsonGenericValue& jsonConfig, const char* jsonTag, const std::
string& mapName, bool saveUnspecified, const std:: map<std:: string, M>& mapToUse, const std:: function<void(const std:: string&)>& valueSetter) - This function is accessed by various attributes managers during loading. It provides a generic handler to look for a particular
jsonTag
in the givenjsonConfig
document, and if it is present it will attempt to find the value in the passed string-keyedmapToUse
of enum config values. If the string is present it will return the string, otherwise it will return an empty string. The consumer of the function is responsible for only setting a config value if the string is not empty. The enum class should have the first value defined as Unspecified and given the value ID_UNDEFINED. -
auto setFilenameFromDefaultTag(const AttribsPtr& attributes,
const std::
string& srcAssetFilename, const std:: function<void(const std:: string&)>& filenameSetter) -> bool - Set a filename attribute to hold the appropriate data if the existing attribute's given path contains the sentinel tag value defined at esp::
metadata:: CONFIG_NAME_AS_ASSET_FILENAME. This will be specified in the Scene Dataset configuration file in the "default_attributes" tag for any attributes which consume file names to specify that the name specified as the instanced attributes should also be used to build the name of the specified asset. The tag value will be replaced by the attributes object's simplified handle, or if unable to be found, with an empty string. -
auto setAttributesHandleFromDefaultTag(const AttribsPtr& attributes,
const std::
string& srcAssetHandle, const std:: function<void(const std:: string&)>& handleSetter) -> bool - Set an attribute that holds another attribute's handle to hold the appropriate data if the existing attribute's given path contains the sentinel tag value defined at esp::
metadata:: CONFIG_NAME_AS_ASSET_FILENAME. This will be used in the Scene Dataset configuration file in the "default_attributes" tag for any attributes which consume attributes handle names to specify that the name given as the instanced attributes should also be used to build the name of the specified asset's handle. The tag value will be replaced by the attributes object's simplified handle.
Function documentation
template<class T, ManagedObjectAccess Access>
esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: AbstractAttributesManager(const std:: string& attrType,
const std:: string& JSONTypeExt)
Construct an attributes manager to manage shared pointers of attributes of type T.
Parameters | |
---|---|
attrType | A string describing the type of attributes, for |
JSONTypeExt | The attributes JSON file extension, which must be of the form 'XXXXXX.json', where XXXXXX represents the sub extension specific to the managed type of attributes (i.e. "stage_config.json" for configurations describing stages). |
template<class T, ManagedObjectAccess Access>
std:: vector<int> esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: loadAllFileBasedTemplates(const std:: vector<std:: string>& tmpltFilenames,
bool saveAsDefaults)
Load all file-based templates given string list of template file locations.
Parameters | |
---|---|
tmpltFilenames | list of file names of templates |
saveAsDefaults | Set these templates as un-deletable from library. |
Returns | vector holding IDs of templates that have been added |
This will take the list of file names specified and load the referenced templates. It is assumed these files are JSON files currently.
template<class T, ManagedObjectAccess Access>
std:: vector<int> esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: loadAllJSONConfigsFromPath(const std:: string& path,
bool saveAsDefaults = false)
Load file-based templates for all JSONTypeExt_
Parameters | |
---|---|
path | A global path to configuration files or a directory containing such files. |
saveAsDefaults | Set the templates loaded as undeleteable default templates. |
Returns | A list of template indices for loaded valid configs |
This will take the passed path
string and either treat it as a file name or a directory, depending on what is found in the filesystem. If path
does not end with JSONTypeExt_path
exists as a directory, and if so will perform a shallow search to find any files ending in JSONTypeExt_
template<class T, ManagedObjectAccess Access>
std:: vector<int> esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: loadAllTemplatesFromPathAndExt(const std:: string& path,
const std:: string& extType,
bool saveAsDefaults = false)
Load file-based templates for all extType
files from the provided file or directory path.
Parameters | |
---|---|
path | A global path to configuration files or a directory containing such files. |
extType | The extension of files to be attempted to be loaded as templates. |
saveAsDefaults | Set the templates loaded as undeleteable default templates. |
Returns | A list of template indices for loaded valid configs |
This will take the passed path
string and either treat it as a file name or a directory, depending on what is found in the filesystem. If path
does not end with extType
, it will append this and check to see if such a file exists, and load it. It will also check if path
exists as a directory, and if so will perform a shallow search to find any files ending in extType
and load those that are found.
template<class T, ManagedObjectAccess Access>
void esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: buildJSONCfgPathsFromJSONAndLoad(const std:: string& configDir,
const io::JsonGenericValue& jsonPaths)
This builds a list of paths to this type of attributes's JSON Config files from the passed jsonPaths
array element. It then will load all the configs it finds at each path.
Parameters | |
---|---|
configDir | The directory to use as a root to search in - may be different than the config dir already listed in this manager. |
jsonPaths | The json array element |
template<class T, ManagedObjectAccess Access>
void esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: buildAttrSrcPathsFromJSONAndLoad(const std:: string& configDir,
const std:: string& extType,
const io::JsonGenericValue& jsonPaths)
This builds a list of paths to the extType
files to use to construct templates derived from the passed jsonPaths
array element. It then will load all the configs it finds at each path.
Parameters | |
---|---|
configDir | The directory to use as a root to search in - may be different than the config dir already listed in this manager. |
extType | The extension of files to be attempted to be loaded as templates. |
jsonPaths | The json array element |
template<class T, ManagedObjectAccess Access>
AttribsPtr esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: buildObjectFromJSONDoc(const std:: string& templateName,
const io::JsonGenericValue& jsonConfig) override
Parse passed JSON Document for esp::
Parameters | |
---|---|
templateName | The desired name for this esp:: |
jsonConfig | json document to parse |
Returns | a reference to the desired template. |
template<class T, ManagedObjectAccess Access>
void esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: setValsFromJSONDoc(AttribsPtr attribs,
const io::JsonGenericValue& jsonConfig) pure virtual
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 |
template<class T, ManagedObjectAccess Access>
bool esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: parseUserDefinedJsonVals(const attributes::AbstractAttributes::ptr& attribs,
const io::JsonGenericValue& jsonConfig) const
This function takes the json block specifying user-defined values and parses it into the passed existing attributes.
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>
bool esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: parseSubconfigJsonVals(const std:: string& subGroupName,
const attributes::AbstractAttributes::ptr& attribs,
const io::JsonGenericValue& jsonConfig) const
This function takes the passed json block jsonConfig
, looks for subGroupName
, and if found in json document and referencing an appropriately formatted object, will load the found values into a subconfig, keyed by subGroupName
, placed into attribs
' subconfig tree.
Parameters | |
---|---|
subGroupName | The name of the target subgroup in the json document. Will also be the key of the resultant subconfig. |
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>
std:: string esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: getFullAttrNameFromStr(const std:: string& attrName) const
Returns actual attributes handle containing attrName
as a substring, or the empty string if none exists. Does a substring search, and returns first value found.
Parameters | |
---|---|
attrName | name to be used as searching substring in attrMgr |
Returns | actual name of attributes in attrMgr, or empty string if does not exist. |
template<class T, ManagedObjectAccess Access>
void esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: finalizeAttrPathsBeforeRegister(const AttribsPtr& attributes) const pure virtual
This function will be called to finalize attributes' paths before registration, moving fully qualified paths to the appropriate hidden attribute fields. This can also be called without registration to make sure the paths specified in an attributes are properly configured.
Parameters | |
---|---|
attributes | The attributes to be filtered. |
template<class T, ManagedObjectAccess Access>
void esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: filterAttribsFilenames(const AttribsPtr& attributes,
const std:: string& curRelPathName,
const std:: string& curFQPathName,
const std:: function<void(const std:: string&)>& relPathSetter,
const std:: function<void(const std:: string&)>& fqPathSetter) const protected
Called internally right before attribute registration. Filepaths in the json configs for Habitat SceneDatasets are specified relative to the location of the config in the file hierarchy. As the config is loaded, these filepaths will be fully qualified with absolute paths so that they can be easily found and consumed on command. However, saving fully qualified filepaths to JSON configs is undesirable.
Parameters | |
---|---|
attributes | The Configuration-backed attributes owning the filepath in question. |
curRelPathName | The currently set relative path filepath in the attributes |
curFQPathName | The currently set fully qualified filepath in the attributes |
relPathSetter | The relative filepath setter in the attributes |
fqPathSetter | The fully qualified filepath setter in the attributes |
This function will examine the curRelPathName
to see that it is a relative path in relation to the attributes'
set filepath, and if not it will strip out the path information and resave the name to rePathSetter
. It will query the passed curFQPathName
to see that it is a fully qualified path to a file that exists, and if not it will add the attributes' filepath and resave it to fqPathSetter
.
It is assumed that what is passed to this function always referneces a filepath, so if, for example, this is called on a render asset filepath, it is assumed that that filepath does not reference a primitive (non-file-based) asset.
template<class T, ManagedObjectAccess Access>
AttribsPtr esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: createFromJsonOrDefaultInternal(const std:: string& filename,
std:: string& msg,
bool registerObj) protected
Called intenrally from createObject. This will create either a file based AbstractAttributes or a default one based on whether the passed file name exists and has appropriate string tag/extension for esp::
Parameters | |
---|---|
filename | the file holding the configuration of the object |
msg | reference to progress message |
registerObj | whether the new object should be registered in library |
Returns | the created esp:: |
template<class T, ManagedObjectAccess Access>
template<class M>
void esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: setEnumStringFromJsonDoc(const io::JsonGenericValue& jsonConfig,
const char* jsonTag,
const std:: string& mapName,
bool saveUnspecified,
const std:: map<std:: string, M>& mapToUse,
const std:: function<void(const std:: string&)>& valueSetter) protected
This function is accessed by various attributes managers during loading. It provides a generic handler to look for a particular jsonTag
in the given jsonConfig
document, and if it is present it will attempt to find the value in the passed string-keyed mapToUse
of enum config values. If the string is present it will return the string, otherwise it will return an empty string. The consumer of the function is responsible for only setting a config value if the string is not empty. The enum class should have the first value defined as Unspecified and given the value ID_UNDEFINED.
Parameters | |
---|---|
jsonConfig | The source json document |
jsonTag | The field to look for. If present expected to hold a string |
mapName | String map name, to be displayed if the value found in json is not found in mapToUse |
saveUnspecified | Whether to save the 'unspecified' string in value setter if no value is specified in json. |
mapToUse | String-keyed map of enum values supported for the field that corresponds to jsonTag . See attributes::AttributesEnumMaps.h/cpp. |
valueSetter | The config function to use to set the value |
template<class T, ManagedObjectAccess Access>
bool esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: setFilenameFromDefaultTag(const AttribsPtr& attributes,
const std:: string& srcAssetFilename,
const std:: function<void(const std:: string&)>& filenameSetter) protected
Set a filename attribute to hold the appropriate data if the existing attribute's given path contains the sentinel tag value defined at esp::
Parameters | |
---|---|
attributes | The AbstractAttributes being worked with. |
srcAssetFilename | The given asset's stored filename to be queried for the specified tag. If the tag exists, replace it with the simplified handle given by the attributes (hence copy). If this DNE on disk, add file directory. |
filenameSetter | The function to set the filename appropriately for the given asset. |
Returns | Whether or not the final value residing within the attribute's asset filename exists or not. |
If the given data does not contain the esp::srcAssetFilename
directly, first as it is given, and then by prefixing it with the current attributes' source file directory. If found it will call filenameSetter
with the successful string.
This will only be called from the specified manager's initNewObjectInternal function, where the attributes is initially built from a default attributes (if such an attributes exists), since it is only within the default attributes that the tag in question would be specified.
template<class T, ManagedObjectAccess Access>
bool esp:: metadata:: managers:: AbstractAttributesManager<T, Access>:: setAttributesHandleFromDefaultTag(const AttribsPtr& attributes,
const std:: string& srcAssetHandle,
const std:: function<void(const std:: string&)>& handleSetter) protected
Set an attribute that holds another attribute's handle to hold the appropriate data if the existing attribute's given path contains the sentinel tag value defined at esp::
Parameters | |
---|---|
attributes | The AbstractAttributes being worked with. |
srcAssetHandle | The given asset's stored asset handle to be queried for the wildcard tag. If the tag exists, replace it with the simplified handle given by the attributes (hence copy). If this DNE on disk, add file directory. |
handleSetter | The function to set the handle appropriately for the given asset. |
Returns | Whether the sentinel tag was found or not in the handle specification. |
This will only be called from the specified manager's initNewObjectInternal function, where the attributes is initially built from a default attributes (if such an attributes exists).