NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
unsolicited-data-policy.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_FW_UNSOLICITED_DATA_POLICY_HPP
27 #define NFD_DAEMON_FW_UNSOLICITED_DATA_POLICY_HPP
28 
29 #include "face/face.hpp"
30 
31 namespace nfd {
32 namespace fw {
33 
37  DROP,
38  CACHE
39 };
40 
41 std::ostream&
42 operator<<(std::ostream& os, UnsolicitedDataDecision d);
43 
50 class UnsolicitedDataPolicy : noncopyable
51 {
52 public:
53  virtual ~UnsolicitedDataPolicy() = default;
54 
56  decide(const Face& inFace, const Data& data) const = 0;
57 
58 public: // registry
59  template<typename P>
60  static void
61  registerPolicy(const std::string& key)
62  {
63  Registry& registry = getRegistry();
64  BOOST_ASSERT(registry.count(key) == 0);
65  registry[key] = [] { return make_unique<P>(); };
66  }
67 
70  static unique_ptr<UnsolicitedDataPolicy>
71  create(const std::string& key);
72 
73 private:
74  typedef std::function<unique_ptr<UnsolicitedDataPolicy>()> CreateFunc;
75  typedef std::map<std::string, CreateFunc> Registry; // indexed by key
76 
77  static Registry&
78  getRegistry();
79 };
80 
84 {
85 public:
87  decide(const Face& inFace, const Data& data) const final;
88 };
89 
93 {
94 public:
96  decide(const Face& inFace, const Data& data) const final;
97 };
98 
102 {
103 public:
105  decide(const Face& inFace, const Data& data) const final;
106 };
107 
111 {
112 public:
114  decide(const Face& inFace, const Data& data) const final;
115 };
116 
120 
121 } // namespace fw
122 } // namespace nfd
123 
128 #define NFD_REGISTER_UNSOLICITED_DATA_POLICY(P, key) \
129 static class NfdAuto ## P ## UnsolicitedDataPolicyRegistrationClass \
130 { \
131 public: \
132  NfdAuto ## P ## UnsolicitedDataPolicyRegistrationClass() \
133  { \
134  ::nfd::fw::UnsolicitedDataPolicy::registerPolicy<P>(key); \
135  } \
136 } g_nfdAuto ## P ## UnsolicitedDataPolicyRegistrationVariable
137 
138 #endif // NFD_DAEMON_FW_UNSOLICITED_DATA_POLICY_HPP
generalization of a network interface
Definition: face.hpp:67
determines how to process an unsolicited Data
static void registerPolicy(const std::string &key)
admits unsolicited Data from local faces
DropAllUnsolicitedDataPolicy DefaultUnsolicitedDataPolicy
the default UnsolicitedDataPolicy
admits unsolicited Data from non-local faces
the Data should be dropped
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
UnsolicitedDataDecision
a decision made by UnsolicitedDataPolicy
the Data should be cached in the ContentStore
std::ostream & operator<<(std::ostream &os, UnsolicitedDataDecision d)
represents a Data packet
Definition: data.hpp:37