esp::core::managedContainers::ManagedContainerBase class

Base class of Managed Container, holding template-type-independent functionality.

Derived classes

template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.
template<class T, ManagedObjectAccess Access>
class ManagedContainer
Class template defining responsibilities and functionality for managing esp::core::managedContainers::AbstractManagedObject constructs.

Constructors, destructors, conversion operators

ManagedContainerBase(const std::string& metadataType) explicit
~ManagedContainerBase() defaulted virtual

Public functions

auto setLock(const std::string& objectHandle, bool lock) -> bool
Sets/Clears lock state for a managed object, preventing or allowing deletion of managed object.
auto setLockByHandles(const std::vector<std::string>& objectHandles, bool lock) -> std::vector<std::string>
Sets/Clears lock state for a managed object, preventing or allowing deletion of managed object.
auto getObjectIDByHandle(const std::string& objectHandle) -> int
Get the ID of the managed object in ManagedContainerBase::objectLibrary_ for the given managed object Handle, if exists.
auto setLockBySubstring(bool lock, const std::string& subStr = "", bool contains = true) -> std::vector<std::string>
set lock state on all managed objects that contain passed substring.
auto getRandomObjectHandle() const -> std::string
Get the handle for a random managed object registered to this manager.
auto getUniqueHandleFromCandidate(const std::string& name) const -> std::string
return a unique handle given the passed object handle candidate substring. If there are no existing ManagedObjects with the passed handle, then the passed value will be returned; Otherwise, an incremented handle will be returned, based on the names present.
auto getObjectHandlesBySubstring(const std::string& subStr = "", bool contains = true, bool sorted = true) const -> std::vector<std::string>
Get a list of all managed objects handles that contain, or explicitly do not contain subStr, ignoring subStr's case.
auto getUndeletableObjectHandles() const -> std::vector<std::string>
returns a vector of managed object handles representing the system-specified undeletable managed objects this manager manages. These managed objects cannot be deleted, although they can be edited.
auto getIsUndeletable(const std::string& key) const -> bool
Returns whether the object with the passed key is undeletable.
auto getUserLockedObjectHandles() const -> std::vector<std::string>
returns a vector of managed object handles representing managed objects that have been locked by the user. These managed objects cannot be deleted until they have been unlocked, although they can be edited while locked.
auto getIsUserLocked(const std::string& key) const -> bool
Returns whether the object with the passed key is user locked.
void reset()
clears maps of handle-keyed managed object and ID-keyed handles.
auto getObjectHandleByID(const int objectID) const -> std::string
Get the key in objectLibrary_ for the object managed object with the given unique ID.
auto getNumObjects() const -> int
Gets the number of object managed objects stored in the objectLibrary_.
auto getObjectLibHasHandle(const std::string& handle) const -> bool
Checks whether managed object library has passed string handle as key.
auto getObjectLibHasID(int ID) const -> bool
Checks whether managed object library has an object with passed integer as ID.
auto getObjectType() const -> const std::string&
Get the type of object this ManagedContainer manages.
auto getObjectInfoStrings(const std::string& subStr = "", bool contains = true) const -> std::vector<std::string>
Get a vector of strings holding the values of each of the objects this manager manages whose keys match subStr, ignoring subStr's case. Pass an empty string for all objects.
auto getObjectInfoCSVString(const std::string& subStr, bool contains) const -> std::string

Protected functions

auto getObjectIDByHandleOrNew(const std::string& objectHandle, bool getNext) -> int
Used Internally. Get the ID of the managed object in objectLibrary_ for the given managed object Handle, if exists. If the managed object is not in the library and getNext is true then returns next available id, otherwise throws assertion and returns ID_UNDEFINED.
template<class U>
auto getObjectInternal(const std::string& handle) const -> auto
Retrieve shared pointer to object held in library, NOT a copy.
void setObjectInternal(const std::shared_ptr<void>& ptr, int objId, const std::string& handle)
Only used from class template AddObject method. put the passed smart poitner in the library.
void deleteObjectInternalFinalize(int objectID, const std::string& objectHandle) pure virtual
This method will perform any necessary updating that is ManagedContainer specialization-specific upon managed object removal, such as removing a specific managed object handle from the list of file-based managed object handles in ObjectAttributesManager. This should only be called internally.
auto checkExistsWithMessage(const std::string& objectHandle, const std::string& src) const -> bool
Used Internally. Checks if managed object handle exists in map; if not prints an error message, returns false; Otherwise returns true;.
auto getUnusedObjectID() -> int
Used Internally. Get an unused/available ID to be assigned to an object as it is being added to the library.
auto getRandomObjectHandlePerType(const std::unordered_map<int, std::string>& mapOfHandles, const std::string& type) const -> std::string
Return a random handle selected from the passed map.
auto getUniqueHandleFromCandidatePerType(const std::unordered_map<int, std::string>& mapOfHandles, const std::string& name) const -> std::string
return a unique handle given the passed object handle candidate substring among all passed types. If there are no existing ManagedObjects with the passed handle within the passed map, then the passed value will be returned; Otherwise, an incremented handle will be returned, based on the names present.
auto getObjectHandlesBySubStringPerType(const std::unordered_map<int, std::string>& mapOfHandles, const std::string& subStr, bool contains, bool sorted) const -> std::vector<std::string>
Get a list of all managed objects' handles of passed type whose origin handles contain substr, ignoring subStr's case.
auto getAllObjectHandlesBySubStringPerType(const std::string& subStr, bool contains, bool sorted) const -> std::vector<std::string>
Get a list of all managed objects' handles of passed type whose origin handles contain substr, ignoring subStr's case.
auto getObjectHandlesBySubStringPerType(const std::unordered_map<std::string, std::set<std::string>>& mapOfHandles, const std::string& subStr, bool contains, bool sorted) const -> std::vector<std::string>
Get a list of all managed objects' handles of passed type whose origin handles contain substr, ignoring subStr's case.
void deleteObjectInternal(int objectID, const std::string& objectHandle)
Called internally only. Remove all references from libraries for object with passed ID and handle.
void resetFinalize() pure virtual
Any implementation-specific resetting that needs to happen on reset.
auto getObjectLibIterator() const -> std::pair<std::unordered_map<std::string, std::shared_ptr<void>>::const_iterator, std::unordered_map<std::string, std::shared_ptr<void>>::const_iterator>
Provide a const iterator over the objectLibrary_.
void clearUndeletableObjectNames()
Clear the mapping of undeletable object handles.
void addUndeletableObjectName(std::string objName)
Add an undeleteable object's name to the mapping.

