NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
identity-container.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_SECURITY_PIB_IDENTITY_CONTAINER_HPP
23 #define NDN_SECURITY_PIB_IDENTITY_CONTAINER_HPP
24 
26 
27 #include <iterator>
28 #include <set>
29 #include <unordered_map>
30 
31 namespace ndn {
32 namespace security {
33 namespace pib {
34 
35 class PibImpl;
36 
37 namespace detail {
38 class IdentityImpl;
39 } // namespace detail
40 
47 class IdentityContainer : noncopyable
48 {
49 public:
51  {
52  public:
53  using iterator_category = std::forward_iterator_tag;
54  using value_type = const Identity;
55  using difference_type = std::ptrdiff_t;
56  using pointer = value_type*;
58 
60 
61  Identity
62  operator*();
63 
65  operator++();
66 
68  operator++(int);
69 
70  bool
71  operator==(const const_iterator& other);
72 
73  bool
74  operator!=(const const_iterator& other);
75 
76  private:
77  const_iterator(std::set<Name>::const_iterator it, const IdentityContainer& container);
78 
79  private:
80  std::set<Name>::const_iterator m_it;
81  const IdentityContainer* m_container;
82 
83  friend class IdentityContainer;
84  };
85 
87 
88 public:
90  begin() const;
91 
93  end() const;
94 
96  find(const Name& keyId) const;
97 
98  size_t
99  size() const;
100 
104  Identity
105  add(const Name& identityName);
106 
110  void
111  remove(const Name& identity);
112 
117  Identity
118  get(const Name& identity) const;
119 
126  void
127  reset();
128 
134  bool
135  isConsistent() const;
136 
142  explicit
143  IdentityContainer(shared_ptr<PibImpl> pibImpl);
144 
145  const std::set<Name>&
147  {
148  return m_identityNames;
149  }
150 
151  const std::unordered_map<Name, shared_ptr<detail::IdentityImpl>>&
153  {
154  return m_identities;
155  }
156 
157 private:
158  std::set<Name> m_identityNames;
160  mutable std::unordered_map<Name, shared_ptr<detail::IdentityImpl>> m_identities;
161 
162  shared_ptr<PibImpl> m_pibImpl;
163 
164  friend class Pib;
165 };
166 
167 } // namespace pib
168 
170 
171 } // namespace security
172 } // namespace ndn
173 
174 #endif // NDN_SECURITY_PIB_IDENTITY_CONTAINER_HPP
ndn::security::pib::IdentityContainer::const_iterator::operator*
Identity operator*()
Definition: identity-container.cpp:46
identity.hpp
ndn::security::pib::IdentityContainer::const_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: identity-container.hpp:53
ndn::security::pib::IdentityContainer::end
const_iterator end() const
Definition: identity-container.cpp:97
ndn::security::pib::IdentityContainer::remove
void remove(const Name &identity)
Remove identity from the container.
Definition: identity-container.cpp:125
ndn::security::pib::IdentityContainer::const_iterator::difference_type
std::ptrdiff_t difference_type
Definition: identity-container.hpp:55
ndn::security::pib::IdentityContainer::get
Identity get(const Name &identity) const
Get identity from the container.
Definition: identity-container.cpp:133
ndn::security::pib::Pib
represents the PIB
Definition: pib.hpp:53
ndn::security::pib::IdentityContainer::begin
const_iterator begin() const
Definition: identity-container.cpp:91
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::security::pib::IdentityContainer::getLoadedIdentities
const std::unordered_map< Name, shared_ptr< detail::IdentityImpl > > & getLoadedIdentities() const
Definition: identity-container.hpp:152
ndn::security::pib::IdentityContainer::reset
void reset()
Reset state of the container.
Definition: identity-container.cpp:149
ndn::security::pib::IdentityContainer::add
Identity add(const Name &identityName)
Add identity into the container.
Definition: identity-container.cpp:115
ndn::security::pib::IdentityContainer::const_iterator::operator!=
bool operator!=(const const_iterator &other)
Definition: identity-container.cpp:78
ndn::security::pib::IdentityContainer::size
size_t size() const
Definition: identity-container.cpp:109
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
ndn::security::pib::IdentityContainer::getIdentityNames
const std::set< Name > & getIdentityNames() const
Definition: identity-container.hpp:146
ndn::security::pib::IdentityContainer::const_iterator::operator==
bool operator==(const const_iterator &other)
Definition: identity-container.cpp:68
ndn::security::pib::IdentityContainer::const_iterator::operator++
const_iterator & operator++()
Definition: identity-container.cpp:53
ndn::security::pib::IdentityContainer::const_iterator::const_iterator
const_iterator()
Definition: identity-container.cpp:33
ndn::security::pib::IdentityContainer
Container of identities of a Pib.
Definition: identity-container.hpp:48
ndn::security::pib::Identity
A frontend handle of an Identity.
Definition: identity.hpp:43
ndn::security::pib::IdentityContainer::isConsistent
bool isConsistent() const
Check if the container is consistent with the backend storage.
Definition: identity-container.cpp:156
ndn::security::pib::IdentityContainer::iterator
const_iterator iterator
Definition: identity-container.hpp:86
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::security::pib::IdentityContainer::const_iterator
Definition: identity-container.hpp:51
ndn::security::pib::IdentityContainer::find
const_iterator find(const Name &keyId) const
Definition: identity-container.cpp:103