33 #ifndef DART_COMMON_NAMEMANAGER_HPP_
34 #define DART_COMMON_NAMEMANAGER_HPP_
66 const std::string& _managerName =
"default",
67 const std::string& _defaultName =
"default");
83 bool setPattern(
const std::string& _newPattern);
86 std::string
issueNewName(
const std::string& _name)
const;
92 bool addName(
const std::string& _name,
const T& _obj);
108 bool hasName(
const std::string& _name)
const;
121 T
getObject(
const std::string& _name)
const;
125 std::string
getName(
const T& _obj)
const;
class NameManager
Definition: NameManager.hpp:62
std::string mInfix
The chunk of text that comes between a duplicate name and its duplication number.
Definition: NameManager.hpp:173
virtual ~NameManager()=default
Destructor.
void clear()
Clear all the objects.
Definition: NameManager.hpp:199
NameManager(const std::string &_managerName="default", const std::string &_defaultName="default")
Constructor.
Definition: NameManager.hpp:46
bool hasObject(const T &_obj) const
Return true if the object is contained.
Definition: NameManager.hpp:214
bool removeObject(const T &_obj)
Remove an object from the Manager based on reverse lookup.
Definition: NameManager.hpp:171
void setManagerName(const std::string &_managerName)
Set the name of this NameManager so that it can be printed in error reports.
Definition: NameManager.hpp:287
bool removeName(const std::string &_name)
Remove an object from the Manager based on its name.
Definition: NameManager.hpp:149
const std::string & getManagerName() const
Get the name of this NameManager.
Definition: NameManager.hpp:294
bool setPattern(const std::string &_newPattern)
Set a new pattern for name generation.
Definition: NameManager.hpp:60
T getObject(const std::string &_name) const
Get object by given name.
Definition: NameManager.hpp:228
std::string mManagerName
Name of this NameManager. This is used to report errors.
Definition: NameManager.hpp:153
void removeEntries(const std::string &_name, const T &_obj)
Remove _name using the forward lookup and _obj using the reverse lookup.
Definition: NameManager.hpp:191
std::string changeObjectName(const T &_obj, const std::string &_newName)
Change the name of a currently held object.
Definition: NameManager.hpp:255
bool addName(const std::string &_name, const T &_obj)
Add an object to the map.
Definition: NameManager.hpp:123
std::string mDefaultName
String which will be used as a name for any object which is passed in with an empty string name.
Definition: NameManager.hpp:163
std::string mAffix
The chunk of text that gets appended to a duplicate name.
Definition: NameManager.hpp:176
std::map< T, std::string > mReverseMap
Reverse map of objects that have been added to the NameManager.
Definition: NameManager.hpp:159
std::string getName(const T &_obj) const
Use a reverse lookup to get the name that the manager has _obj listed under.
Definition: NameManager.hpp:240
std::string issueNewName(const std::string &_name) const
Issue new unique combined name of given base name and number suffix.
Definition: NameManager.hpp:85
std::size_t getCount() const
Get the number of the objects currently stored by the NameManager.
Definition: NameManager.hpp:221
std::string issueNewNameAndAdd(const std::string &_name, const T &_obj)
Call issueNewName() and add the result to the map.
Definition: NameManager.hpp:111
bool mNameBeforeNumber
Internal variable used to arrange the text when resolving duplicate names.
Definition: NameManager.hpp:166
bool hasName(const std::string &_name) const
Return true if the name is contained.
Definition: NameManager.hpp:207
void setDefaultName(const std::string &_defaultName)
Set the name that will be provided to objects passed in with an empty string for a name.
Definition: NameManager.hpp:273
std::map< std::string, T > mMap
Map of objects that have been added to the NameManager.
Definition: NameManager.hpp:156
std::string mPrefix
The chunk of text that gets prepended to a duplicate name.
Definition: NameManager.hpp:169
const std::string & getDefaultName() const
Get the name that will be provided to objects passed in with an empty string for a name.
Definition: NameManager.hpp:280
Definition: BulletCollisionDetector.cpp:65