49 : m_parent (0), m_name (
""), m_object (0)
72 : m_parent (parent), m_name (name), m_object (object)
92 bool Rename (std::string oldpath, std::string newname);
93 bool Rename (std::string path, std::string oldname, std::string newname);
181 std::string namespaceName =
"/Names";
182 std::string::size_type offset = name.find (namespaceName);
189 offset = name.find (
"/");
192 NS_ASSERT_MSG (
false,
"NamesPriv::Add(): Name begins with '/' but not \"/Names\"");
196 name =
"/Names/" + name;
206 std::string::size_type i = name.rfind (
"/");
207 NS_ASSERT_MSG (i != std::string::npos,
"NamesPriv::Add(): Internal error. Can't find '/' in name");
214 NS_ASSERT_MSG (i != 0,
"NamesPriv::Add(): Can't find a name in the path string");
221 return Add (name.substr (0, i), name.substr (i + 1), object);
228 if (path ==
"/Names")
232 return Add (
Find (path), name,
object);
250 NS_ASSERT_MSG (node,
"NamesPriv::Name(): context must point to a previously named node");
291 std::string namespaceName =
"/Names";
292 std::string::size_type offset = oldpath.find (namespaceName);
299 offset = oldpath.find (
"/");
302 NS_ASSERT_MSG (
false,
"NamesPriv::Add(): Name begins with '/' but not \"/Names\"");
306 oldpath =
"/Names/" + oldpath;
316 std::string::size_type i = oldpath.rfind (
"/");
317 NS_ASSERT_MSG (i != std::string::npos,
"NamesPriv::Add(): Internal error. Can't find '/' in name");
324 NS_ASSERT_MSG (i != 0,
"NamesPriv::Add(): Can't find a name in the path string");
331 return Rename (oldpath.substr (0, i), oldpath.substr (i + 1), newname);
338 if (path ==
"/Names")
342 return Rename (
Find (path), oldname, newname);
354 NS_ASSERT_MSG (node,
"NamesPriv::Name(): context must point to a previously named node");
367 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (oldname);
386 changeNode->
m_name = newname;
406 return i->second->m_name;
423 NS_ASSERT_MSG (p,
"NamesPriv::FindFullName(): Internal error: Invalid NameNode pointer from map");
429 path =
"/" + p->
m_name + path;
457 std::string namespaceName =
"/Names/";
458 std::string remaining;
460 std::string::size_type offset = path.find (namespaceName);
464 remaining = path.substr (namespaceName.size ());
483 NS_LOG_LOGIC (
"Looking for the object of name " << remaining);
484 offset = remaining.find (
"/");
485 if (offset == std::string::npos)
491 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (remaining);
500 return i->second->m_object;
509 offset = remaining.find (
"/");
510 std::string segment = remaining.substr (0, offset);
512 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (segment);
521 remaining = remaining.substr (offset + 1);
528 NS_ASSERT_MSG (node,
"NamesPriv::Find(): Internal error: this can't happen");
537 if (path ==
"/Names")
561 NS_LOG_LOGIC (
"Context does not point to a previously named node");
566 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (name);
575 return i->second->m_object;
587 NS_LOG_LOGIC (
"Object does not exist in object map, returning NameNode 0");
592 NS_LOG_LOGIC (
"Object exists in object map, returning NameNode " << &i->second);
602 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (name);
628 NS_ABORT_MSG_UNLESS (result,
"Names::Rename(): Error renaming " << oldpath <<
" to " << newname);
644 NS_ABORT_MSG_UNLESS (result,
"Names::Rename (): Error renaming " << path <<
" " << oldname <<
" to " << newname);
652 NS_ABORT_MSG_UNLESS (result,
"Names::Add(): Error adding name " << name <<
" under context " << &context);
660 NS_ABORT_MSG_UNLESS (result,
"Names::Rename (): Error renaming " << oldname <<
" to " << newname <<
" under context " <<
#define NS_LOG_FUNCTION(parameters)
std::map< std::string, NameNode * > m_nameMap
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if cond is false.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr
A directory of name and Ptr
static void Clear(void)
Clear the list of objects associated with names.
bool Rename(std::string oldpath, std::string newname)
std::string FindPath(Ptr< Object > object)
std::string FindName(Ptr< Object > object)
#define NS_LOG_LOGIC(msg)
static void Rename(std::string oldpath, std::string newname)
Rename a previously associated name.
NameNode & operator=(const NameNode &rhs)
static std::string FindPath(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and return the...
#define NS_ASSERT_MSG(condition, message)
std::map< Ptr< Object >, NameNode * > m_objectMap
static NamesPriv * Get(void)
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and...
NameNode * IsNamed(Ptr< Object >)
bool Add(std::string name, Ptr< Object > object)
static Ptr< Object > FindInternal(std::string path)
Non-templated internal version of Names::Find.
Ptr< Object > Find(std::string name)
bool IsDuplicateName(NameNode *node, std::string name)