35 bool operator()(
const T*
const a,
const T*
const b)
const {
36 return a->getID() < b->getID();
44 bool operator()(
const T*
const a,
const T*
const b)
const {
45 return a->getNumericalID() < b->getNumericalID();
62 Named(
const std::string&
id) : myID(id) { }
70 static std::string
getIDSecure(
const T* obj,
const std::string& fallBack =
"NULL") {
71 return obj == 0 ? fallBack : obj->getID();
77 const std::string&
getID()
const {
85 void setID(
const std::string& newID) {
96 StoringVisitor(std::set<const Named*>& objects) : myIDs(nullptr), myObjects(&objects) {}
97 StoringVisitor(std::set<std::string>& objects) : myIDs(&objects), myObjects(nullptr) {}
104 if (myObjects ==
nullptr) {
105 myIDs->insert(o->
getID());
107 myObjects->insert(o);
StoringVisitor(std::set< std::string > &objects)
virtual ~Named()
Destructor.
StoringVisitor(std::set< const Named *> &objects)
Contructor.
void add(const Named *const o) const
Adds the given object to the container.
void addTo(const StoringVisitor &cont) const
Adds this object to the given container.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
~StoringVisitor()
Destructor.
bool operator()(const T *const a, const T *const b) const
std::set< const Named * > * myObjects
std::set< std::string > * myIDs
The container.
Named(const std::string &id)
Constructor.
Base class for objects which have an id.
Function-object for stable sorting of objects with numerical ids.
Allows to store the object; used as context while traveling the rtree in TraCI.
std::string myID
The name of the object.
void setID(const std::string &newID)
resets the id
Function-object for stable sorting of objects acting like Named without being derived (SUMOVehicle) ...
bool operator()(const T *const a, const T *const b) const