blob: a593132796fb71900c47f72c06a2bffb8926e3d2 [file] [log] [blame]
Yingdi Yub8f8b342015-04-27 11:06:42 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Yingdi Yu6ee2d362015-07-16 21:48:05 -07003 * Copyright (c) 2013-2017 Regents of the University of California.
Yingdi Yub8f8b342015-04-27 11:06:42 -07004 *
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
Alexander Afanasyev97709c02016-08-25 19:58:30 -070022#ifndef NDN_SECURITY_PIB_KEY_CONTAINER_HPP
23#define NDN_SECURITY_PIB_KEY_CONTAINER_HPP
Yingdi Yub8f8b342015-04-27 11:06:42 -070024
25#include <set>
26#include "key.hpp"
27
28namespace ndn {
29namespace security {
Yingdi Yu6ee2d362015-07-16 21:48:05 -070030namespace pib {
Yingdi Yub8f8b342015-04-27 11:06:42 -070031
32class PibImpl;
33
34/// @brief A handler to search or enumerate keys of an identity.
35class KeyContainer
36{
37public:
38 class const_iterator
39 {
40 public:
Yingdi Yub8f8b342015-04-27 11:06:42 -070041 Key
42 operator*();
43
44 const_iterator&
45 operator++();
46
47 const_iterator
48 operator++(int);
49
50 bool
51 operator==(const const_iterator& other);
52
53 bool
54 operator!=(const const_iterator& other);
55
56 private:
Yingdi Yu6ee2d362015-07-16 21:48:05 -070057 const_iterator(const Name& identity, std::set<Name>::const_iterator it, shared_ptr<PibImpl> impl);
Yingdi Yub8f8b342015-04-27 11:06:42 -070058
59 private:
60 Name m_identity;
Yingdi Yu6ee2d362015-07-16 21:48:05 -070061 std::set<Name>::const_iterator m_it;
Yingdi Yub8f8b342015-04-27 11:06:42 -070062 shared_ptr<PibImpl> m_impl;
Yingdi Yu6ee2d362015-07-16 21:48:05 -070063
64 friend class KeyContainer;
Yingdi Yub8f8b342015-04-27 11:06:42 -070065 };
66
67 typedef const_iterator iterator;
68
69public:
70 KeyContainer();
71
Yingdi Yu6ee2d362015-07-16 21:48:05 -070072 KeyContainer(const Name& identity, std::set<Name>&& keyNames, shared_ptr<PibImpl> impl);
Yingdi Yub8f8b342015-04-27 11:06:42 -070073
74 const_iterator
75 begin() const;
76
77 const_iterator
78 end() const;
79
80 const_iterator
Yingdi Yu6ee2d362015-07-16 21:48:05 -070081 find(const Name& keyName) const;
Yingdi Yub8f8b342015-04-27 11:06:42 -070082
83 size_t
84 size() const;
85
86private:
87 Name m_identity;
Yingdi Yu6ee2d362015-07-16 21:48:05 -070088 std::set<Name> m_keyNames;
Yingdi Yub8f8b342015-04-27 11:06:42 -070089 shared_ptr<PibImpl> m_impl;
90};
91
Yingdi Yu6ee2d362015-07-16 21:48:05 -070092} // namespace pib
93
94using pib::KeyContainer;
95
Yingdi Yub8f8b342015-04-27 11:06:42 -070096} // namespace security
97} // namespace ndn
98
Alexander Afanasyev97709c02016-08-25 19:58:30 -070099#endif // NDN_SECURITY_PIB_KEY_CONTAINER_HPP