NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
key-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-2021 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_CXX_SECURITY_PIB_KEY_CONTAINER_HPP
23 #define NDN_CXX_SECURITY_PIB_KEY_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 KeyImpl;
39 class IdentityImpl;
40 } // namespace detail
41 
48 class KeyContainer : noncopyable
49 {
50 public:
52  {
53  public:
54  using iterator_category = std::forward_iterator_tag;
55  using value_type = const Key;
56  using difference_type = std::ptrdiff_t;
57  using pointer = value_type*;
59 
61 
62  Key
63  operator*();
64 
66  operator++();
67 
69  operator++(int);
70 
71  bool
72  operator==(const const_iterator& other);
73 
74  bool
75  operator!=(const const_iterator& other);
76 
77  private:
78  const_iterator(std::set<Name>::const_iterator it, const KeyContainer& container);
79 
80  private:
81  std::set<Name>::const_iterator m_it;
82  const KeyContainer* m_container;
83 
84  friend class KeyContainer;
85  };
86 
88 
89 public:
91  begin() const;
92 
94  end() const;
95 
97  find(const Name& keyName) const;
98 
99  size_t
100  size() const;
101 
109  Key
110  add(span<const uint8_t> key, const Name& keyName);
111 
116  void
117  remove(const Name& keyName);
118 
124  Key
125  get(const Name& keyName) const;
126 
132  bool
133  isConsistent() const;
134 
140  KeyContainer(const Name& identity, shared_ptr<PibImpl> pibImpl);
141 
142  const std::set<Name>&
143  getKeyNames() const
144  {
145  return m_keyNames;
146  }
147 
148  const std::unordered_map<Name, shared_ptr<detail::KeyImpl>>&
150  {
151  return m_keys;
152  }
153 
154 private:
155  Name m_identity;
156  std::set<Name> m_keyNames;
158  mutable std::unordered_map<Name, shared_ptr<detail::KeyImpl>> m_keys;
159 
160  shared_ptr<PibImpl> m_pib;
161 
162 #ifndef DOXYGEN
163  friend detail::IdentityImpl;
164 #endif
165 };
166 
167 } // namespace pib
168 
169 using pib::KeyContainer;
170 
171 } // namespace security
172 } // namespace ndn
173 
174 #endif // NDN_CXX_SECURITY_PIB_KEY_CONTAINER_HPP
Backend instance of Identity.
Copyright (c) 2011-2015 Regents of the University of California.
bool operator==(const Identity &lhs, const Identity &rhs)
Definition: identity.hpp:167
const std::set< Name > & getKeyNames() const
Container of keys of an identity.
A frontend handle of a key instance.
Definition: key.hpp:49
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
Represents an absolute name.
Definition: name.hpp:41
bool operator!=(const Identity &lhs, const Identity &rhs)
Definition: identity.cpp:101
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span-lite.hpp:1535
const std::unordered_map< Name, shared_ptr< detail::KeyImpl > > & getLoadedKeys() const