HOPS
HOPS class reference
Public Member Functions | Protected Types | Protected Attributes | List of all members
hops::MHO_ContainerStore Class Reference

Class MHO_ContainerStore. More...

#include <MHO_ContainerStore.hh>

Public Member Functions

 MHO_ContainerStore ()
 
virtual ~MHO_ContainerStore ()
 
template<typename XClassType >
bool AddObject (XClassType *obj)
 Adds an object (with specific type) to the container store if it's non-null and can be cast to MHO_Serializable. More...
 
void Clear ()
 Deletes all objects in the store. More...
 
bool DeleteObject (const MHO_UUID &obj_id)
 Deletes an object from the container and removes related mappings by its UUID. More...
 
template<typename XClassType >
bool DeleteObject (XClassType *obj_ptr)
 Deletes an object and removes associated entries from containers, returns true if successful. More...
 
void DumpShortNamesToIds ()
 
std::vector< std::tuple< std::string, std::string, std::string > > GetAllObjectInfo ()
 
void GetAllObjectUUIDsOfType (MHO_UUID type_id, std::vector< MHO_UUID > &obj_ids)
 get every object uuid in store associated with the specified type UUID More...
 
void GetAllShortNames (std::vector< std::string > &shortnames)
 get all short names currently in use More...
 
void GetAllTypeUUIDs (std::vector< MHO_UUID > &type_ids)
 get every type uuid that is present in store More...
 
template<typename XClassType >
std::size_t GetNObjects () const
 get the number of objects of a specific type More...
 
std::size_t GetNObjects () const
 get total number of objects in store More...
 
template<typename XClassType >
XClassType * GetObject (const MHO_UUID &obj_id)
 get an object of a specific type via object uuid (returns nullptr if not present) More...
 
MHO_SerializableGetObject (const MHO_UUID &obj_id)
 get an object via uuid (returns nullptr if not present) More...
 
template<typename XClassType >
XClassType * GetObject (const std::string &shortname)
 provides retrieval of an object via shortname/nickname, returns nullptr on failure More...
 
template<typename XClassType >
XClassType * GetObject (std::size_t index)
 get an object of a specific type via integer index (returns nullptr if not present) More...
 
MHO_UUID GetObjectTypeUUID (const MHO_UUID &obj_id)
 returns the type uuid of the object with obj_id (if it exists) More...
 
MHO_UUID GetObjectUUID (const std::string &shortname)
 provide retrieval of an object uuid via shortname/nickname, returns zero'd uuid if none exist More...
 
std::string GetShortName (const MHO_UUID &obj_id)
 provide retrival of object short name from uuid More...
 
template<typename XClassType >
MHO_UUID GetTypeUUID ()
 get the type uuid for a specific type (if it is supported) - if unsupported uuid will be zero More...
 
bool IsObjectPresent (const MHO_UUID &obj_id) const
 Checks if an object with a given UUID is present in the container store. More...
 
void RenameObject (const std::string &current_shortname, const std::string &new_shortname)
 provides a way in which we can replace the shortname/nickname of an object More...
 
bool SetShortName (const MHO_UUID &obj_id, const std::string &shortname)
 provide the ability to attach a nicknames to object uuids, all nicknames must be unique returns false if unsuccessful (object not present, or shortname already in use) More...
 

Protected Types

using key_pair = std::pair< MHO_UUID, MHO_UUID >
 

Protected Attributes

MHO_ContainerDictionary fDictionary
 
std::map< key_pair, MHO_Serializable * > fIdsToObjects
 
std::map< MHO_Serializable *, key_pairfObjectsToIds
 
std::set< std::string > fShortNameSet
 
std::map< std::string, MHO_UUIDfShortNameToIds
 

Detailed Description

Class MHO_ContainerStore.

holds a collection of objects all pointed to by base class MHO_Serializable* retrieval is through type/object ids

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du
Date
Sat Feb 12 17:54:26 2022 -0500

Member Typedef Documentation

◆ key_pair

using hops::MHO_ContainerStore::key_pair = std::pair< MHO_UUID, MHO_UUID >
protected

Constructor & Destructor Documentation

◆ MHO_ContainerStore()

hops::MHO_ContainerStore::MHO_ContainerStore ( )
inline

◆ ~MHO_ContainerStore()

virtual hops::MHO_ContainerStore::~MHO_ContainerStore ( )
inlinevirtual

