164    bool Rename(std::string oldpath, std::string newname);
 
  176    bool Rename(std::string path, std::string oldname, std::string newname);
 
 
  328    std::string namespaceName = 
"/Names";
 
  329    std::string::size_type offset = name.find(namespaceName);
 
  336        offset = name.find(
'/');
 
  339            NS_ASSERT_MSG(
false, 
"NamesPriv::Add(): Name begins with '/' but not \"/Names\"");
 
  343        name = 
"/Names/" + name;
 
  353    std::string::size_type i = name.rfind(
'/');
 
  355                  "NamesPriv::Add(): Internal error.  Can't find '/' in name");
 
  362    NS_ASSERT_MSG(i != 0, 
"NamesPriv::Add(): Can't find a name in the path string");
 
  369    return Add(name.substr(0, i), name.substr(i + 1), 
object);
 
 
  376    if (path == 
"/Names")
 
  380    return Add(
Find(path), name, 
object);
 
 
  398        NS_ASSERT_MSG(node, 
"NamesPriv::Name(): context must point to a previously named node");
 
  411    auto newNode = 
new NameNode(node, name, 
object);
 
 
  439    std::string namespaceName = 
"/Names";
 
  440    std::string::size_type offset = oldpath.find(namespaceName);
 
  447        offset = oldpath.find(
'/');
 
  450            NS_ASSERT_MSG(
false, 
"NamesPriv::Add(): Name begins with '/' but not \"/Names\"");
 
  454        oldpath = 
"/Names/" + oldpath;
 
  464    std::string::size_type i = oldpath.rfind(
'/');
 
  466                  "NamesPriv::Add(): Internal error.  Can't find '/' in name");
 
  473    NS_ASSERT_MSG(i != 0, 
"NamesPriv::Add(): Can't find a name in the path string");
 
  480    return Rename(oldpath.substr(0, i), oldpath.substr(i + 1), newname);
 
 
  487    if (path == 
"/Names")
 
 
  503        NS_ASSERT_MSG(node, 
"NamesPriv::Name(): context must point to a previously named node");
 
  535        changeNode->
m_name = newname;
 
 
  555        return i->second->m_name;
 
 
  573                  "NamesPriv::FindFullName(): Internal error: Invalid NameNode pointer from map");
 
  579        path = 
"/" + p->
m_name + path;
 
  581    } 
while ((p = p->
m_parent) != 
nullptr);
 
 
  605    std::string namespaceName = 
"/Names/";
 
  606    std::string remaining;
 
  608    std::string::size_type offset = path.find(namespaceName);
 
  612        remaining = path.substr(namespaceName.size());
 
  631        NS_LOG_LOGIC(
"Looking for the object of name " << remaining);
 
  632        offset = remaining.find(
'/');
 
  633        if (offset == std::string::npos)
 
  639            auto i = node->
m_nameMap.find(remaining);
 
  648                return i->second->m_object;
 
  657            offset = remaining.find(
'/');
 
  658            std::string segment = remaining.substr(0, offset);
 
  669                remaining = remaining.substr(offset + 1);
 
  676    NS_ASSERT_MSG(node, 
"NamesPriv::Find(): Internal error:  this can't happen");
 
 
  685    if (path == 
"/Names")
 
 
  709            NS_LOG_LOGIC(
"Context does not point to a previously named node");
 
  723        return i->second->m_object;
 
 
  735        NS_LOG_LOGIC(
"Object does not exist in object map, returning NameNode 0");
 
  740        NS_LOG_LOGIC(
"Object exists in object map, returning NameNode " << &i->second);
 
 
  776    NS_ABORT_MSG_UNLESS(result, 
"Names::Rename(): Error renaming " << oldpath << 
" to " << newname);
 
 
  793                        "Names::Rename (): Error renaming " << path << 
" " << oldname << 
" to " 
 
  803                        "Names::Add(): Error adding name " << name << 
" under context " 
 
  813                        "Names::Rename (): Error renaming " << oldname << 
" to " << newname
 
  814                                                            << 
" under context " << &context);
 
 
NS_ABORT_x macro definitions.
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
NameNode * m_parent
The parent NameNode.
NameNode()
Default constructor.
Ptr< Object > m_object
The object corresponding to this NameNode.
std::map< std::string, NameNode * > m_nameMap
Children of this NameNode.
NameNode & operator=(const NameNode &rhs)
Assignment operator.
std::string m_name
The name of this NameNode.
static void Rename(std::string oldpath, std::string newname)
Rename a previously associated name.
static Ptr< Object > FindInternal(std::string path)
Non-templated internal version of Names::Find.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
static void Clear()
Clear the list of objects associated with names.
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,...
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...
The singleton root Names object.
bool Add(std::string name, Ptr< Object > object)
Internal implementation for Names::Add(std::string,Ptr<Object>)
NameNode m_root
The root NameNode.
bool IsDuplicateName(NameNode *node, std::string name)
Check if a name already exists as a child of a NameNode.
std::string FindPath(Ptr< Object > object)
Internal implementation of Names::FindPath()
bool Rename(std::string oldpath, std::string newname)
Internal implementation for Names::Rename(std::string,std::string)
std::string FindName(Ptr< Object > object)
Internal implementation for Names::FindName()
~NamesPriv() override
Destructor.
NameNode * IsNamed(Ptr< Object > object)
Check if an object has a name.
std::map< Ptr< Object >, NameNode * > m_objectMap
Map from object pointers to their NameNodes.
Ptr< Object > Find(std::string path)
Internal implementation for ns3::Names::Find(std::string)
void Clear()
Internal implementation for Names::Clear()
Smart pointer class similar to boost::intrusive_ptr.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Declaration of class ns3::Names.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ns3::Singleton declaration and template implementation.