mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
Update
- Optimize the dependency injection model for the API classes - Removed the constructor params from the base-classes of APIServer - Allocate data to the base-class members in the Constructor of APIServer
This commit is contained in:
parent
37f501c442
commit
d802b4a5d7
@ -1,14 +1,6 @@
|
||||
#include "baseAPI.hpp"
|
||||
|
||||
BaseAPI::BaseAPI(int CONTROL_PORT,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url) : API_Utilities(CONTROL_PORT,
|
||||
network,
|
||||
camera,
|
||||
stateManager,
|
||||
api_url) {}
|
||||
BaseAPI::BaseAPI() {}
|
||||
|
||||
BaseAPI::~BaseAPI() {}
|
||||
|
||||
|
||||
@ -70,11 +70,7 @@ protected:
|
||||
route_map_t route_map;
|
||||
|
||||
public:
|
||||
BaseAPI(int CONTROL_PORT,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url);
|
||||
BaseAPI();
|
||||
|
||||
virtual ~BaseAPI();
|
||||
virtual void begin();
|
||||
|
||||
@ -18,15 +18,7 @@ bool API_Utilities::channel_write = false;
|
||||
//! API Utilities
|
||||
//*********************************************************************************************
|
||||
|
||||
API_Utilities::API_Utilities(int CONTROL_PORT,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url) : server(new AsyncWebServer(CONTROL_PORT)),
|
||||
stateManager(stateManager),
|
||||
network(network),
|
||||
camera(camera),
|
||||
api_url(api_url) {}
|
||||
API_Utilities::API_Utilities() : server(new AsyncWebServer(_control_port)) {}
|
||||
API_Utilities::~API_Utilities() {}
|
||||
|
||||
std::string API_Utilities::shaEncoder(std::string data)
|
||||
|
||||
@ -29,11 +29,7 @@
|
||||
class API_Utilities
|
||||
{
|
||||
public:
|
||||
API_Utilities(int CONTROL_PORT,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url);
|
||||
API_Utilities();
|
||||
virtual ~API_Utilities();
|
||||
|
||||
static void printASCII();
|
||||
@ -80,6 +76,7 @@ protected:
|
||||
|
||||
protected:
|
||||
std::string api_url;
|
||||
byte _control_port;
|
||||
|
||||
static bool ssid_write;
|
||||
static bool pass_write;
|
||||
|
||||
@ -4,15 +4,18 @@
|
||||
//! API Server
|
||||
//*********************************************************************************************
|
||||
|
||||
APIServer::APIServer(int CONTROL_PORT,
|
||||
APIServer::APIServer(byte control_port,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url) : BaseAPI(CONTROL_PORT,
|
||||
network,
|
||||
camera,
|
||||
stateManager,
|
||||
api_url) {}
|
||||
std::string api_url)
|
||||
{
|
||||
this->_control_port = control_port;
|
||||
this->network = network;
|
||||
this->camera = camera;
|
||||
this->stateManager = stateManager;
|
||||
this->api_url = api_url;
|
||||
}
|
||||
|
||||
APIServer::~APIServer() {}
|
||||
|
||||
@ -41,7 +44,6 @@ void APIServer::setupServer()
|
||||
routes.emplace("deleteRoute", &APIServer::deleteRoute);
|
||||
|
||||
// Camera Routes
|
||||
|
||||
|
||||
//! reserve enough memory for all routes - must be called after adding routes and before adding routes to route_map
|
||||
indexes.reserve(routes.size()); // this is done to avoid reallocation of memory and copying of data
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
class APIServer : public BaseAPI
|
||||
{
|
||||
public:
|
||||
APIServer(int CONTROL_PORT,
|
||||
APIServer(byte control_port,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user