Stellarium 0.15.2
APIController.hpp
1 /*
2  * Stellarium Remote Control plugin
3  * Copyright (C) 2015 Florian Schaukowitsch
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef APIHANDLER_HPP_
21 #define APIHANDLER_HPP_
22 
24 #include "AbstractAPIService.hpp"
25 
26 #include <QMutex>
27 
33 {
34  Q_OBJECT
35 public:
39  APIController(int prefixLength, QObject* parent = 0);
40  virtual ~APIController();
41 
44  void update(double deltaTime);
45 
52  virtual void service(HttpRequest& request, HttpResponse& response);
53 
56  void registerService(AbstractAPIService* service);
57 private:
58  int m_prefixLength;
59  typedef QMap<QByteArray,AbstractAPIService*> ServiceMap;
60  ServiceMap m_serviceMap;
61  QMutex mutex;
62 };
63 
64 #endif
The request handler generates a response for each HTTP request.
APIController(int prefixLength, QObject *parent=0)
Constructs an APIController.
virtual void service(HttpRequest &request, HttpResponse &response)
Handles an API-specific request.
Abstract base class for all Remote Control Plug-in service implementations.
void update(double deltaTime)
Should be called each frame from the main thread, like from StelModule::update.
void registerService(AbstractAPIService *service)
Registers a service with the APIController.
This object represents a single HTTP request.
Definition: httprequest.h:36
This class handles the API-specific requests and dispatches them to the correct AbstractAPISerice imp...
This object represents a HTTP response, used to return something to the web client.
Definition: httpresponse.h:35