22 #include <unordered_map> 146 bool RemoveObject(
const std::string &name,
bool removeAliased =
false);
159 bool IsPresent(
const std::string &nameOrAlias)
const;
166 std::string
GetAlias(
const std::string &name)
const;
202 bool IsAlias(
const std::string &objName);
217 using Map = std::unordered_map<std::string, ObjectWrapper>;
227 return std::find_if(_aliases.begin(), _aliases.end(),
228 [&
aliasName](
const Alias alias) {
return (aliasName == alias.aliasName); });
232 std::vector<Aliases::iterator> retValue;
233 auto aliasIter = _aliases.begin();
234 while (aliasIter != _aliases.end()) {
235 aliasIter = std::find_if(_aliases.begin(), _aliases.end(),
236 [&
objName](
const Alias alias) {
return (objName == alias.objName); });
237 if (aliasIter != _aliases.end()) {
238 retValue.push_back(aliasIter);
255 std::pair<Map::iterator, bool> insertResult =
256 _map.insert(std::pair<const std::string &, ObjectWrapper>(name, wrapper));
257 if (insertResult.second) {
260 if (insertResult.first->second == wrapper) {
277 std::pair<Map::iterator, bool> insertResult =
278 _map.insert(std::pair<const std::string &, ObjectWrapper>(name, wrapper));
279 if (insertResult.second) {
283 if (insertResult.first->second == wrapper) {
300 std::pair<Map::iterator, bool> insertResult =
301 _map.insert(std::pair<const std::string &, ObjectWrapper>(name, wrapper));
302 if (insertResult.second) {
306 if (insertResult.first->second == wrapper) {
323 std::pair<Map::iterator, bool> insertResult =
324 _map.insert(std::pair<const std::string &, ObjectWrapper>(name, wrapper));
325 if (insertResult.second) {
329 if (insertResult.first->second == wrapper) {
344 iter =
_map.find(alias->objName);
347 iter =
_map.find(name);
349 if (iter ==
_map.end()) {
Class describing a pointer to an object retrieved from an ObjectMap.
Definition: ObjPtr.h:31
bool IsPresent(const std::string &nameOrAlias) const
Checks if an object is present in the map.
Definition: ObjectMap.cpp:123
bool CleanAliases()
Removes all the aliases from the map.
Definition: ObjectMap.cpp:138
Known object but not available at the moment.
InsertionResult SetAlias(const std::string &objName, const std::string &objAlias)
Set an alias for the given object.
Definition: ObjectMap.cpp:152
std::vector< Aliases::iterator > _FindAliasesOf(const std::string &objName)
Definition: ObjectMap.h:231
bool Clean()
Removes all the objects and aliases from the map.
Definition: ObjectMap.cpp:133
const std::string & GetNameOfAliasedObject(const std::string &aliasName)
Gets the name of the object corresponding to an alias.
Definition: ObjectMap.cpp:70
ObjectWrapper GetObjectWrapper(const std::string &objName)
Get a wrapper for a given object.
Definition: ObjectMap.cpp:52
std::string aliasName
Definition: ObjectMap.h:220
Definition: ObjectMap.h:219
std::string objName
Definition: ObjectMap.h:220
bool IsAlias(const std::string &objName)
Checks if an object name is actually an alias.
Definition: ObjectMap.cpp:203
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
std::type_index typeIndex
Definition: ObjectMap.h:221
Aliases _aliases
Definition: ObjectMap.h:224
A map between strings and objects of ObjectWrapper kind.
Definition: ObjectMap.h:32
Aliases::iterator _FindAlias(const std::string &aliasName)
Definition: ObjectMap.h:226
std::string GetAlias(const std::string &name) const
Get the alias of an object.
Definition: ObjectMap.cpp:184
Generic wrapper class.
Definition: ObjectWrapper.h:28
std::vector< std::string > GetObjects() const
Returns the names of the objects in the map.
Definition: ObjectMap.cpp:114
std::vector< Alias > Aliases
Definition: ObjectMap.h:223
InsertionResult AddObject(const std::string &name, DataType &obj)
Adds an object to the map.
Definition: ObjectMap.h:247
InsertionResult
Definition: InsertionResult.h:16
bool RemoveObject(const std::string &name, bool removeAliased=false)
Removes an object or an alias from the map.
Definition: ObjectMap.cpp:79
std::vector< std::string > GetAliases() const
Returns the aliases of the objects in the map.
Definition: ObjectMap.cpp:194
Object successfully inserted or already present.
ObjPtr< DataType > GetObject(const std::string &name)
Retrieves an object given its name.
Definition: ObjectMap.h:338
std::string GetObjectClass(const std::string &objName)
Get the class name of an object in the store.
Definition: ObjectMap.cpp:143
std::unordered_map< std::string, ObjectWrapper > Map
Definition: ObjectMap.h:217
Map _map
Definition: ObjectMap.h:218
~ObjectMap()
Destructor.
Definition: ObjectMap.cpp:14
Object found but class does not match with requested.
Another object with the same name already present.
RetrievalResult _result
Definition: ObjPtr.h:114