Stellarium  0.16.1
List of all members | Public Member Functions
APIController Class Reference

This class handles the API-specific requests and dispatches them to the correct RemoteControlServiceInterface implementation. More...

#include <APIController.hpp>

+ Inheritance diagram for APIController:
+ Collaboration diagram for APIController:

Public Member Functions

 APIController (int prefixLength, QObject *parent=Q_NULLPTR)
 Constructs an APIController. More...
 
void update (double deltaTime)
 Should be called each frame from the main thread, like from StelModule::update. More...
 
virtual void service (HttpRequest &request, HttpResponse &response)
 Handles an API-specific request. More...
 
void registerService (RemoteControlServiceInterface *service)
 Registers a service with the APIController. More...
 
- Public Member Functions inherited from HttpRequestHandler
 HttpRequestHandler (QObject *parent=Q_NULLPTR)
 Constructor. More...
 
virtual ~HttpRequestHandler ()
 Destructor. More...
 

Detailed Description

This class handles the API-specific requests and dispatches them to the correct RemoteControlServiceInterface implementation.

Services are registered using registerService(). To see the default services used, see the RequestHandler::RequestHandler constructor.

Definition at line 30 of file APIController.hpp.

Constructor & Destructor Documentation

APIController::APIController ( int  prefixLength,
QObject *  parent = Q_NULLPTR 
)

Constructs an APIController.

Parameters
prefixLengthDetermines how many characters to strip from the front of the request path
parentpassed on to QObject constructor

Member Function Documentation

void APIController::registerService ( RemoteControlServiceInterface service)

Registers a service with the APIController.

The RemoteControlServiceInterface::getPath() determines the request path of the service.

virtual void APIController::service ( HttpRequest request,
HttpResponse response 
)
virtual

Handles an API-specific request.

It finds out which RemoteControlServiceInterface to use depending on the service name (first part of path until slash). An error is returned for invalid requests. If a service was found, the request is passed on to its RemoteControlServiceInterface::get or RemoteControlServiceInterface::post method depending on the HTTP request type. If RemoteControlServiceInterface::isThreadSafe is false, these methods are called in the Stellarium main thread using QMetaObject::invokeMethod, otherwise they are directly executed in the current thread (HTTP worker thread).

Reimplemented from HttpRequestHandler.

void APIController::update ( double  deltaTime)

Should be called each frame from the main thread, like from StelModule::update.

Passed on to each AbstractAPIService::update method for optional processing.


The documentation for this class was generated from the following file: