blob: 7653955ecaa22e959a592d0e3dcd7b5d9585a3c1 [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
22#include "key-container.hpp"
23#include "pib-impl.hpp"
24
25namespace ndn {
26namespace security {
Yingdi Yu6ee2d362015-07-16 21:48:05 -070027namespace pib {
Yingdi Yub8f8b342015-04-27 11:06:42 -070028
29KeyContainer::const_iterator::const_iterator(const Name& identity,
Yingdi Yu6ee2d362015-07-16 21:48:05 -070030 std::set<Name>::const_iterator it,
Yingdi Yub8f8b342015-04-27 11:06:42 -070031 shared_ptr<PibImpl> impl)
32 : m_identity(identity)
33 , m_it(it)
34 , m_impl(impl)
35{
36}
37
38Key
39KeyContainer::const_iterator::operator*()
40{
Yingdi Yu6ee2d362015-07-16 21:48:05 -070041 return Key(*m_it, m_impl);
Yingdi Yub8f8b342015-04-27 11:06:42 -070042}
43
44KeyContainer::const_iterator&
45KeyContainer::const_iterator::operator++()
46{
47 ++m_it;
48 return *this;
49}
50
51KeyContainer::const_iterator
52KeyContainer::const_iterator::operator++(int)
53{
54 const_iterator it(*this);
55 ++m_it;
56 return it;
57}
58
59bool
60KeyContainer::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
65bool
66KeyContainer::const_iterator::operator!=(const const_iterator& other)
67{
68 return !(*this == other);
69}
70
71KeyContainer::KeyContainer()
72{
73}
74
Yingdi Yu6ee2d362015-07-16 21:48:05 -070075KeyContainer::KeyContainer(const Name& identity, std::set<Name>&& keyNames, shared_ptr<PibImpl> impl)
Yingdi Yub8f8b342015-04-27 11:06:42 -070076 : m_identity(identity)
Yingdi Yu6ee2d362015-07-16 21:48:05 -070077 , m_keyNames(keyNames)
Yingdi Yub8f8b342015-04-27 11:06:42 -070078 , m_impl(impl)
79{
80}
81
82KeyContainer::const_iterator
83KeyContainer::begin() const
84{
Yingdi Yu6ee2d362015-07-16 21:48:05 -070085 return const_iterator(m_identity, m_keyNames.begin(), m_impl);
Yingdi Yub8f8b342015-04-27 11:06:42 -070086}
87
88KeyContainer::const_iterator
89KeyContainer::end() const
90{
Yingdi Yu6ee2d362015-07-16 21:48:05 -070091 return const_iterator(m_identity, m_keyNames.end(), m_impl);
Yingdi Yub8f8b342015-04-27 11:06:42 -070092}
93
94KeyContainer::const_iterator
Yingdi Yu6ee2d362015-07-16 21:48:05 -070095KeyContainer::find(const Name& keyName) const
Yingdi Yub8f8b342015-04-27 11:06:42 -070096{
Yingdi Yu6ee2d362015-07-16 21:48:05 -070097 return const_iterator(m_identity, m_keyNames.find(keyName), m_impl);
Yingdi Yub8f8b342015-04-27 11:06:42 -070098}
99
100size_t
101KeyContainer::size() const
102{
Yingdi Yu6ee2d362015-07-16 21:48:05 -0700103 return m_keyNames.size();
Yingdi Yub8f8b342015-04-27 11:06:42 -0700104}
105
Yingdi Yu6ee2d362015-07-16 21:48:05 -0700106} // namespace pib
Yingdi Yub8f8b342015-04-27 11:06:42 -0700107} // namespace security
108} // namespace ndn