33 #ifndef DART_COMMON_NAMEMANAGER_HPP_
34 #define DART_COMMON_NAMEMANAGER_HPP_
65 NameManager(
const std::string& _managerName =
"default",
66 const std::string& _defaultName =
"default");
82 bool setPattern(
const std::string& _newPattern);
85 std::string
issueNewName(
const std::string& _name)
const;
91 bool addName(
const std::string& _name,
const T& _obj);
107 bool hasName(
const std::string& _name)
const;
120 T
getObject(
const std::string& _name)
const;
124 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:171
virtual ~NameManager()=default
Destructor.
void clear()
Clear all the objects.
Definition: NameManager.hpp:197
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:212
bool removeObject(const T &_obj)
Remove an object from the Manager based on reverse lookup.
Definition: NameManager.hpp:169
void setManagerName(const std::string &_managerName)
Set the name of this NameManager so that it can be printed in error reports.
Definition: NameManager.hpp:286
bool removeName(const std::string &_name)
Remove an object from the Manager based on its name.
Definition: NameManager.hpp:147
const std::string & getManagerName() const
Get the name of this NameManager.
Definition: NameManager.hpp:293
bool setPattern(const std::string &_newPattern)
Set a new pattern for name generation.
Definition: NameManager.hpp:58
T getObject(const std::string &_name) const
Get object by given name.
Definition: NameManager.hpp:226
std::string mManagerName
Name of this NameManager. This is used to report errors.
Definition: NameManager.hpp:151
void removeEntries(const std::string &_name, const T &_obj)
Remove _name using the forward lookup and _obj using the reverse lookup.
Definition: NameManager.hpp:189
std::string changeObjectName(const T &_obj, const std::string &_newName)
Change the name of a currently held object.
Definition: NameManager.hpp:254
bool addName(const std::string &_name, const T &_obj)
Add an object to the map.
Definition: NameManager.hpp:121
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:161
std::string mAffix
The chunk of text that gets appended to a duplicate name.
Definition: NameManager.hpp:174
std::map< T, std::string > mReverseMap
Reverse map of objects that have been added to the NameManager.
Definition: NameManager.hpp:157
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:239
std::string issueNewName(const std::string &_name) const
Issue new unique combined name of given base name and number suffix.
Definition: NameManager.hpp:83
std::size_t getCount() const
Get the number of the objects currently stored by the NameManager.
Definition: NameManager.hpp:219
std::string issueNewNameAndAdd(const std::string &_name, const T &_obj)
Call issueNewName() and add the result to the map.
Definition: NameManager.hpp:109
bool mNameBeforeNumber
Internal variable used to arrange the text when resolving duplicate names.
Definition: NameManager.hpp:164
bool hasName(const std::string &_name) const
Return true if the name is contained.
Definition: NameManager.hpp:205
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:272
std::map< std::string, T > mMap
Map of objects that have been added to the NameManager.
Definition: NameManager.hpp:154
std::string mPrefix
The chunk of text that gets prepended to a duplicate name.
Definition: NameManager.hpp:167
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:279
Definition: BulletCollisionDetector.cpp:63