Kea  2.1.7-git
question.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 QUESTION_H
8 #define QUESTION_H 1
9 
10 #include <iostream>
11 #include <string>
12 
13 #include <boost/shared_ptr.hpp>
14 
15 #include <dns/name.h>
16 #include <dns/rrclass.h>
17 #include <dns/rrtype.h>
18 
19 namespace isc {
20 namespace util {
21 class InputBuffer;
22 class OutputBuffer;
23 }
24 
25 namespace dns {
26 
27 class AbstractMessageRenderer;
28 class Question;
29 
31 typedef boost::shared_ptr<Question> QuestionPtr;
32 
34 typedef boost::shared_ptr<const Question> ConstQuestionPtr;
35 
95 class Question {
105 
106 public:
118 
128  Question(const Name& name, const RRClass& rrclass, const RRType& rrtype) :
129  name_(name), rrtype_(rrtype), rrclass_(rrclass)
130  {}
132 
136 
137  const Name& getName() const { return (name_); }
144 
151  const RRType& getType() const { return (rrtype_); }
152 
159  const RRClass& getClass() const { return (rrclass_); }
161 
165 
166  std::string toText(bool newline = false) const;
184 
217  unsigned int toWire(AbstractMessageRenderer& renderer) const;
218 
227  unsigned int toWire(isc::util::OutputBuffer& buffer) const;
229 
233 
234  bool operator <(const Question& rhs) const {
237  return (rrclass_ < rhs.rrclass_ ||
238  (rrclass_ == rhs.rrclass_ &&
239  (rrtype_ < rhs.rrtype_ ||
240  (rrtype_ == rhs.rrtype_ && (name_ < rhs.name_)))));
241  }
242 
248  bool operator==(const Question& rhs) const {
249  return ((rrclass_ == rhs.rrclass_) && (rrtype_ == rhs.rrtype_) &&
250  (name_ == rhs.name_));
251  }
252 
259  bool operator!=(const Question& rhs) const {
260  return (!operator==(rhs));
261  }
263 
264 private:
265  Name name_;
266  RRType rrtype_;
268 };
269 
284 std::ostream& operator<<(std::ostream& os, const Question& question);
285 } // end of namespace dns
286 } // end of namespace isc
287 #endif // QUESTION_H
288 
289 // Local Variables:
290 // mode: c++
291 // End:
The Name class encapsulates DNS names.
Definition: name.h:223
const RRClass & rrclass_
Definition: dns/message.cc:695
bool operator<(Element const &a, Element const &b)
Definition: data.cc:219
The Question class encapsulates the common search key of DNS lookup, consisting of owner name...
Definition: question.h:95
bool operator!=(const Question &rhs) const
Inequality operator.
Definition: question.h:259
Question(const Name &name, const RRClass &rrclass, const RRType &rrtype)
Constructor from fixed parameters of the Question.
Definition: question.h:128
std::ostream & operator<<(std::ostream &os, const CSVRow &row)
Overrides standard output stream operator for CSVRow object.
Definition: csv_file.cc:100
const RRType & rrtype_
Definition: dns/message.cc:694
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
const RRType & getType() const
Returns the RR Class of the Question.
Definition: question.h:151
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
Defines the logger used by the top-level component of kea-lfc.
const Name & name_
Definition: dns/message.cc:693
const RRClass & getClass() const
Returns the RR Type of the Question.
Definition: question.h:159
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
boost::shared_ptr< Question > QuestionPtr
A pointer-like type pointing to an Question object.
Definition: question.h:28
boost::shared_ptr< const Question > ConstQuestionPtr
A pointer-like type pointing to an (immutable) Question object.
Definition: question.h:34
bool operator==(const Question &rhs) const
Equality operator.
Definition: question.h:248