shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014, Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of NDNS (Named Data Networking Domain Name Service). |
| 6 | * See AUTHORS.md for complete list of NDNS authors and contributors. |
| 7 | * |
| 8 | * NDNS is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef RR_MGR_HPP |
| 21 | #define RR_MGR_HPP |
| 22 | |
| 23 | #include "db-mgr.hpp" |
| 24 | #include "query.hpp" |
| 25 | #include "response.hpp" |
| 26 | #include "zone.hpp" |
| 27 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 28 | namespace ndn { |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 29 | namespace ndns { |
| 30 | class RRMgr: public DBMgr |
| 31 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 32 | public: |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 33 | RRMgr(Zone& zone, Query& query, Response& response); |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 34 | virtual ~RRMgr(); |
| 35 | |
| 36 | public: |
| 37 | int lookup(); |
| 38 | |
| 39 | int callback_getRr(int argc, char **argv, char **azColName); |
| 40 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 41 | static int static_callback_getRr(void *param, int argc, char **argv, |
| 42 | char **azColName) |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 43 | { |
| 44 | RRMgr *mgr = reinterpret_cast<RRMgr*>(param); |
| 45 | return mgr->callback_getRr(argc, argv, azColName); |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 46 | } |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 47 | |
| 48 | int count(); |
| 49 | int callback_countRr(int argc, char **argv, char **azColName); |
| 50 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 51 | static int static_callback_countRr(void *param, int argc, char **argv, |
| 52 | char **azColName) |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 53 | { |
| 54 | RRMgr *mgr = reinterpret_cast<RRMgr*>(param); |
| 55 | return mgr->callback_countRr(argc, argv, azColName); |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 56 | } |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 57 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 58 | const Query& getQuery() const |
| 59 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 60 | return m_query; |
| 61 | } |
| 62 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 63 | void setQuery(const Query& query) |
| 64 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 65 | m_query = query; |
| 66 | } |
| 67 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 68 | const Response& getResponse() const |
| 69 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 70 | return m_response; |
| 71 | } |
| 72 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 73 | void setResponse(const Response& response) |
| 74 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 75 | m_response = response; |
| 76 | } |
| 77 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 78 | const Zone& getZone() const |
| 79 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 80 | return m_zone; |
| 81 | } |
| 82 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 83 | void setZone(const Zone& zone) |
| 84 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 85 | m_zone = zone; |
| 86 | } |
| 87 | |
| 88 | private: |
| 89 | unsigned int m_count; |
| 90 | Zone& m_zone; |
| 91 | Query& m_query; |
| 92 | Response& m_response; |
| 93 | }; |
| 94 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame] | 95 | } //namespace ndns |
| 96 | } /* namespace ndn */ |
| 97 | |
| 98 | #endif /* RR_MGR_HPP_ */ |