Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 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 | |
Alexander Afanasyev | 97709c0 | 2016-08-25 19:58:30 -0700 | [diff] [blame] | 22 | #ifndef NDN_SECURITY_PIB_KEY_CONTAINER_HPP |
| 23 | #define NDN_SECURITY_PIB_KEY_CONTAINER_HPP |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 24 | |
| 25 | #include <set> |
| 26 | #include "key.hpp" |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace security { |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 30 | namespace pib { |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 31 | |
| 32 | class PibImpl; |
| 33 | |
| 34 | /// @brief A handler to search or enumerate keys of an identity. |
| 35 | class KeyContainer |
| 36 | { |
| 37 | public: |
| 38 | class const_iterator |
| 39 | { |
| 40 | public: |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 41 | 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 Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 57 | const_iterator(const Name& identity, std::set<Name>::const_iterator it, shared_ptr<PibImpl> impl); |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 58 | |
| 59 | private: |
| 60 | Name m_identity; |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 61 | std::set<Name>::const_iterator m_it; |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 62 | shared_ptr<PibImpl> m_impl; |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 63 | |
| 64 | friend class KeyContainer; |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | typedef const_iterator iterator; |
| 68 | |
| 69 | public: |
| 70 | KeyContainer(); |
| 71 | |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 72 | KeyContainer(const Name& identity, std::set<Name>&& keyNames, shared_ptr<PibImpl> impl); |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 73 | |
| 74 | const_iterator |
| 75 | begin() const; |
| 76 | |
| 77 | const_iterator |
| 78 | end() const; |
| 79 | |
| 80 | const_iterator |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 81 | find(const Name& keyName) const; |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 82 | |
| 83 | size_t |
| 84 | size() const; |
| 85 | |
| 86 | private: |
| 87 | Name m_identity; |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 88 | std::set<Name> m_keyNames; |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 89 | shared_ptr<PibImpl> m_impl; |
| 90 | }; |
| 91 | |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 92 | } // namespace pib |
| 93 | |
| 94 | using pib::KeyContainer; |
| 95 | |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 96 | } // namespace security |
| 97 | } // namespace ndn |
| 98 | |
Alexander Afanasyev | 97709c0 | 2016-08-25 19:58:30 -0700 | [diff] [blame] | 99 | #endif // NDN_SECURITY_PIB_KEY_CONTAINER_HPP |