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 | |
| 22 | #include "key-container.hpp" |
| 23 | #include "pib-impl.hpp" |
| 24 | |
| 25 | namespace ndn { |
| 26 | namespace security { |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 27 | namespace pib { |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 28 | |
| 29 | KeyContainer::const_iterator::const_iterator(const Name& identity, |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 30 | std::set<Name>::const_iterator it, |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 31 | shared_ptr<PibImpl> impl) |
| 32 | : m_identity(identity) |
| 33 | , m_it(it) |
| 34 | , m_impl(impl) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | Key |
| 39 | KeyContainer::const_iterator::operator*() |
| 40 | { |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 41 | return Key(*m_it, m_impl); |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | KeyContainer::const_iterator& |
| 45 | KeyContainer::const_iterator::operator++() |
| 46 | { |
| 47 | ++m_it; |
| 48 | return *this; |
| 49 | } |
| 50 | |
| 51 | KeyContainer::const_iterator |
| 52 | KeyContainer::const_iterator::operator++(int) |
| 53 | { |
| 54 | const_iterator it(*this); |
| 55 | ++m_it; |
| 56 | return it; |
| 57 | } |
| 58 | |
| 59 | bool |
| 60 | KeyContainer::const_iterator::operator==(const const_iterator& other) |
| 61 | { |
| 62 | return (m_impl == other.m_impl && m_identity == other.m_identity && m_it == other.m_it); |
| 63 | } |
| 64 | |
| 65 | bool |
| 66 | KeyContainer::const_iterator::operator!=(const const_iterator& other) |
| 67 | { |
| 68 | return !(*this == other); |
| 69 | } |
| 70 | |
| 71 | KeyContainer::KeyContainer() |
| 72 | { |
| 73 | } |
| 74 | |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 75 | KeyContainer::KeyContainer(const Name& identity, std::set<Name>&& keyNames, shared_ptr<PibImpl> impl) |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 76 | : m_identity(identity) |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 77 | , m_keyNames(keyNames) |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 78 | , m_impl(impl) |
| 79 | { |
| 80 | } |
| 81 | |
| 82 | KeyContainer::const_iterator |
| 83 | KeyContainer::begin() const |
| 84 | { |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 85 | return const_iterator(m_identity, m_keyNames.begin(), m_impl); |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | KeyContainer::const_iterator |
| 89 | KeyContainer::end() const |
| 90 | { |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 91 | return const_iterator(m_identity, m_keyNames.end(), m_impl); |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | KeyContainer::const_iterator |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 95 | KeyContainer::find(const Name& keyName) const |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 96 | { |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 97 | return const_iterator(m_identity, m_keyNames.find(keyName), m_impl); |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | size_t |
| 101 | KeyContainer::size() const |
| 102 | { |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 103 | return m_keyNames.size(); |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame^] | 106 | } // namespace pib |
Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 107 | } // namespace security |
| 108 | } // namespace ndn |