blob: 605be8b3e6a5adce9ea41e3697a2dc90eed6cf69 [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 "identity-container.hpp"
23#include "pib-impl.hpp"
24
25namespace ndn {
26namespace security {
27
28IdentityContainer::const_iterator::const_iterator(std::set<Name>::const_iterator it,
29 shared_ptr<PibImpl> impl)
30 : m_it(it)
31 , m_impl(impl)
32{
33}
34
35Identity
36IdentityContainer::const_iterator::operator*()
37{
38 return Identity(*m_it, m_impl);
39}
40
41IdentityContainer::const_iterator&
42IdentityContainer::const_iterator::operator++()
43{
44 ++m_it;
45 return *this;
46}
47
48IdentityContainer::const_iterator
49IdentityContainer::const_iterator::operator++(int)
50{
51 const_iterator it(*this);
52 ++m_it;
53 return it;
54}
55
56bool
57IdentityContainer::const_iterator::operator==(const const_iterator& other)
58{
59 return (m_impl == other.m_impl && m_it == other.m_it);
60}
61
62bool
63IdentityContainer::const_iterator::operator!=(const const_iterator& other)
64{
65 return !(*this == other);
66}
67
68IdentityContainer::IdentityContainer()
69{
70}
71
72IdentityContainer::IdentityContainer(std::set<Name>&& identities,
73 shared_ptr<PibImpl> impl)
74 : m_identities(identities)
75 , m_impl(impl)
76{
77}
78
79IdentityContainer::const_iterator
80IdentityContainer::begin() const
81{
82 return const_iterator(m_identities.begin(), m_impl);
83}
84
85IdentityContainer::const_iterator
86IdentityContainer::end() const
87{
88 return const_iterator(m_identities.end(), m_impl);
89}
90
91IdentityContainer::const_iterator
92IdentityContainer::find(const Name& identity) const
93{
94 return const_iterator(m_identities.find(identity), m_impl);
95}
96
97size_t
98IdentityContainer::size() const
99{
100 return m_identities.size();
101}
102
103} // namespace security
104} // namespace ndn