Kea  1.9.9-git
rrparamregistry.h
Go to the documentation of this file.
1 // Copyright (C) 2010-2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef RRPARAMREGISTRY_H
8 #define RRPARAMREGISTRY_H 1
9 
10 #include <string>
11 
12 #include <stdint.h>
13 
14 #include <boost/shared_ptr.hpp>
15 
16 #include <dns/exceptions.h>
17 
18 #include <dns/rdata.h>
19 
20 namespace isc {
21 namespace dns {
22 
23 // forward declarations
24 struct RRParamRegistryImpl;
25 
31 public:
32  RRTypeExists(const char* file, size_t line, const char* what) :
33  isc::dns::Exception(file, line, what) {}
34 };
35 
41 public:
42  RRClassExists(const char* file, size_t line, const char* what) :
43  isc::dns::Exception(file, line, what) {}
44 };
45 
46 namespace rdata {
61 
62 protected:
68 public:
70  virtual ~AbstractRdataFactory() {};
72 
76 
77 
85  virtual RdataPtr create(const std::string& rdata_str) const = 0;
86 
97  virtual RdataPtr create(isc::util::InputBuffer& buffer, size_t rdata_len) const = 0;
98 
112  virtual RdataPtr create(const rdata::Rdata& source) const = 0;
113 
120  virtual RdataPtr create(MasterLexer& lexer, const Name* origin,
121  MasterLoader::Options options,
122  MasterLoaderCallbacks& callbacks) const = 0;
124 };
125 
130 typedef boost::shared_ptr<AbstractRdataFactory> RdataFactoryPtr;
131 } // end of namespace rdata
132 
176 
177 private:
178  RRParamRegistry();
179  RRParamRegistry(const RRParamRegistry& orig);
180  ~RRParamRegistry();
182 public:
201  static RRParamRegistry& getRegistry();
202 
206 
207  void add(const std::string& type_string, uint16_t type_code,
232  const std::string& class_string, uint16_t class_code,
233  rdata::RdataFactoryPtr rdata_factory);
234 
244  void add(const std::string& type_string, uint16_t type_code,
245  rdata::RdataFactoryPtr rdata_factory);
246 
274  bool addType(const std::string& type_string, uint16_t type_code);
275 
288  bool removeType(uint16_t type_code);
289 
317  bool addClass(const std::string& class_string, uint16_t class_code);
318 
331  bool removeClass(uint16_t class_code);
332 
347  bool removeRdataFactory(const RRType& rrtype, const RRClass& rrclass);
348 
362  bool removeRdataFactory(const RRType& rrtype);
364 
368 
369  bool textToTypeCode(const std::string& type_string,
387  uint16_t& type_code) const;
388 
404  std::string codeToTypeText(uint16_t type_code) const;
405 
424  bool textToClassCode(const std::string& class_string,
425  uint16_t& class_code) const;
426 
442  std::string codeToClassText(uint16_t class_code) const;
444 
464 
465  rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
476  const std::string& rdata_string);
490  rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
491  isc::util::InputBuffer& buffer, size_t len);
514  rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
515  const rdata::Rdata& source);
516 
529  rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
530  MasterLexer& lexer, const Name* origin,
531  MasterLoader::Options options,
532  MasterLoaderCallbacks& callbacks);
534 
535 private:
536  RRParamRegistryImpl* impl_;
537 };
538 
539 }
540 }
541 #endif // RRPARAMREGISTRY_H
542 
543 // Local Variables:
544 // mode: c++
545 // End:
The Name class encapsulates DNS names.
Definition: name.h:223
static RRParamRegistry & getRegistry()
Return the singleton instance of RRParamRegistry.
The RRParamRegistryImpl class is the actual implementation of RRParamRegistry.
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
Definition: rdata.h:123
void add(const std::string &type_string, uint16_t type_code, const std::string &class_string, uint16_t class_code, rdata::RdataFactoryPtr rdata_factory)
Add a set of parameters for a pair of RR type and class.
bool removeType(uint16_t type_code)
Remove mappings between RR type code and textual representation for a given type. ...
virtual ~AbstractRdataFactory()
The destructor.
rdata::RdataPtr createRdata(const RRType &rrtype, const RRClass &rrclass, const std::string &rdata_string)
Create RDATA of a given pair of RR type and class from a string.
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
AbstractRdataFactory()
The default constructor.
RRTypeExists(const char *file, size_t line, const char *what)
Options
Options how the parsing should work.
Definition: master_loader.h:39
The AbstractRdataFactory class is an abstract base class to encapsulate a set of Rdata factory method...
A standard DNS module exception that is thrown if a new RR class is being registered with a different...
RRClassExists(const char *file, size_t line, const char *what)
bool removeRdataFactory(const RRType &rrtype, const RRClass &rrclass)
Remove registered RDATA factory for the given pair of RRType and RRClass.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The RRParamRegistry class represents a registry of parameters to manipulate DNS resource records (RRs...
boost::shared_ptr< AbstractRdataFactory > RdataFactoryPtr
The RdataFactoryPtr type is a pointer-like type, pointing to an object of some concrete derived class...
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool removeClass(uint16_t class_code)
Remove mappings between RR class code and textual representation for a given class.
bool textToTypeCode(const std::string &type_string, uint16_t &type_code) const
Convert a textual representation of an RR type to the corresponding 16-bit integer code...
A standard DNS module exception that is thrown if a new RR type is being registered with a different ...
bool textToClassCode(const std::string &class_string, uint16_t &class_code) const
Convert a textual representation of an RR class to the corresponding 16-bit integer code...
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition: buffer.h:81
virtual RdataPtr create(const std::string &rdata_str) const =0
Create RDATA from a string.
bool addType(const std::string &type_string, uint16_t type_code)
Add mappings between RR type code and textual representation.
bool addClass(const std::string &class_string, uint16_t class_code)
Add mappings between RR class code and textual representation.
Tokenizer for parsing DNS master files.
Definition: master_lexer.h:301
Set of issue callbacks for a loader.
std::string codeToClassText(uint16_t class_code) const
Convert class code into its textual representation.
boost::shared_ptr< Rdata > RdataPtr
The RdataPtr type is a pointer-like type, pointing to an object of some concrete derived class of Rda...
std::string codeToTypeText(uint16_t type_code) const
Convert type code into its textual representation.