Member Function Documentation

◆ AddObject()

template<typename XClassType >
bool hops::MHO_ContainerStore::AddObject ( XClassType *  obj)

Adds an object (with specific type) to the container store if it's non-null and can be cast to MHO_Serializable.

Function MHO_ContainerStore::AddObject, addes and object via pointer.

Template Parameters
XClassTypeTemplate parameter, the object type
Parameters
objPointer to the object to add, must not be nullptr
Returns
True if object was successfully added, false otherwise
Parameters
obj(XClassType*)
Returns
Return value (template< typename XClassType > bool)

◆ Clear()

void hops::MHO_ContainerStore::Clear ( )

Deletes all objects in the store.

◆ DeleteObject() [1/2]

bool hops::MHO_ContainerStore::DeleteObject ( const MHO_UUID obj_id)

Deletes an object from the container and removes related mappings by its UUID.

Parameters
obj_idUUID of the object to delete.
Returns
True if deletion was successful, false otherwise.

◆ DeleteObject() [2/2]

template<typename XClassType >
bool hops::MHO_ContainerStore::DeleteObject ( XClassType *  obj_ptr)

Deletes an object and removes associated entries from containers, returns true if successful.

Function MHO_ContainerStore::DeleteObject - removes an object via pointer.

Template Parameters
XClassTypeTemplate parameter XClassType
Parameters
obj_ptrPointer to the object of type XClassType to delete.
Returns
True if deletion was successful, false otherwise.
Parameters
obj_ptr(XClassType*)
Returns
Return value (template< typename XClassType > bool)

◆ DumpShortNamesToIds()

void hops::MHO_ContainerStore::DumpShortNamesToIds ( )
inline

◆ GetAllObjectInfo()

std::vector< std::tuple< std::string, std::string, std::string > > hops::MHO_ContainerStore::GetAllObjectInfo ( )

◆ GetAllObjectUUIDsOfType()

void hops::MHO_ContainerStore::GetAllObjectUUIDsOfType ( MHO_UUID  type_id,
std::vector< MHO_UUID > &  obj_ids 
)

get every object uuid in store associated with the specified type UUID

Parameters
type_idInput type ID of MHO_UUID to filter objects
obj_ids(std::vector< MHO_UUID )&

◆ GetAllShortNames()

void hops::MHO_ContainerStore::GetAllShortNames ( std::vector< std::string > &  shortnames)

get all short names currently in use

Parameters
referenceto (std::vector< std::string>&) to be filled

◆ GetAllTypeUUIDs()

void hops::MHO_ContainerStore::GetAllTypeUUIDs ( std::vector< MHO_UUID > &  type_ids)

get every type uuid that is present in store

Parameters
type_idsOutput parameter: vector to hold retrieved UUIDs.

◆ GetNObjects() [1/2]

template<typename XClassType >
std::size_t hops::MHO_ContainerStore::GetNObjects

get the number of objects of a specific type

Counts and returns the number of objects of type XClassType stored in MHO_ContainerStore.

Template Parameters
XClassTypeTemplate parameter XClassType
Returns
Size of fObjectsToIds vector as std::size_t
Number of objects of type XClassType found

◆ GetNObjects() [2/2]

std::size_t hops::MHO_ContainerStore::GetNObjects ( ) const
inline

get total number of objects in store

Returns
Number of objects as std::size_t

◆ GetObject() [1/4]

template<typename XClassType >
XClassType * hops::MHO_ContainerStore::GetObject ( const MHO_UUID obj_id)

get an object of a specific type via object uuid (returns nullptr if not present)

Retrieves an object of type XClassType from the container store using its UUID.

Parameters
obj_idUUID of the object to retrieve
Returns
Pointer to the object of type XClassType if found, nullptr otherwise
Parameters
obj_idThe unique identifier (UUID) of the desired object
Returns
A pointer to the object of type XClassType, or nullptr if not found

◆ GetObject() [2/4]

MHO_Serializable * hops::MHO_ContainerStore::GetObject ( const MHO_UUID obj_id)

get an object via uuid (returns nullptr if not present)

Parameters
obj_idUUID of the object to retrieve
Returns
Pointer to the object if found, nullptr otherwise

◆ GetObject() [3/4]

template<typename XClassType >
XClassType * hops::MHO_ContainerStore::GetObject ( const std::string &  shortname)

