blob: 9799d0321aff9402473e6e1da4997a76fc60d7e4 [file] [log] [blame]
Yingdi Yub8f8b342015-04-27 11:06:42 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2015 Regents of the University of California.
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#ifndef NDN_SECURITY_KEY_CONTAINER_HPP
23#define NDN_SECURITY_KEY_CONTAINER_HPP
24
25#include <set>
26#include "key.hpp"
27
28namespace ndn {
29namespace security {
30
31class PibImpl;
32
33/// @brief A handler to search or enumerate keys of an identity.
34class KeyContainer
35{
36public:
37 class const_iterator
38 {
39 public:
40 friend class KeyContainer;
41
42 public:
43 Key
44 operator*();
45
46 const_iterator&
47 operator++();
48
49 const_iterator
50 operator++(int);
51
52 bool
53 operator==(const const_iterator& other);
54
55 bool
56 operator!=(const const_iterator& other);
57
58 private:
59 const_iterator(const Name& identity,
60 std::set<name::Component>::const_iterator it,
61 shared_ptr<PibImpl> impl);
62
63 private:
64 Name m_identity;
65 std::set<name::Component>::const_iterator m_it;
66 shared_ptr<PibImpl> m_impl;
67 };
68
69 typedef const_iterator iterator;
70
71public:
72 KeyContainer();
73
74 KeyContainer(const Name& identity,
75 std::set<name::Component>&& keyIds,
76 shared_ptr<PibImpl> impl);
77
78 const_iterator
79 begin() const;
80
81 const_iterator
82 end() const;
83
84 const_iterator
85 find(const name::Component& keyId) const;
86
87 size_t
88 size() const;
89
90private:
91 Name m_identity;
92 std::set<name::Component> m_keyIds;
93 shared_ptr<PibImpl> m_impl;
94};
95
96} // namespace security
97} // namespace ndn
98
99#endif // NDN_SECURITY_KEY_CONTAINER_HPP