fixes required by review of pr1700

This commit is contained in:
csoler 2019-11-25 22:16:32 +01:00
parent 5223ff751a
commit 7aa51423a4
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
13 changed files with 98 additions and 154 deletions

View file

@ -5,7 +5,7 @@
* Copyright (C) 2019-2019 Cyril Soler <csoler@users.sourceforge.net> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
@ -14,12 +14,13 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
*
*******************************************************************************/
#pragma once
#include <map>
#include <string>
class p3ConfigMgr;
@ -28,34 +29,52 @@ class JsonApiResourceProvider;
class RsJsonAPI
{
public:
enum {
JSONAPI_STATUS_UNKNOWN = 0x00,
JSONAPI_STATUS_RUNNING = 0x01,
JSONAPI_STATUS_NOT_RUNNING = 0x02
};
static const uint16_t DEFAULT_PORT = 9092 ;
static const std::string DEFAULT_BINDING_ADDRESS ; // 127.0.0.1
virtual bool restart() =0;
virtual bool stop() =0;
virtual void setBindingAddress(const std::string& address) =0;
virtual void setListeningPort(uint16_t port) =0;
virtual uint16_t listeningPort() const =0;
virtual void connectToConfigManager(p3ConfigMgr *cfgmgr)=0;
virtual void registerResourceProvider(const JsonApiResourceProvider *)=0;
virtual void unregisterResourceProvider(const JsonApiResourceProvider *)=0;
virtual bool hasResourceProvider(const JsonApiResourceProvider *)=0;
/**
* @brief Get status of the json api server
* @jsonapi{development}
* @return the status picked in the enum JSONAPI_STATUS_UNKNOWN/RUNNING/NOT_RUNNING
* @return Returns true if the server is running
*/
virtual int status() =0;
virtual bool isRunning() =0;
/*!
* \brief setBindingAddress
* Sets the binding address of the jsonapi server. Will only take effect after the server is restarted
* \param address
* Address in IPv4 or IPv6 format.
*/
virtual void setBindingAddress(const std::string& address) =0;
/*!
* \brief setListeningPort
* Port to use when talking to the jsonAPI server.
* \param port
* Should be a non system-reserved 16 bits port number (1024 to 65535)
*/
virtual void setListeningPort(uint16_t port) =0;
virtual uint16_t listeningPort() const =0;
/*!
* \brief connectToConfigManager
* Should be called after creating the JsonAPI object so that it publishes itself with the proper config file.
* Since JsonAPI is created *before* login, the config manager does not exist at this time.
* \param cfgmgr
*/
virtual void connectToConfigManager(p3ConfigMgr *cfgmgr)=0;
/*!
* \brief registerResourceProvider
* This is used to add/remove new web services to JsonAPI. The client should take care of not using a path range already
* used by the jsonAPI server.
*/
virtual void registerResourceProvider(const JsonApiResourceProvider *)=0;
virtual void unregisterResourceProvider(const JsonApiResourceProvider *)=0;
virtual bool hasResourceProvider(const JsonApiResourceProvider *)=0;
//=============================================================================================//
// API methods that are also accessible through http //