23 #include "ndn-cxx/security/pib/impl/identity-impl.hpp"
32 IdentityContainer::const_iterator::equals(
const const_iterator& other)
const noexcept
34 bool isThisEnd = m_container ==
nullptr || m_it == m_container->m_identityNames.end();
35 bool isOtherEnd = other.m_container ==
nullptr || other.m_it == other.m_container->m_identityNames.end();
38 return !isOtherEnd && m_container->m_pib == other.m_container->m_pib && m_it == other.m_it;
41 IdentityContainer::IdentityContainer(shared_ptr<PibImpl> pibImpl)
42 : m_pib(std::move(pibImpl))
44 BOOST_ASSERT(m_pib !=
nullptr);
45 m_identityNames = m_pib->getIdentities();
48 IdentityContainer::const_iterator
49 IdentityContainer::find(
const Name& identity)
const
51 return {m_identityNames.find(identity), *
this};
55 IdentityContainer::add(
const Name& identityName)
57 bool didInsert = m_identityNames.insert(identityName).second;
60 return get(identityName);
64 m_pib->addIdentity(identityName);
65 auto ret = m_identities.emplace(identityName,
66 std::make_shared<IdentityImpl>(identityName, m_pib));
68 BOOST_ASSERT(ret.second);
74 IdentityContainer::remove(
const Name& identityName)
76 if (m_identityNames.erase(identityName) > 0) {
78 m_identities.erase(identityName);
82 BOOST_ASSERT(m_identities.find(identityName) == m_identities.end());
84 m_pib->removeIdentity(identityName);
88 IdentityContainer::get(
const Name& identityName)
const
90 if (
auto it = m_identities.find(identityName); it != m_identities.end()) {
95 if (!m_pib->hasIdentity(identityName)) {
99 auto id = std::make_shared<IdentityImpl>(identityName, m_pib);
100 m_identities[identityName] = id;
105 IdentityContainer::reset()
108 m_identities.clear();
109 m_identityNames = m_pib->getIdentities();
113 IdentityContainer::isConsistent()
const
115 return m_identityNames == m_pib->getIdentities();
Represents an absolute name.
void toUri(std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const
Write URI representation of the name to the output stream.
Frontend handle for an identity in the PIB.
Represents a semantic error.
#define NDN_LOG_DEBUG(expression)
Log at DEBUG level.
#define NDN_LOG_INIT(name)
Define a non-member log module.
Contains the ndn-cxx security framework.