KISSCPP
a C++ library for rapid application development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
request_handler.hpp
Go to the documentation of this file.
1 // File : request_handler.hpp
2 // Author: Dirk J. Botha <bothadj@gmail.com>
3 //
4 // This file is part of kisscpp library.
5 //
6 // The kisscpp library is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // The kisscpp library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with the kisscpp library. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef _SERVER_REQUEST_HANDLER_HPP
20 #define _SERVER_REQUEST_HANDLER_HPP
21 
22 #include <iostream>
23 #include <string>
24 
25 #include <boost/noncopyable.hpp>
26 
27 #include "boost_ptree.hpp"
28 #include "logstream.hpp"
29 
30 namespace kisscpp
31 {
32  //--------------------------------------------------------------------------------
33  class RequestHandler : private boost::noncopyable
34  {
35  public:
36  RequestHandler(const std::string &_id, const std::string &_description) : id(_id), description(_description)
37  {
38  LogStream log(__PRETTY_FUNCTION__);
39  };
40 
41  virtual ~RequestHandler() {};
42 
43  virtual void run(const BoostPtree& request, BoostPtree& response) = 0;
44 
45  std::string commandId() { return id; }
46  std::string getDescription() { return description; }
47 
48  protected:
49  private:
50  std::string id;
51  std::string description;
52  };
53 
54  typedef boost::shared_ptr<RequestHandler> RequestHandlerPtr;
55 
56 }
57 
58 #endif
virtual void run(const BoostPtree &request, BoostPtree &response)=0
virtual ~RequestHandler()
Definition: request_handler.hpp:41
boost::property_tree::ptree BoostPtree
Definition: boost_ptree.hpp:31
std::string getDescription()
Definition: request_handler.hpp:46
boost::shared_ptr< RequestHandler > RequestHandlerPtr
Definition: request_handler.hpp:54
RequestHandler(const std::string &_id, const std::string &_description)
Definition: request_handler.hpp:36
Definition: logstream.hpp:145
std::string commandId()
Definition: request_handler.hpp:45
Definition: request_handler.hpp:33