NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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
54  ~UnsolicitedDataPolicy() = default;
55 
57  decide(const Face& inFace, const Data& data) const = 0;
58 
59 public: // registry
60  template<typename P>
61  static void
62  registerPolicy(const std::string& policyName = P::POLICY_NAME)
63  {
64  Registry& registry = getRegistry();
65  BOOST_ASSERT(registry.count(policyName) == 0);
66  registry[policyName] = [] { return make_unique<P>(); };
67  }
68 
72  static unique_ptr<UnsolicitedDataPolicy>
73  create(const std::string& policyName);
74 
77  static std::set<std::string>
79 
80 private:
81  typedef std::function<unique_ptr<UnsolicitedDataPolicy>()> CreateFunc;
82  typedef std::map<std::string, CreateFunc> Registry; // indexed by policy name
83 
84  static Registry&
85  getRegistry();
86 };
87 
91 {
92 public:
94  decide(const Face& inFace, const Data& data) const final;
95 
96 public:
97  static const std::string POLICY_NAME;
98 };
99 
103 {
104 public:
106  decide(const Face& inFace, const Data& data) const final;
107 
108 public:
109  static const std::string POLICY_NAME;
110 };
111 
115 {
116 public:
118  decide(const Face& inFace, const Data& data) const final;
119 
120 public:
121  static const std::string POLICY_NAME;
122 };
123 
127 {
128 public:
130  decide(const Face& inFace, const Data& data) const final;
131 
132 public:
133  static const std::string POLICY_NAME;
134 };
135 
139 
140 } // namespace fw
141 } // namespace nfd
142 
147 #define NFD_REGISTER_UNSOLICITED_DATA_POLICY(P) \
148 static class NfdAuto ## P ## UnsolicitedDataPolicyRegistrationClass \
149 { \
150 public: \
151  NfdAuto ## P ## UnsolicitedDataPolicyRegistrationClass() \
152  { \
153  ::nfd::fw::UnsolicitedDataPolicy::registerPolicy<P>(); \
154  } \
155 } g_nfdAuto ## P ## UnsolicitedDataPolicyRegistrationVariable
156 
157 #endif // NFD_DAEMON_FW_UNSOLICITED_DATA_POLICY_HPP
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
generalization of a network interface
Definition: face.hpp:67
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
determines how to process an unsolicited Data
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
admits unsolicited Data from local faces
DropAllUnsolicitedDataPolicy DefaultUnsolicitedDataPolicy
the default UnsolicitedDataPolicy
admits unsolicited Data from non-local faces
the Data should be dropped
static void registerPolicy(const std::string &policyName=P::POLICY_NAME)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
static unique_ptr< UnsolicitedDataPolicy > create(const std::string &policyName)
virtual ~UnsolicitedDataPolicy()=default
UnsolicitedDataDecision
a decision made by UnsolicitedDataPolicy
static std::set< std::string > getPolicyNames()
the Data should be cached in the ContentStore
virtual UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const =0
std::ostream & operator<<(std::ostream &os, UnsolicitedDataDecision d)
Represents a Data packet.
Definition: data.hpp:35
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final