diff --git a/src/name.cpp b/src/name.cpp index c388064..f158137 100644 --- a/src/name.cpp +++ b/src/name.cpp @@ -43,27 +43,52 @@ static_assert(std::is_base_of::value, const size_t Name::npos = std::numeric_limits::max(); +static std::set& +getAllNameSet() +{ + static std::set s; + return s; +} + Name::Name() : m_nameBlock(tlv::Name) { + getAllNameSet().insert(this); } Name::Name(const Block& wire) { + getAllNameSet().insert(this); m_nameBlock = wire; m_nameBlock.parse(); } Name::Name(const char* uri) { + getAllNameSet().insert(this); construct(uri); } Name::Name(const std::string& uri) { + getAllNameSet().insert(this); construct(uri.c_str()); } +Name::Name(const Name& other) +{ + getAllNameSet().insert(this); + *this = other; +} + +Name::~Name() +{ + auto it = getAllNameSet().find(this); + BOOST_ASSERT(it != getAllNameSet().end()); + std::cout << "Name::~Name(" << this << " " << *this << ")" << std::endl; + getAllNameSet().erase(it); +} + template size_t Name::wireEncode(EncodingImpl& encoder) const diff --git a/src/name.hpp b/src/name.hpp index cf8318f..c98e9b5 100644 --- a/src/name.hpp +++ b/src/name.hpp @@ -98,6 +98,13 @@ public: */ Name(const std::string& uri); + Name(const Name& other); + + Name& + operator=(const Name& other) = default; + + ~Name(); + /** * @brief Fast encoding or block size estimation */