34 : m_container(nullptr)
41 , m_container(&container)
48 BOOST_ASSERT(m_container !=
nullptr);
49 return m_container->get(*m_it);
70 bool isThisEnd = m_container ==
nullptr || m_it == m_container->m_keyNames.end();
71 bool isOtherEnd = other.m_container ==
nullptr || other.m_it == other.m_container->m_keyNames.end();
72 return ((isThisEnd || isOtherEnd) ?
73 (isThisEnd == isOtherEnd) :
74 m_container->m_pib == other.m_container->m_pib && m_it == other.m_it);
80 return !(*
this == other);
83 KeyContainer::KeyContainer(
const Name& identity, shared_ptr<PibImpl>
pibImpl)
84 : m_identity(identity)
87 BOOST_ASSERT(m_pib !=
nullptr);
88 m_keyNames = m_pib->getKeysOfIdentity(identity);
112 return m_keyNames.size();
119 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Key name `" + keyName.
toUri() +
"` does not match identity " 120 "`" + m_identity.
toUri() +
"`"));
123 m_keyNames.insert(keyName);
124 m_keys[keyName] = make_shared<detail::KeyImpl>(keyName, key, keyLen, m_pib);
133 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Key name `" + keyName.
toUri() +
"` does not match identity " 134 "`" + m_identity.
toUri() +
"`"));
137 m_keyNames.erase(keyName);
138 m_keys.erase(keyName);
139 m_pib->removeKey(keyName);
146 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Key name `" + keyName.
toUri() +
"` does not match identity " 147 "`" + m_identity.
toUri() +
"`"));
150 shared_ptr<detail::KeyImpl> key;
151 auto it = m_keys.find(keyName);
153 if (it != m_keys.end()) {
157 key = make_shared<detail::KeyImpl>(keyName, m_pib);
158 m_keys[keyName] = key;
167 return m_keyNames == m_pib->getKeysOfIdentity(m_identity);
const_iterator find(const Name &keyName) const
Copyright (c) 2011-2015 Regents of the University of California.
std::string toUri() const
Get URI representation of the name.
const_iterator begin() const
bool operator==(const const_iterator &other)
void remove(const Name &keyName)
Remove a key with keyName from the container.
NDN_CXX_ASSERT_FORWARD_ITERATOR(CertificateContainer::const_iterator)
bool operator!=(const const_iterator &other)
Container of keys of an identity.
const_iterator end() const
A frontend handle of a key instance.
Key get(const Name &keyName) const
Get a key with keyName from the container.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > pibImpl
Key add(const uint8_t *key, size_t keyLen, const Name &keyName)
Add key of keyLen bytes with keyName into the container.
bool isConsistent() const
Check if the container is consistent with the backend storage.
Represents an absolute name.
const_iterator & operator++()
Name extractIdentityFromKeyName(const Name &keyName)
Extract identity namespace from the key name keyName.