All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
pib-key-container.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_PIB_KEY_CONTAINER_HPP
24 #define NDN_PIB_KEY_CONTAINER_HPP
25 
26 #include <set>
27 #include <map>
28 #include "pib-key.hpp"
29 
30 // Give friend access to the tests.
31 class TestPibKeyContainer_Basic_Test;
32 class TestPibKeyContainer_Errors_Test;
33 
34 namespace ndn {
35 
36 class PibKeyImpl;
37 
43 public:
48  size_t
49  size() const { return keyNames_.size(); }
50 
61  ptr_lib::shared_ptr<PibKey>
62  add(const uint8_t* key, size_t keyLength, const Name& keyName);
63 
70  void
71  remove(const Name& keyName);
72 
80  ptr_lib::shared_ptr<PibKey>
81  get(const Name& keyName);
82 
87  ptr_lib::shared_ptr<std::vector<Name> >
88  getKeyNames() const;
89 
96  bool
97  isConsistent() const;
98 
99 private:
100  friend class PibIdentityImpl;
101  // Give friend access to the tests.
102  friend TestPibKeyContainer_Basic_Test;
103  friend TestPibKeyContainer_Errors_Test;
104 
112  (const Name& identityName, const ptr_lib::shared_ptr<PibImpl>& pibImpl);
113 
114  // Disable the copy constructor and assignment operator.
115  PibKeyContainer(const PibKeyContainer& other);
116  PibKeyContainer& operator=(const PibKeyContainer& other);
117 
118  Name identityName_;
119  std::set<Name> keyNames_;
120  // Cache of loaded PibKeyImpl objects.
121  std::map<Name, ptr_lib::shared_ptr<PibKeyImpl>> keys_;
122 
123  ptr_lib::shared_ptr<PibImpl> pibImpl_;
124 };
125 
126 }
127 
128 #endif
bool isConsistent() const
Check if the container is consistent with the backend storage.
Definition: pib-key-container.cpp:107
ptr_lib::shared_ptr< PibKey > add(const uint8_t *key, size_t keyLength, const Name &keyName)
Add a key with name keyName into the container.
Definition: pib-key-container.cpp:43
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
PibIdentityImpl provides the backend implementation for PibIdentity.
Definition: pib-identity-impl.hpp:41
ptr_lib::shared_ptr< std::vector< Name > > getKeyNames() const
Get the names of all the keys in the container.
Definition: pib-key-container.cpp:93
A PibKeyContainer is used to search/enumerate the keys of an identity.
Definition: pib-key-container.hpp:42
size_t size() const
Get the number of keys in the container.
Definition: pib-key-container.hpp:49