All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
config-rule.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_CONFIG_RULE_HPP
24 #define NDN_CONFIG_RULE_HPP
25 
26 #include "config-filter.hpp"
27 #include "config-checker.hpp"
28 
29 namespace ndn {
30 
31 class BoostInfoTree;
32 
36 class ConfigRule {
37 public:
44  ConfigRule(const std::string& id, bool isForInterest)
45  : id_(id),
46  isForInterest_(isForInterest)
47  {
48  }
49 
54  const std::string&
55  getId() const { return id_; }
56 
62  bool
63  getIsForInterest() const { return isForInterest_; }
64 
69  void
70  addFilter(const ptr_lib::shared_ptr<ConfigFilter>& filter)
71  {
72  filters_.push_back(filter);
73  }
74 
79  void
80  addChecker(const ptr_lib::shared_ptr<ConfigChecker>& checker)
81  {
82  checkers_.push_back(checker);
83  }
84 
97  bool
98  match(bool isForInterest, const Name& packetName);
99 
114  bool
115  check
116  (bool isForInterest, const Name& packetName, const Name& keyLocatorName,
117  const ptr_lib::shared_ptr<ValidationState>& state);
118 
125  static ptr_lib::shared_ptr<ConfigRule>
126  create(const BoostInfoTree& configSection);
127 
128 private:
129  // Disable the copy constructor and assignment operator.
130  ConfigRule(const ConfigRule& other);
131  ConfigRule& operator=(const ConfigRule& other);
132 
133  std::string id_;
134  bool isForInterest_;
135  std::vector<ptr_lib::shared_ptr<ConfigFilter>> filters_;
136  std::vector<ptr_lib::shared_ptr<ConfigChecker>> checkers_;
137 };
138 
139 }
140 
141 #endif
const std::string & getId() const
Get the rule ID.
Definition: config-rule.hpp:55
void addChecker(const ptr_lib::shared_ptr< ConfigChecker > &checker)
Add the ConfigChecker to the list of checkers.
Definition: config-rule.hpp:80
void addFilter(const ptr_lib::shared_ptr< ConfigFilter > &filter)
Add the ConfigFilter to the list of filters.
Definition: config-rule.hpp:70
BoostInfoTree is provided for compatibility with the Boost INFO property list format used in ndn-cxx...
Definition: boost-info-parser.hpp:46
A ConfigRule represents a rule configuration section, used by ConfigValidator.
Definition: config-rule.hpp:36
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
bool getIsForInterest() const
Get the isForInterest flag.
Definition: config-rule.hpp:63
bool check(bool isForInterest, const Name &packetName, const Name &keyLocatorName, const ptr_lib::shared_ptr< ValidationState > &state)
Check if the packet satisfies the rule's condition.
bool match(bool isForInterest, const Name &packetName)
Check if the packet name matches the rule's filter.
ConfigRule(const std::string &id, bool isForInterest)
Create a ConfigRule with empty filters and checkers.
Definition: config-rule.hpp:44
static ptr_lib::shared_ptr< ConfigRule > create(const BoostInfoTree &configSection)
Create a rule from configuration section.