avoid stupid string allocation all the time.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "ns3/packet-metadata.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
@@ -39,6 +40,7 @@ public:
|
||||
virtual void Serialize (Buffer::Iterator start) const;
|
||||
virtual uint32_t Deserialize (Buffer::Iterator start);
|
||||
private:
|
||||
static std::string GetTypeName (void);
|
||||
bool m_ok;
|
||||
};
|
||||
|
||||
@@ -54,13 +56,20 @@ BenchHeader<N>::IsOk (void) const
|
||||
return m_ok;
|
||||
}
|
||||
|
||||
template <int N>
|
||||
std::string
|
||||
BenchHeader<N>::GetTypeName (void)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "ns3::BenchHeader<" << N << ">";
|
||||
return oss.str ();
|
||||
}
|
||||
|
||||
template <int N>
|
||||
TypeId
|
||||
BenchHeader<N>::GetTypeId (void)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "ns3::BenchHeader<"<<N<<">";
|
||||
static TypeId tid = TypeId (oss.str ().c_str ())
|
||||
static TypeId tid = TypeId (GetTypeName ().c_str ())
|
||||
.SetParent<Header> ()
|
||||
;
|
||||
return tid;
|
||||
|
||||
Reference in New Issue
Block a user