1 #ifndef MHO_ContainerStore_HH__
2 #define MHO_ContainerStore_HH__
51 template<
typename XClassType >
bool AddObject(XClassType* obj);
68 template<
typename XClassType > XClassType*
GetObject(
const std::string& shortname);
77 template<
typename XClassType > XClassType*
GetObject(std::size_t index);
86 template<
typename XClassType >
bool DeleteObject(XClassType* obj_ptr);
102 template<
typename XClassType > std::size_t
GetNObjects()
const;
194 std::vector< std::tuple< std::string, std::string, std::string > >
GetAllObjectInfo();
203 void RenameObject(
const std::string& current_shortname,
const std::string& new_shortname);
210 std::cout << it->first <<
" : " << it->second.as_string() << std::endl;
256 MHO_UUID obj_id = obj->GetObjectUUID();
257 MHO_UUID type_id = obj->GetTypeUUID();
282 XClassType* ptr =
nullptr;
287 ptr =
dynamic_cast< XClassType*
>(obj);
300 XClassType* ptr =
nullptr;
304 ptr = GetObject< XClassType >(obj_id);
317 XClassType* ptr =
nullptr;
318 std::size_t n_objects = GetNObjects< XClassType >();
319 std::size_t count = 0;
320 if(index < n_objects)
326 MHO_UUID item_type_id = item_ids.first;
327 if(type_id == item_type_id)
332 ptr =
dynamic_cast< XClassType*
>(obj);
377 std::string shortname =
"";
380 if(it->second == obj_id)
382 shortname = it->first;
410 std::size_t count = 0;
414 MHO_UUID item_type_id = item_ids.first;
415 if(type_id == item_type_id)
MHO_UUID GetUUIDFor() const
Getter for uuid for a class type.
Definition: MHO_ClassIdentityMap.hh:155
Class MHO_ContainerDictionary.
Definition: MHO_ContainerDictionary.hh:28
Class MHO_ContainerStore.
Definition: MHO_ContainerStore.hh:32
MHO_ContainerStore()
Definition: MHO_ContainerStore.hh:34
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...
Definition: MHO_ContainerStore.cc:93
void GetAllShortNames(std::vector< std::string > &shortnames)
get all short names currently in use
Definition: MHO_ContainerStore.cc:135
void DumpShortNamesToIds()
Definition: MHO_ContainerStore.hh:206
std::set< std::string > fShortNameSet
Definition: MHO_ContainerStore.hh:233
MHO_UUID GetObjectTypeUUID(const MHO_UUID &obj_id)
returns the type uuid of the object with obj_id (if it exists)
Definition: MHO_ContainerStore.cc:145
bool DeleteObject(XClassType *obj_ptr)
Deletes an object and removes associated entries from containers, returns true if successful.
Definition: MHO_ContainerStore.hh:349
MHO_ContainerDictionary fDictionary
Definition: MHO_ContainerStore.hh:220
std::map< MHO_Serializable *, key_pair > fObjectsToIds
Definition: MHO_ContainerStore.hh:229
std::string GetShortName(const MHO_UUID &obj_id)
provide retrival of object short name from uuid
Definition: MHO_ContainerStore.cc:120
virtual ~MHO_ContainerStore()
Definition: MHO_ContainerStore.hh:36
std::map< std::string, MHO_UUID > fShortNameToIds
Definition: MHO_ContainerStore.hh:232
XClassType * GetObject(const MHO_UUID &obj_id)
get an object of a specific type via object uuid (returns nullptr if not present)
Definition: MHO_ContainerStore.hh:274
void GetAllTypeUUIDs(std::vector< MHO_UUID > &type_ids)
get every type uuid that is present in store
Definition: MHO_ContainerStore.cc:61
void Clear()
Deletes all objects in the store.
Definition: MHO_ContainerStore.cc:6
MHO_UUID GetObjectUUID(const std::string &shortname)
provide retrieval of an object uuid via shortname/nickname, returns zero'd uuid if none exist
Definition: MHO_ContainerStore.cc:108
void GetAllObjectUUIDsOfType(MHO_UUID type_id, std::vector< MHO_UUID > &obj_ids)
get every object uuid in store associated with the specified type UUID
Definition: MHO_ContainerStore.cc:78
bool IsObjectPresent(const MHO_UUID &obj_id) const
Checks if an object with a given UUID is present in the container store.
Definition: MHO_ContainerStore.cc:18
std::map< key_pair, MHO_Serializable * > fIdsToObjects
Definition: MHO_ContainerStore.hh:226
std::vector< std::tuple< std::string, std::string, std::string > > GetAllObjectInfo()
Definition: MHO_ContainerStore.cc:162
std::size_t GetNObjects() const
get total number of objects in store
Definition: MHO_ContainerStore.hh:150
std::pair< MHO_UUID, MHO_UUID > key_pair
Definition: MHO_ContainerStore.hh:215
void RenameObject(const std::string ¤t_shortname, const std::string &new_shortname)
provides a way in which we can replace the shortname/nickname of an object
Definition: MHO_ContainerStore.hh:429
MHO_UUID GetTypeUUID()
get the type uuid for a specific type (if it is supported) - if unsupported uuid will be zero
Definition: MHO_ContainerStore.hh:396
std::size_t GetNObjects() const
get the number of objects of a specific type
Definition: MHO_ContainerStore.hh:407
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_Se...
Definition: MHO_ContainerStore.hh:242
Class MHO_Serializable.
Definition: MHO_Serializable.hh:26
Class MHO_UUID - a class for a 16 byte UUID (for object and type identification)
Definition: MHO_UUID.hh:27
uint64_t as_long() const
Definition: MHO_UUID.hh:108
bool is_empty() const
Definition: MHO_UUID.hh:168
Definition: MHO_ChannelLabeler.hh:17