Files
1NiM-WatingRoom-WatchContro…/components/spit/include/SAD_DetectedServer.hpp
T
gustice 04a8904cbe refactor/bringup: Bringup full project
moving SPIT-App parts to main app
LiveShowDemoProject added
Debugging motor movements
2025-04-08 23:49:05 +02:00

120 lines
4.0 KiB
C++

#pragma once
#include "I_SAD_Client.hpp"
#include <list>
#include <string>
#include <unordered_map>
using namespace std;
class SAD_DetectedServer {
public:
SAD_DetectedServer();
SAD_DetectedServer(const SAD_DetectedServer &orig) {
m_ID = orig.getID();
m_Name = orig.getName();
m_ComputerName = orig.getComputerName();
m_IP = orig.getIP();
m_ClientIP = orig.getClientIP();
m_Port = orig.getPort();
m_Additions = orig.getAdditions();
}
~SAD_DetectedServer();
private:
string m_ID;
string m_Name;
string m_ComputerName;
string m_IP;
string m_ClientIP;
string m_Port;
string m_Additions;
string m_ServerProjectName;
bool m_New;
bool m_Changed;
bool m_FoundAgain;
public:
string getID() const { return m_ID; }
string getName() const { return m_Name; }
string getComputerName() const { return m_ComputerName; }
string getIP() const { return m_IP; }
string getPort() const { return m_Port; }
string getClientIP() const { return m_ClientIP; }
string getAdditions() const { return m_Additions; }
string getProjectName() const { return m_ServerProjectName; }
private:
void setID(string p_ID) { m_ID = p_ID; }
void setName(string p_Name) { m_Name = p_Name; }
void setComputerName(string p_ComputerName) { m_ComputerName = p_ComputerName; }
void setIP(string p_IP) { m_IP = p_IP; }
void setClientIP(string p_IP) { m_ClientIP = p_IP; }
void setPort(string p_Port) { m_Port = p_Port; }
void setAdditions(string p_Additions) { m_Additions = p_Additions; }
void setProjectName(string p_ServerProjectName);
bool getNew() const { return m_New; }
bool getChanged() const { return m_Changed; }
bool getFoundAgain() const { return m_FoundAgain; }
void setChanged() { m_Changed = true; }
void setNew(bool p_New) { m_New = p_New; }
void setFoundAgain() { m_FoundAgain = true; }
// SAD_Client m_ThreadSend will send to Multicast addresses
void startCycleSAD() {
m_Changed = false;
m_FoundAgain = false;
m_New = false;
}
private:
static unordered_map<string, SAD_DetectedServer *> s_DetectedServers;
public:
static const int PARAMINDEX_PRECODE = 0;
static const int PARAMINDEX_SPITTASKID = 1;
static const int PARAMINDEX_NAME = 2;
static const int PARAMINDEX_ID = 3;
static const int PARAMINDEX_COMPUTERNAME = 4;
static const int PARAMINDEX_PORT = 5;
static const int PARAMINDEX_CLIENTIP = 6;
static const int PARAMINDEX_ADDITIONS = 7;
static const int PARAMINDEX_SERVERPROJECTNAME = 8;
static const int PARAMINDEX_IP = 9;
/**
* Used by SAD_Client to add a found SPITServer - don't use this manually
* @param p_IsIP4 true = the server is reached via a IP4 address<br>false = the server is reahed via a IP6 address
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
* @param p_ServerParams the server's parameter
*/
static void addDetectedServer(string p_ServerID, string p_ServerParams[]);
/**
* Used by SAD_Client to remove a SPITServer - don't use this manually
* @param p_DetectedServer
*/
static void removeDetectedServer(SAD_DetectedServer &server);
/**
* Used by SAD_Client to clear all found SPITServers - don't use this manually
*/
static void clearDetectedServers();
/**
* Used by SAD_Client internally - don't use this manually
*/
static void cycleStart();
/**
* Used by SAD_Client internally -don't use this manually
* @param p_SADClientInterface
*/
static void cycleEnd(I_SAD_Client &p_SADClientInterface);
/**
* Returns a reference of the DetectedServer with the id p_ServerID.<br>
* If no DetectedServer is found an eyception is thrown.
* @param p_ServerID the id of the SPITServer
* @return the reference of the SAD_DetectedServer instance with getID() == p_ServerID
*/
static const SAD_DetectedServer &getRefDetectedServer(string p_ServerID);
};