blob: ca30ab9029909389e5a9603bcbdf33b11ff2b29a [file] [log] [blame]
Yingdi Yub8f8b342015-04-27 11:06:42 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev97709c02016-08-25 19:58:30 -07003 * Copyright (c) 2013-2016 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
22#include "key-container.hpp"
23#include "pib-impl.hpp"
24
25namespace ndn {
26namespace security {
27
28KeyContainer::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
37Key
38KeyContainer::const_iterator::operator*()
39{
40 return Key(m_identity, *m_it, m_impl);
41}
42
43KeyContainer::const_iterator&
44KeyContainer::const_iterator::operator++()
45{
46 ++m_it;
47 return *this;
48}
49
50KeyContainer::const_iterator
51KeyContainer::const_iterator::operator++(int)
52{
53 const_iterator it(*this);
54 ++m_it;
55 return it;
56}
57
58bool
59KeyContainer::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
64bool
65KeyContainer::const_iterator::operator!=(const const_iterator& other)
66{
67 return !(*this == other);
68}
69
70KeyContainer::KeyContainer()
71{
72}
73
74KeyContainer::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
83KeyContainer::const_iterator
84KeyContainer::begin() const
85{
86 return const_iterator(m_identity, m_keyIds.begin(), m_impl);
87}
88
89KeyContainer::const_iterator
90KeyContainer::end() const
91{
92 return const_iterator(m_identity, m_keyIds.end(), m_impl);
93}
94
95KeyContainer::const_iterator
96KeyContainer::find(const name::Component& keyId) const
97{
98 return const_iterator(m_identity, m_keyIds.find(keyId), m_impl);
99}
100
101size_t
102KeyContainer::size() const
103{
104 return m_keyIds.size();
105}
106
107} // namespace security
108} // namespace ndn