blob: 8fb8cd3f95b042fc785f8183db06779143537caa [file] [log] [blame]
Steve DiBenedetto042bfe92014-01-30 15:05:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NFD_MGMT_MANAGER_BASE_HPP
8#define NFD_MGMT_MANAGER_BASE_HPP
9
10#include "common.hpp"
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080011#include <ndn-cpp-dev/management/nfd-control-response.hpp>
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070012
13namespace nfd {
14
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080015using ndn::nfd::ControlResponse;
16
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070017class AppFace;
18
19class ManagerBase
20{
21public:
22 ManagerBase(shared_ptr<AppFace> face);
23
24 virtual
25 ~ManagerBase();
26
27protected:
28
Steve DiBenedetto3970c892014-01-31 23:31:13 -070029 void
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080030 setResponse(ControlResponse& response,
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070031 uint32_t code,
32 const std::string& text);
Steve DiBenedetto2693db92014-02-10 15:58:36 -070033 void
34 setResponse(ControlResponse& response,
35 uint32_t code,
36 const std::string& text,
37 const Block& body);
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070038
39 void
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070040 sendResponse(const Name& name,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080041 const ControlResponse& response);
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070042
43 void
44 sendResponse(const Name& name,
45 uint32_t code,
46 const std::string& text);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070047
48protected:
49 shared_ptr<AppFace> m_face;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070050};
51
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070052inline void
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080053ManagerBase::setResponse(ControlResponse& response,
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070054 uint32_t code,
55 const std::string& text)
56{
57 response.setCode(code);
58 response.setText(text);
59}
60
Steve DiBenedetto2693db92014-02-10 15:58:36 -070061inline void
62ManagerBase::setResponse(ControlResponse& response,
63 uint32_t code,
64 const std::string& text,
65 const Block& body)
66{
67 setResponse(response, code, text);
68 response.setBody(body);
69}
70
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070071
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070072} // namespace nfd
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070073
74#endif // NFD_MGMT_MANAGER_BASE_HPP
75