22 #include <unordered_map> 146 bool RemoveObject(
const std::string &name,
bool removeAliased =
false);
159 bool IsPresent(
const std::string &nameOrAlias)
const;
170 std::vector<std::string>
GetAliases(
const std::string &name =
"")
const;
200 bool IsAlias(
const std::string &objName);
215 using Map = std::unordered_map<std::string, ObjectWrapper>;
225 return std::find_if(_aliases.begin(), _aliases.end(),
226 [&
aliasName](
const Alias alias) {
return (aliasName == alias.aliasName); });
230 std::vector<Aliases::iterator> retValue;
231 auto aliasIter = _aliases.begin();
232 while (aliasIter != _aliases.end()) {
233 aliasIter = std::find_if(_aliases.begin(), _aliases.end(),
234 [&
objName](
const Alias alias) {
return (objName == alias.objName); });
235 if (aliasIter != _aliases.end()) {
236 retValue.push_back(aliasIter);
253 std::pair<Map::iterator, bool> insertResult =
254 _map.insert(std::pair<const std::string &, ObjectWrapper>(name, wrapper));
255 if (insertResult.second) {
258 if (insertResult.first->second == wrapper) {
275 std::pair<Map::iterator, bool> insertResult =
276 _map.insert(std::pair<const std::string &, ObjectWrapper>(name, wrapper));
277 if (insertResult.second) {
281 if (insertResult.first->second == wrapper) {
298 std::pair<Map::iterator, bool> insertResult =
299 _map.insert(std::pair<const std::string &, ObjectWrapper>(name, wrapper));
300 if (insertResult.second) {
304 if (insertResult.first->second == wrapper) {
321 std::pair<Map::iterator, bool> insertResult =
322 _map.insert(std::pair<const std::string &, ObjectWrapper>(name, wrapper));
323 if (insertResult.second) {
327 if (insertResult.first->second == wrapper) {
342 iter =
_map.find(alias->objName);
345 iter =
_map.find(name);
347 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:229
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:218
Definition: ObjectMap.h:217
std::string objName
Definition: ObjectMap.h:218
bool IsAlias(const std::string &objName)
Checks if an object name is actually an alias.
Definition: ObjectMap.cpp:195
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
std::type_index typeIndex
Definition: ObjectMap.h:219
Aliases _aliases
Definition: ObjectMap.h:222
A map between strings and objects of ObjectWrapper kind.
Definition: ObjectMap.h:32
Aliases::iterator _FindAlias(const std::string &aliasName)
Definition: ObjectMap.h:224
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:221
InsertionResult AddObject(const std::string &name, DataType &obj)
Adds an object to the map.
Definition: ObjectMap.h:245
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 std::string &name="") const
Returns the aliases of the objects in the map.
Definition: ObjectMap.cpp:184
Object successfully inserted or already present.
ObjPtr< DataType > GetObject(const std::string &name)
Retrieves an object given its name.
Definition: ObjectMap.h:336
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:215
Map _map
Definition: ObjectMap.h:216
~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