Protected variables

const std::string objectType_
A descriptive name of the managed object being managed by this manager.

Function documentation

bool esp::core::managedContainers::ManagedContainerBase::setLock(const std::string& objectHandle, bool lock)

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

Parameters
objectHandle handle of managed object to set state of
lock boolean to set or clear lock
Returns whether successful or not.

std::vector<std::string> esp::core::managedContainers::ManagedContainerBase::setLockByHandles(const std::vector<std::string>& objectHandles, bool lock)

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

Parameters
objectHandles Vector of handles of managed objects to set state of
lock boolean to set or clear lock for all managed objects
Returns the list of handles actually set to desired lock state.

int esp::core::managedContainers::ManagedContainerBase::getObjectIDByHandle(const std::string& objectHandle)

Get the ID of the managed object in ManagedContainerBase::objectLibrary_ for the given managed object Handle, if exists.

Parameters
objectHandle The string key referencing the managed object in ManagedContainerBase::objectLibrary_. Usually the origin handle.
Returns The object ID for the managed object with the passed handle, or ID_UNDEFINED if none exists.

std::vector<std::string> esp::core::managedContainers::ManagedContainerBase::setLockBySubstring(bool lock, const std::string& subStr = "", bool contains = true)

set lock state on all managed objects that contain passed substring.

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

std::string esp::core::managedContainers::ManagedContainerBase::getRandomObjectHandle() const

Get the handle for a random managed object registered to this manager.

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

std::string esp::core::managedContainers::ManagedContainerBase::getUniqueHandleFromCandidate(const std::string& name) const

return a unique handle given the passed object handle candidate substring. If there are no existing ManagedObjects with the passed handle, then the passed value will be returned; Otherwise, an incremented handle will be returned, based on the names present.

Parameters
name Candidate name for object. If DNE then this string is returned with a count component of 0000; if does exist, then an incrementing scheme will be followed.
Returns A valid, unique name to use for a potential managed object.

std::vector<std::string> esp::core::managedContainers::ManagedContainerBase::getObjectHandlesBySubstring(const std::string& subStr = "", bool contains = true, bool sorted = true) const

Get a list of all managed objects handles that contain, or explicitly do not contain subStr, ignoring subStr's case.

Parameters
subStr substring key to search for within existing managed objects.
contains whether to search for keys containing, or excluding, passed subStr
sorted
Returns vector of 0 or more managed object handles containing the passed substring

bool esp::core::managedContainers::ManagedContainerBase::getIsUndeletable(const std::string& key) const

Returns whether the object with the passed key is undeletable.

Parameters
key Value to look for to check whether undeletable or not.
Returns True if handle exists and is undeletable.

bool esp::core::managedContainers::ManagedContainerBase::getIsUserLocked(const std::string& key) const

Returns whether the object with the passed key is user locked.

Parameters
key Value to look for to check whether locked or not.
Returns True if handle exists and is user-locked.

std::string esp::core::managedContainers::ManagedContainerBase::getObjectHandleByID(const int objectID) const

Get the key in objectLibrary_ for the object managed object with the given unique ID.

Parameters
objectID The unique ID of the desired managed object.
Returns The key referencing the managed object in objectLibrary_, or nullptr if does not exist.

int esp::core::managedContainers::ManagedContainerBase::getNumObjects() const

Gets the number of object managed objects stored in the objectLibrary_.

Returns The size of the objectLibrary_.

bool esp::core::managedContainers::ManagedContainerBase::getObjectLibHasHandle(const std::string& handle) const

Checks whether managed object library has passed string handle as key.

