#pragma once #include #include #include using namespace std; class SAD_DetectedServer; class I_SAD_Client { public: 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) { } 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(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; } 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 resetFlags() { m_Changed = false; m_FoundAgain = false; m_New = false; } private: static unordered_map 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; static void addDetectedServer(string &id, string p_ServerParams[]); static void removeDetectedServer(SAD_DetectedServer &server); 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.
* 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(const string &id); };