Yingdi Yu | b8f8b34 | 2015-04-27 11:06:42 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 97709c0 | 2016-08-25 19:58:30 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2013-2016 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 { |
| 27 | |
| 28 | KeyContainer::const_iterator::const_iterator(const Name& identity, |
| 29 | std::set<name::Component>::const_iterator it, |
| 30 | shared_ptr<PibImpl> impl) |
| 31 | : m_identity(identity) |
| 32 | , m_it(it) |
| 33 | , m_impl(impl) |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | Key |
| 38 | KeyContainer::const_iterator::operator*() |
| 39 | { |
| 40 | return Key(m_identity, *m_it, m_impl); |
| 41 | } |
| 42 | |
| 43 | KeyContainer::const_iterator& |
| 44 | KeyContainer::const_iterator::operator++() |
| 45 | { |
| 46 | ++m_it; |
| 47 | return *this; |
| 48 | } |
| 49 | |
| 50 | KeyContainer::const_iterator |
| 51 | KeyContainer::const_iterator::operator++(int) |
| 52 | { |
| 53 | const_iterator it(*this); |
| 54 | ++m_it; |
| 55 | return it; |
| 56 | } |
| 57 | |
| 58 | bool |
| 59 | KeyContainer::const_iterator::operator==(const const_iterator& other) |
| 60 | { |
| 61 | return (m_impl == other.m_impl && m_identity == other.m_identity && m_it == other.m_it); |
| 62 | } |
| 63 | |
| 64 | bool |
| 65 | KeyContainer::const_iterator::operator!=(const const_iterator& other) |
| 66 | { |
| 67 | return !(*this == other); |
| 68 | } |
| 69 | |
| 70 | KeyContainer::KeyContainer() |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | KeyContainer::KeyContainer(const Name& identity, |
| 75 | std::set<name::Component>&& keyIds, |
| 76 | shared_ptr<PibImpl> impl) |
| 77 | : m_identity(identity) |
| 78 | , m_keyIds(keyIds) |
| 79 | , m_impl(impl) |
| 80 | { |
| 81 | } |
| 82 | |
| 83 | KeyContainer::const_iterator |
| 84 | KeyContainer::begin() const |
| 85 | { |
| 86 | return const_iterator(m_identity, m_keyIds.begin(), m_impl); |
| 87 | } |
| 88 | |
| 89 | KeyContainer::const_iterator |
| 90 | KeyContainer::end() const |
| 91 | { |
| 92 | return const_iterator(m_identity, m_keyIds.end(), m_impl); |
| 93 | } |
| 94 | |
| 95 | KeyContainer::const_iterator |
| 96 | KeyContainer::find(const name::Component& keyId) const |
| 97 | { |
| 98 | return const_iterator(m_identity, m_keyIds.find(keyId), m_impl); |
| 99 | } |
| 100 | |
| 101 | size_t |
| 102 | KeyContainer::size() const |
| 103 | { |
| 104 | return m_keyIds.size(); |
| 105 | } |
| 106 | |
| 107 | } // namespace security |
| 108 | } // namespace ndn |