All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
registered-prefix.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
7 #ifndef NDN_DETAIL_REGISTERED_PREFIX_HPP
8 #define NDN_DETAIL_REGISTERED_PREFIX_HPP
9 
10 #include "../common.hpp"
11 #include "../name.hpp"
12 #include "../interest.hpp"
13 
14 namespace ndn {
15 
17 {
18 public:
19  typedef function<void (const Name&, const Interest&)> OnInterest;
20 
26  RegisteredPrefix(const Name& prefix, const OnInterest& onInterest)
27  : m_prefix(new Name(prefix))
28  , m_onInterest(onInterest)
29  {
30  }
31 
32  const Name&
33  getPrefix() const
34  {
35  return* m_prefix;
36  }
37 
38  const OnInterest&
39  getOnInterest() const
40  {
41  return m_onInterest;
42  }
43 
44 private:
45  shared_ptr<Name> m_prefix;
46  const OnInterest m_onInterest;
47 };
48 
49 
50 struct RegisteredPrefixId;
51 
56 {
57  MatchRegisteredPrefixId(const RegisteredPrefixId* registeredPrefixId)
58  : m_id(registeredPrefixId)
59  {
60  }
61 
62  bool
63  operator()(const shared_ptr<RegisteredPrefix>& registeredPrefix) const
64  {
65  return (reinterpret_cast<const RegisteredPrefixId*>(registeredPrefix.get()) == m_id);
66  }
67 private:
68  const RegisteredPrefixId* m_id;
69 };
70 
71 } // namespace ndn
72 
73 #endif // NDN_DETAIL_REGISTERED_PREFIX_HPP
const OnInterest & getOnInterest() const
const Name & getPrefix() const
function< void(const Name &, const Interest &)> OnInterest
An OnInterest function object is used to pass a callback to registerPrefix.
Definition: face.hpp:42
bool operator()(const shared_ptr< RegisteredPrefix > &registeredPrefix) const
Functor to match pending interests against PendingInterestId.
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:26
function< void(const Name &, const Interest &)> OnInterest
MatchRegisteredPrefixId(const RegisteredPrefixId *registeredPrefixId)
RegisteredPrefix(const Name &prefix, const OnInterest &onInterest)
Create a new PrefixEntry.