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