TopologyRead string handling optimization
This commit is contained in:
1 parent
54e9e3200a
commit
a5ceb2cf29
2 files changed
+12
-12
No files matched your search
@@ -49,7 +49,7 @@ TopologyReader::~TopologyReader ()
|
||||
}
|
||||
|
||||
void
|
||||
TopologyReader::SetFileName (const std::string fileName)
|
||||
TopologyReader::SetFileName (const std::string &fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ TopologyReader::AddLink (Link link)
|
||||
}
|
||||
|
||||
|
||||
TopologyReader::Link::Link ( Ptr<Node> fromPtr, std::string fromName, Ptr<Node> toPtr, std::string toName )
|
||||
TopologyReader::Link::Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName )
|
||||
{
|
||||
m_fromPtr = fromPtr;
|
||||
m_fromName = fromName;
|
||||
@@ -131,14 +131,14 @@ TopologyReader::Link::GetToNodeName (void) const
|
||||
}
|
||||
|
||||
std::string
|
||||
TopologyReader::Link::GetAttribute (std::string name) const
|
||||
TopologyReader::Link::GetAttribute (const std::string &name) const
|
||||
{
|
||||
NS_ASSERT_MSG (m_linkAttr.find (name) == m_linkAttr.end (), "Requested topology link attribute not found");
|
||||
return m_linkAttr.find (name)->second;
|
||||
}
|
||||
|
||||
bool
|
||||
TopologyReader::Link::GetAttributeFailSafe (std::string name, std::string &value) const
|
||||
TopologyReader::Link::GetAttributeFailSafe (const std::string &name, std::string &value) const
|
||||
{
|
||||
if ( m_linkAttr.find (name) == m_linkAttr.end () )
|
||||
{
|
||||
@@ -149,7 +149,7 @@ TopologyReader::Link::GetAttributeFailSafe (std::string name, std::string &value
|
||||
}
|
||||
|
||||
void
|
||||
TopologyReader::Link::SetAttribute (std::string name, std::string &value)
|
||||
TopologyReader::Link::SetAttribute (const std::string &name, const std::string &value)
|
||||
{
|
||||
m_linkAttr[name] = value;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
/**
|
||||
* \brief Constant iterator to scan the map of link attributes.
|
||||
*/
|
||||
typedef std::map<std::string, std::string >::const_iterator ConstAttributesIterator;
|
||||
typedef std::map<std::string, std::string>::const_iterator ConstAttributesIterator;
|
||||
|
||||
/**
|
||||
* \brief Constructor
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
* \param toPtr Ptr to the node the link is directed to
|
||||
* \param toName name of the node the link is directed to
|
||||
*/
|
||||
Link ( Ptr<Node> fromPtr, std::string fromName, Ptr<Node> toPtr, std::string toName );
|
||||
Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName );
|
||||
|
||||
/**
|
||||
* \brief Returns a Ptr<Node> to the "from" node of the link
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
*
|
||||
* \return the value of the attribute
|
||||
*/
|
||||
std::string GetAttribute (std::string name) const;
|
||||
std::string GetAttribute (const std::string &name) const;
|
||||
/**
|
||||
* \brief Returns the value of a link attribute.
|
||||
* \param name the name of the attribute
|
||||
@@ -103,13 +103,13 @@ public:
|
||||
*
|
||||
* \return true if the attribute was defined, false otherwise.
|
||||
*/
|
||||
bool GetAttributeFailSafe (std::string name, std::string &value) const;
|
||||
bool GetAttributeFailSafe (const std::string &name, std::string &value) const;
|
||||
/**
|
||||
* \brief Sets an arbitrary link attribute.
|
||||
* \param name the name of the attribute
|
||||
* \param value the value of the attribute
|
||||
*/
|
||||
void SetAttribute (std::string name, std::string &value);
|
||||
void SetAttribute (const std::string &name, const std::string &value);
|
||||
/**
|
||||
* \brief Returns an iterator to the begin of the attributes.
|
||||
* \return a const iterator to the first attribute of a link.
|
||||
@@ -127,7 +127,7 @@ private:
|
||||
Ptr< Node > m_fromPtr;
|
||||
std::string m_toName;
|
||||
Ptr< Node > m_toPtr;
|
||||
std::map<std::string, std::string > m_linkAttr;
|
||||
std::map<std::string, std::string> m_linkAttr;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ private:
|
||||
* \brief Sets the input file name.
|
||||
* \param fileName the input file name.
|
||||
*/
|
||||
void SetFileName (const std::string fileName);
|
||||
void SetFileName (const std::string &fileName);
|
||||
|
||||
/**
|
||||
* \brief Returns the input file name.
|
||||
|
||||
Reference in new issue
Block a user