blob: e4a3ff3fbf147319115c51a099d7e032e7caf653 [file] [log] [blame]
Yingdi Yu77627ab2015-07-21 16:13:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Yingdi Yu0a312e52015-07-22 13:14:53 -07003 * Copyright (c) 2014-2015, Regents of the University of California.
Yingdi Yu77627ab2015-07-21 16:13:49 -07004 *
Yingdi Yu0a312e52015-07-22 13:14:53 -07005 * This file is part of ndn-tools (Named Data Networking Essential Tools).
6 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
Yingdi Yu77627ab2015-07-21 16:13:49 -07007 *
Yingdi Yu0a312e52015-07-22 13:14:53 -07008 * ndn-tools 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.
Yingdi Yu77627ab2015-07-21 16:13:49 -070011 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070012 * ndn-tools 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.
Yingdi Yu77627ab2015-07-21 16:13:49 -070015 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070016 * You should have received a copy of the GNU General Public License along with
17 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Yingdi Yu77627ab2015-07-21 16:13:49 -070018 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070019 * @author Yingdi Yu <yingdi@cs.ucla.edu>
Yingdi Yu77627ab2015-07-21 16:13:49 -070020 */
21
Yingdi Yu0a312e52015-07-22 13:14:53 -070022#ifndef NDN_TOOLS_PIB_DEFAULT_QUERY_PROCESSOR_HPP
23#define NDN_TOOLS_PIB_DEFAULT_QUERY_PROCESSOR_HPP
Yingdi Yu77627ab2015-07-21 16:13:49 -070024
25#include "pib-db.hpp"
26#include "encoding/default-param.hpp"
27#include <ndn-cxx/interest.hpp>
28#include <utility>
29
30namespace ndn {
31namespace pib {
32
33class DefaultQueryProcessor : noncopyable
34{
35public:
36 class Error : public std::runtime_error
37 {
38 public:
39 explicit
40 Error(const std::string& what)
41 : std::runtime_error(what)
42 {
43 }
44 };
45
46 /**
47 * @brief Constructor
48 *
49 * @param db The pib database.
50 */
51 explicit
52 DefaultQueryProcessor(PibDb& db);
53
54 std::pair<bool, Block>
55 operator()(const Interest& interest);
56
57private:
58 std::pair<bool, Block>
59 processDefaultIdQuery(const DefaultParam& param);
60
61 std::pair<bool, Block>
62 processDefaultKeyQuery(const DefaultParam& param);
63
64 std::pair<bool, Block>
65 processDefaultCertQuery(const DefaultParam& param);
66
67private:
68 static const size_t DEFAULT_QUERY_LENGTH;
69
70 const PibDb& m_db;
71};
72
73} // namespace pib
74} // namespace ndn
75
Yingdi Yu0a312e52015-07-22 13:14:53 -070076#endif // NDN_TOOLS_PIB_DEFAULT_QUERY_PROCESSOR_HPP