Stellarium  0.90.0
AbstractAPIService.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 ABSTRACTAPISERVICE_HPP_
21 #define ABSTRACTAPISERVICE_HPP_
22 
23 #include "RemoteControlServiceInterface.hpp"
24 
27 
29 class AbstractAPIService : public QObject, public RemoteControlServiceInterface
30 {
31  Q_OBJECT
32  //Probably not really necessary to do this here but it probably won't hurt either
33  Q_INTERFACES(RemoteControlServiceInterface)
34 public:
36  AbstractAPIService(QObject* parent = Q_NULLPTR) : QObject(parent)
37  {
38  }
39 
40  // Provides a default implementation which returns false.
41  virtual bool isThreadSafe() const Q_DECL_OVERRIDE;
44  virtual void update(double deltaTime) Q_DECL_OVERRIDE;
46  virtual void get(const QByteArray &operation, const APIParameters &parameters, APIServiceResponse& response) Q_DECL_OVERRIDE;
48  virtual void post(const QByteArray &operation, const APIParameters &parameters, const QByteArray& data, APIServiceResponse& response) Q_DECL_OVERRIDE;
49 
50 protected:
53  static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE;
54 };
55 
57 
58 #endif
AbstractAPIService(QObject *parent=Q_NULLPTR)
Only calls QObject constructor.
virtual bool isThreadSafe() const Q_DECL_OVERRIDE
Return true if the service's get() and post() methods can safely be run in the HTTP handler thread...
virtual void post(const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE
Provides a default implementation which returns an error message.
Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod.
virtual void update(double deltaTime) Q_DECL_OVERRIDE
Called in the main thread each frame.
static const Qt::ConnectionType SERVICE_DEFAULT_INVOKETYPE
This defines the connection type QMetaObject::invokeMethod has to use inside a service: either Qt::Di...
Abstract base class for all RemoteControlServiceInterface implementations which are provided by the R...
QMultiMap< QByteArray, QByteArray > APIParameters
Defines the HTTP request parameters for the service.
Interface for all Remote Control Plug-in services.