provides retrieval of an object via shortname/nickname, returns nullptr on failure

Retrieves an object of type XClassType from the container store using its shortname.

Template Parameters
XClassTypeTemplate parameter XClassType
Parameters
shortname(const std::string&)
Returns
Pointer to the object if found, nullptr otherwise
Parameters
shortname(const std::string&)
Returns
Pointer to the retrieved object of type XClassType, or nullptr if not found

◆ GetObject() [4/4]

template<typename XClassType >
XClassType * hops::MHO_ContainerStore::GetObject ( std::size_t  index)

get an object of a specific type via integer index (returns nullptr if not present)

Retrieves an object of type XClassType at a specific index (for this class type) in the container.

Template Parameters
XClassTypeTemplate parameter XClassType
Parameters
index(std::size_t)
Returns
Pointer to the retrieved object cast to XClassType, or nullptr if not found
Parameters
indexIndex of the desired object
Returns
Pointer to the object of type XClassType if found, nullptr otherwise

◆ GetObjectTypeUUID()

MHO_UUID hops::MHO_ContainerStore::GetObjectTypeUUID ( const MHO_UUID obj_id)

returns the type uuid of the object with obj_id (if it exists)

Parameters
obj_idThe ID of the object whose type's UUID is to be retrieved.
Returns
The UUID of the object type if found, otherwise an empty UUID.

◆ GetObjectUUID()

MHO_UUID hops::MHO_ContainerStore::GetObjectUUID ( const std::string &  shortname)

provide retrieval of an object uuid via shortname/nickname, returns zero'd uuid if none exist

Parameters
shortnameShort name of the object
Returns
Object UUID; zero'd if none exist

◆ GetShortName()

std::string hops::MHO_ContainerStore::GetShortName ( const MHO_UUID obj_id)

provide retrival of object short name from uuid

Parameters
obj_idThe UUID for which to retrieve the short name.
Returns
The short name as a string if found, otherwise an empty string.

◆ GetTypeUUID()

template<typename XClassType >
MHO_UUID hops::MHO_ContainerStore::GetTypeUUID

get the type uuid for a specific type (if it is supported) - if unsupported uuid will be zero

Retrieves the UUID for a given class type from the internal dictionary, given the class XClassType template parameter.

Template Parameters
XClassTypeTemplate parameter XClassType
Returns
MHO_UUID representing the type's UUID.
MHO_UUID representing the type's UUID.

◆ IsObjectPresent()

bool hops::MHO_ContainerStore::IsObjectPresent ( const MHO_UUID obj_id) const

Checks if an object with a given UUID is present in the container store.

Template Parameters
XClassTypeTemplate parameter XClassType
Parameters
obj_idThe UUID of the object to search for.
Returns
True if the object is found, false otherwise.

◆ RenameObject()

void hops::MHO_ContainerStore::RenameObject ( const std::string &  current_shortname,
const std::string &  new_shortname 
)
inline

provides a way in which we can replace the shortname/nickname of an object

Renames an object in MHO_ContainerStore by updating its short name and associated UUID.

Parameters
current_shortname(std::string) the current shortname
new_shortname(std::string) the new object shortname
current_shortnameCurrent short name of the object to be renamed
new_shortnameNew short name for the object

◆ SetShortName()

bool hops::MHO_ContainerStore::SetShortName ( const MHO_UUID obj_id,
const std::string &  shortname 
)

provide the ability to attach a nicknames to object uuids, all nicknames must be unique returns false if unsuccessful (object not present, or shortname already in use)

Parameters
obj_idObject UUID to associate with the short name
shortnameUnique short name to assign to the object
Returns
True if successful, returns false if unsuccessful (object not present, or shortname already in use)

Member Data Documentation

◆ fDictionary

MHO_ContainerDictionary hops::MHO_ContainerStore::fDictionary
protected

◆ fIdsToObjects

std::map< key_pair, MHO_Serializable* > hops::MHO_ContainerStore::fIdsToObjects
protected

◆ fObjectsToIds

std::map< MHO_Serializable*, key_pair > hops::MHO_ContainerStore::fObjectsToIds
protected

◆ fShortNameSet

std::set< std::string > hops::MHO_ContainerStore::fShortNameSet
protected

◆ fShortNameToIds

std::map< std::string, MHO_UUID > hops::MHO_ContainerStore::fShortNameToIds
protected

The documentation for this class was generated from the following files: