refactoring on Server detection
This commit is contained in:
@@ -1,36 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "I_SAD_Client.hpp"
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SAD_DetectedServer {
|
||||
|
||||
class SAD_DetectedServer;
|
||||
class I_SAD_Client {
|
||||
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();
|
||||
virtual void eventServerDetected(SAD_DetectedServer &server) = 0;
|
||||
virtual void eventServerChanged(SAD_DetectedServer &server) = 0;
|
||||
virtual void eventServerLost(SAD_DetectedServer &server) = 0;
|
||||
};
|
||||
|
||||
class SAD_DetectedServer {
|
||||
public:
|
||||
SAD_DetectedServer() {}
|
||||
SAD_DetectedServer(const SAD_DetectedServer &orig)
|
||||
: m_ID(orig.m_ID),
|
||||
m_Name(orig.m_Name),
|
||||
m_ComputerName(orig.m_ComputerName),
|
||||
m_IP(orig.m_IP),
|
||||
m_ClientIP(orig.m_ClientIP),
|
||||
m_Port(orig.m_Port),
|
||||
m_Additions(orig.m_Additions) {
|
||||
}
|
||||
~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;
|
||||
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;
|
||||
@@ -46,14 +51,14 @@ class SAD_DetectedServer {
|
||||
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);
|
||||
void setID(const string& p_ID) { m_ID = p_ID; }
|
||||
void setName(const string& p_Name) { m_Name = p_Name; }
|
||||
void setComputerName(const string& p_ComputerName) { m_ComputerName = p_ComputerName; }
|
||||
void setIP(const string& p_IP) { m_IP = p_IP; }
|
||||
void setClientIP(const string& p_IP) { m_ClientIP = p_IP; }
|
||||
void setPort(const string& p_Port) { m_Port = p_Port; }
|
||||
void setAdditions(const string& p_Additions) { m_Additions = p_Additions; }
|
||||
void setProjectName(const string& projName);
|
||||
|
||||
bool getNew() const { return m_New; }
|
||||
bool getChanged() const { return m_Changed; }
|
||||
@@ -63,7 +68,7 @@ class SAD_DetectedServer {
|
||||
void setFoundAgain() { m_FoundAgain = true; }
|
||||
|
||||
// SAD_Client m_ThreadSend will send to Multicast addresses
|
||||
void startCycleSAD() {
|
||||
void resetFlags() {
|
||||
m_Changed = false;
|
||||
m_FoundAgain = false;
|
||||
m_New = false;
|
||||
@@ -83,21 +88,8 @@ class SAD_DetectedServer {
|
||||
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 addDetectedServer(string &id, string p_ServerParams[]);
|
||||
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
|
||||
@@ -115,5 +107,5 @@ class SAD_DetectedServer {
|
||||
* @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);
|
||||
static const SAD_DetectedServer &getRefDetectedServer(const string &id);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user