Parameters
handle the key to look for

bool esp::core::managedContainers::ManagedContainerBase::getObjectLibHasID(int ID) const

Checks whether managed object library has an object with passed integer as ID.

Parameters
ID the ID to look for

std::vector<std::string> esp::core::managedContainers::ManagedContainerBase::getObjectInfoStrings(const std::string& subStr = "", bool contains = true) const

Get a vector of strings holding the values of each of the objects this manager manages whose keys match subStr, ignoring subStr's case. Pass an empty string for all objects.

Parameters
subStr substring key to search for within existing managed objects.
contains whether to search for keys containing, or excluding, substr
Returns A vector containing the string info of all the objects in this manager.

int esp::core::managedContainers::ManagedContainerBase::getObjectIDByHandleOrNew(const std::string& objectHandle, bool getNext) protected

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

Parameters
objectHandle The string key referencing the managed object in ManagedContainerBase::objectLibrary_. 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 managed object's ID if found. The next available ID if not found and getNext is true. Otherwise ID_UNDEFINED.

template<class U>
auto esp::core::managedContainers::ManagedContainerBase::getObjectInternal(const std::string& handle) const protected

Retrieve shared pointer to object held in library, NOT a copy.

Parameters
handle the name of the object held in the smart pointer

void esp::core::managedContainers::ManagedContainerBase::setObjectInternal(const std::shared_ptr<void>& ptr, int objId, const std::string& handle) protected

Only used from class template AddObject method. put the passed smart poitner in the library.

Parameters
ptr the smart pointer to the object being managed
objId
handle the name (key) to use for the object in the library

void esp::core::managedContainers::ManagedContainerBase::deleteObjectInternalFinalize(int objectID, const std::string& objectHandle) pure virtual protected

This method will perform any necessary updating that is ManagedContainer specialization-specific upon managed object removal, such as removing a specific managed object handle from the list of file-based managed object handles in ObjectAttributesManager. This should only be called internally.

Parameters
objectID the ID of the managed object to remove
objectHandle the string key of the managed object to remove.

int esp::core::managedContainers::ManagedContainerBase::getUnusedObjectID() protected

Used Internally. Get an unused/available ID to be assigned to an object as it is being added to the library.

Returns The managed object's ID if found. The next available ID if not found and getNext is true. Otherwise ID_UNDEFINED.

std::string esp::core::managedContainers::ManagedContainerBase::getRandomObjectHandlePerType(const std::unordered_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 managed object handles
type the type of managed object being retrieved, for debug message
Returns a random managed object handle of the chosen type, or the empty string if none loaded

std::string esp::core::managedContainers::ManagedContainerBase::getUniqueHandleFromCandidatePerType(const std::unordered_map<int, std::string>& mapOfHandles, const std::string& name) const protected

return a unique handle given the passed object handle candidate substring among all passed types. If there are no existing ManagedObjects with the passed handle within the passed map, then the passed value will be returned; Otherwise, an incremented handle will be returned, based on the names present.

Parameters
mapOfHandles map containing the desired managed object handles
name Candidate name for object. If DNE then this string is returned; if does exist, then an incrementing scheme will be followed.
Returns A valid, unique name to use for a potential managed object.

std::vector<std::string> esp::core::managedContainers::ManagedContainerBase::getObjectHandlesBySubStringPerType(const std::unordered_map<int, std::string>& mapOfHandles, const std::string& subStr, bool contains, bool sorted) const protected

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

Parameters
mapOfHandles map containing the desired managed object handles
subStr substring to search for within existing managed objects
contains Whether to search for handles containing, or not containing, substr
sorted whether the return vector values are sorted
Returns vector of 0 or more managed object handles containing/not containing the passed substring

This version works on std::unordered_map<int,std::string> maps' values.

std::vector<std::string> esp::core::managedContainers::ManagedContainerBase::getAllObjectHandlesBySubStringPerType(const std::string& subStr, bool contains, bool sorted) const protected

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

Parameters
subStr substring to search for within existing managed objects
contains Whether to search for handles containing, or not containing, substr
sorted whether the return vector values are sorted
Returns vector of 0 or more managed object handles containing/not containing the passed substring

This version works on the internal objectLibKeyByID_ map

std::vector<std::string> esp::core::managedContainers::ManagedContainerBase::getObjectHandlesBySubStringPerType(const std::unordered_map<std::string, std::set<std::string>>& mapOfHandles, const std::string& subStr, bool contains, bool sorted) const protected

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

Parameters
mapOfHandles map containing the desired keys to search.
subStr substring to search for within existing managed objects
contains Whether to search for handles containing, or not containing, substr
sorted whether the return vector values are sorted
Returns vector of 0 or more managed object handles containing/not containing the passed substring

This version works on std::unordered_map<std::string, std::set<std::string>> maps's keys.

void esp::core::managedContainers::ManagedContainerBase::deleteObjectInternal(int objectID, const std::string& objectHandle) protected

Called internally only. Remove all references from libraries for object with passed ID and handle.

Parameters
objectID the ID of the object to remove.
objectHandle the handle of the object to remove.