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
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
nfd::fw::UnsolicitedDataDecision
UnsolicitedDataDecision
a decision made by UnsolicitedDataPolicy
Definition: unsolicited-data-policy.hpp:36
nfd::fw::AdmitLocalUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition: unsolicited-data-policy.hpp:109
nfd::fw::UnsolicitedDataPolicy::getPolicyNames
static std::set< std::string > getPolicyNames()
Definition: unsolicited-data-policy.cpp:61
nfd::fw::AdmitNetworkUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition: unsolicited-data-policy.hpp:121
nfd::fw::DropAllUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition: unsolicited-data-policy.hpp:97
nfd::fw::UnsolicitedDataDecision::CACHE
@ CACHE
the Data should be cached in the ContentStore
nfd::fw::AdmitAllUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition: unsolicited-data-policy.hpp:133
nfd::fw::UnsolicitedDataPolicy::create
static unique_ptr< UnsolicitedDataPolicy > create(const std::string &policyName)
Definition: unsolicited-data-policy.cpp:53
nfd::fw::UnsolicitedDataPolicy::registerPolicy
static void registerPolicy(const std::string &policyName=P::POLICY_NAME)
Definition: unsolicited-data-policy.hpp:62
nfd::fw::UnsolicitedDataPolicy
determines how to process an unsolicited Data
Definition: unsolicited-data-policy.hpp:51
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::fw::DropAllUnsolicitedDataPolicy
drops all unsolicited Data
Definition: unsolicited-data-policy.hpp:91
nfd::face::Face
generalization of a network interface
Definition: face.hpp:53
nfd::fw::DefaultUnsolicitedDataPolicy
DropAllUnsolicitedDataPolicy DefaultUnsolicitedDataPolicy
the default UnsolicitedDataPolicy
Definition: unsolicited-data-policy.hpp:138
nfd::fw::UnsolicitedDataPolicy::~UnsolicitedDataPolicy
virtual ~UnsolicitedDataPolicy()=default
face.hpp
nfd::fw::DropAllUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition: unsolicited-data-policy.cpp:73
nfd::fw::AdmitNetworkUnsolicitedDataPolicy
admits unsolicited Data from non-local faces
Definition: unsolicited-data-policy.hpp:115
nfd::fw::AdmitAllUnsolicitedDataPolicy
admits all unsolicited Data
Definition: unsolicited-data-policy.hpp:127
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
nfd::fw::AdmitLocalUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition: unsolicited-data-policy.cpp:82
nfd::fw::operator<<
std::ostream & operator<<(std::ostream &os, UnsolicitedDataDecision d)
Definition: unsolicited-data-policy.cpp:34
nfd::fw::AdmitLocalUnsolicitedDataPolicy
admits unsolicited Data from local faces
Definition: unsolicited-data-policy.hpp:103
nfd::fw::AdmitAllUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition: unsolicited-data-policy.cpp:106
nfd::fw::UnsolicitedDataDecision::DROP
@ DROP
the Data should be dropped
nfd::fw::AdmitNetworkUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition: unsolicited-data-policy.cpp:94
nfd::fw::UnsolicitedDataPolicy::decide
virtual UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const =0