All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
config-checker.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_CONFIG_CHECKER_HPP
24 #define NDN_CONFIG_CHECKER_HPP
25 
26 #include "../../../name.hpp"
27 #include "config-name-relation.hpp"
28 #include "../validation-state.hpp"
29 
30 namespace ndn {
31 
32 class BoostInfoTree;
33 class NdnRegexTopMatcher;
34 
41 public:
42  virtual
43  ~ConfigChecker();
44 
58  bool
59  check
60  (bool isForInterest, const Name& packetName, const Name& keyLocatorName,
61  const ptr_lib::shared_ptr<ValidationState>& state);
62 
69  static ptr_lib::shared_ptr<ConfigChecker>
70  create(const BoostInfoTree& configSection);
71 
72 protected:
73  ConfigChecker() {}
74 
86  virtual bool
88  (const Name& packetName, const Name& keyLocatorName,
89  const ptr_lib::shared_ptr<ValidationState>& state) = 0;
90 
91 private:
92  static ptr_lib::shared_ptr<ConfigChecker>
93  createCustomizedChecker(const BoostInfoTree& configSection);
94 
95  static ptr_lib::shared_ptr<ConfigChecker>
96  createHierarchicalChecker(const BoostInfoTree& configSection);
97 
98  static ptr_lib::shared_ptr<ConfigChecker>
99  createKeyLocatorChecker(const BoostInfoTree& configSection);
100 
101  static ptr_lib::shared_ptr<ConfigChecker>
102  createKeyLocatorNameChecker(const BoostInfoTree& configSection);
103 
104  // Disable the copy constructor and assignment operator.
105  ConfigChecker(const ConfigChecker& other);
106  ConfigChecker& operator=(const ConfigChecker& other);
107 };
108 
110 public:
112  (const Name& name, ConfigNameRelation::Relation relation)
113  : name_(name),
114  relation_(relation)
115  {
116  }
117 
118 protected:
119  virtual bool
120  checkNames
121  (const Name& packetName, const Name& keyLocatorName,
122  const ptr_lib::shared_ptr<ValidationState>& state);
123 
124 private:
125  Name name_;
126  ConfigNameRelation::Relation relation_;
127 };
128 
130 public:
131  ConfigRegexChecker(const std::string& regexString);
132 
133 protected:
134  virtual bool
135  checkNames
136  (const Name& packetName, const Name& keyLocatorName,
137  const ptr_lib::shared_ptr<ValidationState>& state);
138 
139 private:
140  ptr_lib::shared_ptr<NdnRegexTopMatcher> regex_;
141 };
142 
144 public:
146  (const std::string& packetNameRegexString, const std::string& packetNameExpansion,
147  const std::string& keyNameRegexString, const std::string& keyNameExpansion,
148  ConfigNameRelation::Relation hyperRelation);
149 
150 protected:
151  virtual bool
152  checkNames
153  (const Name& packetName, const Name& keyLocatorName,
154  const ptr_lib::shared_ptr<ValidationState>& state);
155 
156 private:
157  ptr_lib::shared_ptr<NdnRegexTopMatcher> packetNameRegex_;
158  std::string packetNameExpansion_;
159  ptr_lib::shared_ptr<NdnRegexTopMatcher> keyNameRegex_;
160  std::string keyNameExpansion_;
161  ConfigNameRelation::Relation hyperRelation_;
162 };
163 
164 }
165 
166 #endif
Definition: config-checker.hpp:109
virtual bool checkNames(const Name &packetName, const Name &keyLocatorName, const ptr_lib::shared_ptr< ValidationState > &state)
Check if the packet name ane KeyLocator name satisfy this checker's conditions.
virtual bool checkNames(const Name &packetName, const Name &keyLocatorName, const ptr_lib::shared_ptr< ValidationState > &state)=0
Check if the packet name ane KeyLocator name satisfy this checker's conditions.
virtual bool checkNames(const Name &packetName, const Name &keyLocatorName, const ptr_lib::shared_ptr< ValidationState > &state)
Check if the packet name ane KeyLocator name satisfy this checker's conditions.
BoostInfoTree is provided for compatibility with the Boost INFO property list format used in ndn-cxx...
Definition: boost-info-parser.hpp:46
static ptr_lib::shared_ptr< ConfigChecker > create(const BoostInfoTree &configSection)
Create a checker from the configuration section.
A ConfigChecker is an abstract base class for ConfigNameRelationChecker, etc.
Definition: config-checker.hpp:40
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
Definition: config-checker.hpp:143
virtual bool checkNames(const Name &packetName, const Name &keyLocatorName, const ptr_lib::shared_ptr< ValidationState > &state)
Check if the packet name ane KeyLocator name satisfy this checker's conditions.
Definition: config-checker.hpp:129
bool check(bool isForInterest, const Name &packetName, const Name &keyLocatorName, const ptr_lib::shared_ptr< ValidationState > &state)
Check if the packet name ane KeyLocator name satisfy this checker's conditions.