48 : m_parent (0), m_name (
""), m_object (0)
71 : m_parent (parent), m_name (name), m_object (object)
89 bool Rename (std::string oldpath, std::string newname);
90 bool Rename (std::string path, std::string oldname, std::string newname);
176 std::string namespaceName =
"/Names";
177 std::string::size_type offset = name.find (namespaceName);
184 offset = name.find (
"/");
187 NS_ASSERT_MSG (
false,
"NamesPriv::Add(): Name begins with '/' but not \"/Names\"");
191 name =
"/Names/" + name;
201 std::string::size_type i = name.rfind (
"/");
202 NS_ASSERT_MSG (i != std::string::npos,
"NamesPriv::Add(): Internal error. Can't find '/' in name");
209 NS_ASSERT_MSG (i != 0,
"NamesPriv::Add(): Can't find a name in the path string");
216 return Add (name.substr (0, i), name.substr (i + 1), object);
222 if (path ==
"/Names")
226 return Add (
Find (path), name,
object);
244 NS_ASSERT_MSG (node,
"NamesPriv::Name(): context must point to a previously named node");
285 std::string namespaceName =
"/Names";
286 std::string::size_type offset = oldpath.find (namespaceName);
293 offset = oldpath.find (
"/");
296 NS_ASSERT_MSG (
false,
"NamesPriv::Add(): Name begins with '/' but not \"/Names\"");
300 oldpath =
"/Names/" + oldpath;
310 std::string::size_type i = oldpath.rfind (
"/");
311 NS_ASSERT_MSG (i != std::string::npos,
"NamesPriv::Add(): Internal error. Can't find '/' in name");
318 NS_ASSERT_MSG (i != 0,
"NamesPriv::Add(): Can't find a name in the path string");
325 return Rename (oldpath.substr (0, i), oldpath.substr (i + 1), newname);
331 if (path ==
"/Names")
335 return Rename (
Find (path), oldname, newname);
347 NS_ASSERT_MSG (node,
"NamesPriv::Name(): context must point to a previously named node");
360 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (oldname);
379 changeNode->
m_name = newname;
399 return i->second->m_name;
416 NS_ASSERT_MSG (p,
"NamesPriv::FindFullName(): Internal error: Invalid NameNode pointer from map");
422 path =
"/" + p->
m_name + path;
448 std::string namespaceName =
"/Names/";
449 std::string remaining;
451 std::string::size_type offset = path.find (namespaceName);
455 remaining = path.substr (namespaceName.size ());
474 NS_LOG_LOGIC (
"Looking for the object of name " << remaining);
475 offset = remaining.find (
"/");
476 if (offset == std::string::npos)
482 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (remaining);
491 return i->second->m_object;
500 offset = remaining.find (
"/");
501 std::string segment = remaining.substr (0, offset);
503 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (segment);
512 remaining = remaining.substr (offset + 1);
519 NS_ASSERT_MSG (node,
"NamesPriv::Find(): Internal error: this can't happen");
528 if (path ==
"/Names")
552 NS_LOG_LOGIC (
"Context does not point to a previously named node");
557 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (name);
566 return i->second->m_object;
578 NS_LOG_LOGIC (
"Object does not exist in object map, returning NameNode 0");
583 NS_LOG_LOGIC (
"Object exists in object map, returning NameNode " << &i->second);
593 std::map<std::string, NameNode *>::iterator i = node->
m_nameMap.find (name);
617 NS_ABORT_MSG_UNLESS (result,
"Names::Rename(): Error renaming " << oldpath <<
" to " << newname);
631 NS_ABORT_MSG_UNLESS (result,
"Names::Rename (): Error renaming " << path <<
" " << oldname <<
" to " << newname);
638 NS_ABORT_MSG_UNLESS (result,
"Names::Add(): Error adding name " << name <<
" under context " << &context);
645 NS_ABORT_MSG_UNLESS (result,
"Names::Rename (): Error renaming " << oldname <<
" to " << newname <<
" under context " <<