Use std::move in more places
Plus various code simplifications
Change-Id: I19805e4a635e4c74afaff68f9d8968475217ec6e
diff --git a/src/security/pib/identity-container.cpp b/src/security/pib/identity-container.cpp
index 7c018ce..0e4749f 100644
--- a/src/security/pib/identity-container.cpp
+++ b/src/security/pib/identity-container.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -81,10 +81,10 @@
}
IdentityContainer::IdentityContainer(shared_ptr<PibImpl> pibImpl)
- : m_pibImpl(pibImpl)
+ : m_pibImpl(std::move(pibImpl))
{
- BOOST_ASSERT(pibImpl != nullptr);
- m_identityNames = pibImpl->getIdentities();
+ BOOST_ASSERT(m_pibImpl != nullptr);
+ m_identityNames = m_pibImpl->getIdentities();
}
IdentityContainer::const_iterator
@@ -116,8 +116,7 @@
{
if (m_identityNames.count(identityName) == 0) {
m_identityNames.insert(identityName);
- m_identities[identityName] =
- shared_ptr<detail::IdentityImpl>(new detail::IdentityImpl(identityName, m_pibImpl, true));
+ m_identities[identityName] = make_shared<detail::IdentityImpl>(identityName, m_pibImpl, true);
}
return get(identityName);
}
@@ -140,7 +139,7 @@
id = it->second;
}
else {
- id = shared_ptr<detail::IdentityImpl>(new detail::IdentityImpl(identityName, m_pibImpl, false));
+ id = make_shared<detail::IdentityImpl>(identityName, m_pibImpl, false);
m_identities[identityName] = id;
}
return Identity(id);
diff --git a/src/security/pib/key-container.cpp b/src/security/pib/key-container.cpp
index 7dc8358..ee47e37 100644
--- a/src/security/pib/key-container.cpp
+++ b/src/security/pib/key-container.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -121,7 +121,7 @@
}
m_keyNames.insert(keyName);
- m_keys[keyName] = shared_ptr<detail::KeyImpl>(new detail::KeyImpl(keyName, key, keyLen, m_pib));
+ m_keys[keyName] = make_shared<detail::KeyImpl>(keyName, key, keyLen, m_pib);
return get(keyName);
}
@@ -154,7 +154,7 @@
key = it->second;
}
else {
- key = shared_ptr<detail::KeyImpl>(new detail::KeyImpl(keyName, m_pib));
+ key = make_shared<detail::KeyImpl>(keyName, m_pib);
m_keys[keyName] = key;
}
diff --git a/src/security/pib/pib.cpp b/src/security/pib/pib.cpp
index 68b9add..4fba641 100644
--- a/src/security/pib/pib.cpp
+++ b/src/security/pib/pib.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -34,9 +34,9 @@
, m_location(location)
, m_isDefaultIdentityLoaded(false)
, m_identities(impl)
- , m_impl(impl)
+ , m_impl(std::move(impl))
{
- BOOST_ASSERT(impl != nullptr);
+ BOOST_ASSERT(m_impl != nullptr);
}
Pib::~Pib() = default;
diff --git a/src/security/pib/pib.hpp b/src/security/pib/pib.hpp
index 947e5a5..27d83da 100644
--- a/src/security/pib/pib.hpp
+++ b/src/security/pib/pib.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -67,7 +67,7 @@
~Pib();
/**
- * @brief return the scheme of the PibLocator
+ * @brief return the scheme of the PIB Locator
*/
std::string
getScheme() const
@@ -110,19 +110,21 @@
Identity
getIdentity(const Name& identityName) const;
- /// @brief Get all the identities
+ /**
+ * @brief Get all the identities
+ */
const IdentityContainer&
getIdentities() const;
/**
* @brief Get the default identity.
- * @throw Pib::Error if no default identity.
+ * @throw Pib::Error if no default identity exists.
*/
const Identity&
getDefaultIdentity() const;
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
- /*
+ /**
* @brief Create a Pib instance
*
* @param scheme The scheme for the Pib
@@ -131,17 +133,8 @@
*/
Pib(const std::string& scheme, const std::string& location, shared_ptr<PibImpl> impl);
- /*
- * @brief Create an identity with name @p identityName and return a reference to it.
- *
- * If there already exists an identity for the name @p identityName, then it is returned.
- * If no default identity is set, the newly created identity will be set as the default.
- *
- * @param identityName The name for the identity to be added
- */
-
/**
- * @brief Add an @p identity.
+ * @brief Add an identity.
*
* If no default identity is set before, the new identity will be set as the default identity
*
@@ -150,8 +143,8 @@
Identity
addIdentity(const Name& identity);
- /*
- * @brief Remove an @p identity.
+ /**
+ * @brief Remove an identity.
*
* If the default identity is being removed, no default identity will be selected.
*/
@@ -159,7 +152,7 @@
removeIdentity(const Name& identity);
/**
- * @brief Set an @p identity as the default identity.
+ * @brief Set an identity as the default identity.
*
* Create the identity if it does not exist.
*