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
Identity get(const Name &identity) const
Get identity from the container.
void remove(const Name &identity)
Remove identity from the container.
Copyright (c) 2011-2015 Regents of the University of California.
void reset()
Reset state of the container.
const std::set< Name > & getIdentityNames() const
Identity add(const Name &identityName)
Add identity into the container.
const_iterator find(const Name &keyId) const
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
Represents an absolute name.
Definition: name.hpp:43
Container of identities of a Pib.
bool isConsistent() const
Check if the container is consistent with the backend storage.
A frontend handle of an Identity.
Definition: identity.hpp:42
const std::unordered_map< Name, shared_ptr< detail::IdentityImpl > > & getLoadedIdentities() const
represents the PIB
Definition: pib.hpp:52