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"
|
#include "baseAPI.hpp"
|
||||||
|
|
||||||
BaseAPI::BaseAPI(int CONTROL_PORT,
|
BaseAPI::BaseAPI() {}
|
||||||
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;
|
route_map_t route_map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseAPI(int CONTROL_PORT,
|
BaseAPI();
|
||||||
WiFiHandler *network,
|
|
||||||
CameraHandler *camera,
|
|
||||||
StateManager<WiFiState_e> *stateManager,
|
|
||||||
std::string api_url);
|
|
||||||
|
|
||||||
virtual ~BaseAPI();
|
virtual ~BaseAPI();
|
||||||
virtual void begin();
|
virtual void begin();
|
||||||
|
|||||||
@ -18,15 +18,7 @@ bool API_Utilities::channel_write = false;
|
|||||||
//! API Utilities
|
//! API Utilities
|
||||||
//*********************************************************************************************
|
//*********************************************************************************************
|
||||||
|
|
||||||
API_Utilities::API_Utilities(int CONTROL_PORT,
|
API_Utilities::API_Utilities() : server(new AsyncWebServer(_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() {}
|
API_Utilities::~API_Utilities() {}
|
||||||
|
|
||||||
std::string API_Utilities::shaEncoder(std::string data)
|
std::string API_Utilities::shaEncoder(std::string data)
|
||||||
|
|||||||
@ -29,11 +29,7 @@
|
|||||||
class API_Utilities
|
class API_Utilities
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
API_Utilities(int CONTROL_PORT,
|
API_Utilities();
|
||||||
WiFiHandler *network,
|
|
||||||
CameraHandler *camera,
|
|
||||||
StateManager<WiFiState_e> *stateManager,
|
|
||||||
std::string api_url);
|
|
||||||
virtual ~API_Utilities();
|
virtual ~API_Utilities();
|
||||||
|
|
||||||
static void printASCII();
|
static void printASCII();
|
||||||
@ -80,6 +76,7 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string api_url;
|
std::string api_url;
|
||||||
|
byte _control_port;
|
||||||
|
|
||||||
static bool ssid_write;
|
static bool ssid_write;
|
||||||
static bool pass_write;
|
static bool pass_write;
|
||||||
|
|||||||
@ -4,15 +4,18 @@
|
|||||||
//! API Server
|
//! API Server
|
||||||
//*********************************************************************************************
|
//*********************************************************************************************
|
||||||
|
|
||||||
APIServer::APIServer(int CONTROL_PORT,
|
APIServer::APIServer(byte control_port,
|
||||||
WiFiHandler *network,
|
WiFiHandler *network,
|
||||||
CameraHandler *camera,
|
CameraHandler *camera,
|
||||||
StateManager<WiFiState_e> *stateManager,
|
StateManager<WiFiState_e> *stateManager,
|
||||||
std::string api_url) : BaseAPI(CONTROL_PORT,
|
std::string api_url)
|
||||||
network,
|
{
|
||||||
camera,
|
this->_control_port = control_port;
|
||||||
stateManager,
|
this->network = network;
|
||||||
api_url) {}
|
this->camera = camera;
|
||||||
|
this->stateManager = stateManager;
|
||||||
|
this->api_url = api_url;
|
||||||
|
}
|
||||||
|
|
||||||
APIServer::~APIServer() {}
|
APIServer::~APIServer() {}
|
||||||
|
|
||||||
@ -42,7 +45,6 @@ void APIServer::setupServer()
|
|||||||
|
|
||||||
// Camera Routes
|
// Camera Routes
|
||||||
|
|
||||||
|
|
||||||
//! reserve enough memory for all routes - must be called after adding routes and before adding routes to route_map
|
//! 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
|
indexes.reserve(routes.size()); // this is done to avoid reallocation of memory and copying of data
|
||||||
addRouteMap("builtin", routes, indexes); // add new route map to the route_map
|
addRouteMap("builtin", routes, indexes); // add new route map to the route_map
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
class APIServer : public BaseAPI
|
class APIServer : public BaseAPI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
APIServer(int CONTROL_PORT,
|
APIServer(byte control_port,
|
||||||
WiFiHandler *network,
|
WiFiHandler *network,
|
||||||
CameraHandler *camera,
|
CameraHandler *camera,
|
||||||
StateManager<WiFiState_e> *stateManager,
|
StateManager<WiFiState_e> *stateManager,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user