template<class T, ManagedObjectAccess Access>
AttributesManager 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
-
AttributesManager(const std::
string& attrType, const std:: string& JSONTypeExt) - Construct an attributes manager to manage shared pointers of attributes of type T.
- ~AttributesManager() 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.
Protected functions
-
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 setHandleFromDefaultTag(const attributes::AbstractAttributes::ptr& 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 used 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.
Function documentation
template<class T, ManagedObjectAccess Access>
esp:: metadata:: managers:: AttributesManager<T, Access>:: AttributesManager(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:: AttributesManager<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:: AttributesManager<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:: AttributesManager<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:: AttributesManager<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:: AttributesManager<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:: AttributesManager<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:: AttributesManager<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:: AttributesManager<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>
AttribsPtr esp:: metadata:: managers:: AttributesManager<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 create esp:: |
template<class T, ManagedObjectAccess Access>
template<class M>
void esp:: metadata:: managers:: AttributesManager<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 | |
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:: AttributesManager<T, Access>:: setHandleFromDefaultTag(const attributes::AbstractAttributes::ptr& 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 | |
srcAssetFilename | The given asset's stored filename to be queried for the specified tag. If the tag exists, replace it to build the 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. |
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).