23 #include "ndn-cxx/security/pib/impl/identity-impl.hpp"
37 const IdentityContainer& container) noexcept
39 , m_container(&container)
46 BOOST_ASSERT(m_container !=
nullptr);
47 return m_container->
get(*m_it);
53 bool isThisEnd = m_container ==
nullptr || m_it == m_container->m_identityNames.end();
54 bool isOtherEnd = other.m_container ==
nullptr || other.m_it == other.m_container->m_identityNames.end();
57 return !isOtherEnd && m_container->m_pib == other.m_container->m_pib && m_it == other.m_it;
60 IdentityContainer::IdentityContainer(shared_ptr<PibImpl> pibImpl)
61 : m_pib(std::move(pibImpl))
63 BOOST_ASSERT(m_pib !=
nullptr);
64 m_identityNames = m_pib->getIdentities();
70 return {m_identityNames.find(identity), *
this};
76 bool didInsert = m_identityNames.insert(identityName).second;
79 return get(identityName);
83 m_pib->addIdentity(identityName);
84 auto ret = m_identities.emplace(identityName,
85 std::make_shared<detail::IdentityImpl>(identityName, m_pib));
87 BOOST_ASSERT(ret.second);
95 if (m_identityNames.erase(identityName) > 0) {
97 m_identities.erase(identityName);
101 BOOST_ASSERT(m_identities.find(identityName) == m_identities.end());
103 m_pib->removeIdentity(identityName);
109 auto it = m_identities.find(identityName);
110 if (it != m_identities.end()) {
115 if (!m_pib->hasIdentity(identityName)) {
119 auto id = std::make_shared<detail::IdentityImpl>(identityName, m_pib);
120 m_identities[identityName] = id;
128 m_identities.clear();
129 m_identityNames = m_pib->getIdentities();
135 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.
bool operator==(const const_iterator &other) const
Identity get(const Name &identity) const
Return an identity by name.
const_iterator find(const Name &identity) const
void remove(const Name &identity)
Remove identity from the container.
Identity add(const Name &identity)
Add identity into the container.
bool isConsistent() const
Check if the container is consistent with the backend storage.
void reset()
Reset the state of the container.
Frontend handle for an identity in the PIB.
Represents a semantic error.
#define NDN_CXX_ASSERT_FORWARD_ITERATOR(T)
Assert T is a forward iterator.
#define NDN_LOG_DEBUG(expression)
Log at DEBUG level.
#define NDN_LOG_INIT(name)
Define a non-member log module.