Client: inline trivial getters & setters

This commit is contained in:
Lion Kortlepel 2021-01-02 03:19:51 +01:00
parent 0f30706a0a
commit 61776d6a1b
2 changed files with 20 additions and 62 deletions

View File

@ -37,31 +37,32 @@ private:
int ID = -1; int ID = -1;
public: public:
bool isConnected = false;
bool isSynced = false;
bool isGuest = false;
void AddNewCar(int ident, const std::string& Data); void AddNewCar(int ident, const std::string& Data);
void SetCarData(int ident, const std::string& Data); void SetCarData(int ident, const std::string& Data);
std::set<std::unique_ptr<VData>>& GetAllCars(); std::set<std::unique_ptr<VData>>& GetAllCars();
void SetName(const std::string& name); void SetName(const std::string& name) { Name = name; }
void SetRoles(const std::string& role); void SetRoles(const std::string& role) { Role = role; }
std::string GetCarData(int ident); std::string GetCarData(int ident);
void SetUDPAddr(sockaddr_in Addr); void SetUDPAddr(sockaddr_in Addr) { UDPADDR = Addr; }
void SetDownSock(SOCKET CSock); void SetDownSock(SOCKET CSock) { SOCK[1] = CSock; }
void SetTCPSock(SOCKET CSock); void SetTCPSock(SOCKET CSock) { SOCK[0] = CSock; }
void SetStatus(int status); void SetStatus(int status) { Status = status; }
void DeleteCar(int ident); void DeleteCar(int ident);
sockaddr_in GetUDPAddr(); sockaddr_in GetUDPAddr() { return UDPADDR; }
bool isConnected = false; std::string GetRoles() { return Role; }
std::string GetRoles(); std::string GetName() { return Name; }
std::string GetName(); SOCKET GetDownSock() { return SOCK[1]; }
bool isSynced = false; SOCKET GetTCPSock() { return SOCK[0]; }
bool isGuest = false; void SetID(int ID) { this->ID = ID; }
SOCKET GetDownSock();
SOCKET GetTCPSock();
void SetID(int ID);
int GetOpenCarID(); int GetOpenCarID();
int GetCarCount(); int GetCarCount();
void ClearCars(); void ClearCars();
int GetStatus(); int GetStatus() { return Status; }
int GetID(); int GetID() { return ID; }
}; };
struct ClientInterface { struct ClientInterface {
std::set<std::unique_ptr<Client>> Clients; std::set<std::unique_ptr<Client>> Clients;
@ -80,7 +81,7 @@ struct ClientInterface {
} }
void AddClient(Client*&& c) { void AddClient(Client*&& c) {
Assert(c); Assert(c);
Clients.insert(std::move(std::unique_ptr<Client>(c))); Clients.insert(std::unique_ptr<Client>(c));
} }
int Size() { int Size() {
return int(Clients.size()); return int(Clients.size());

View File

@ -9,50 +9,6 @@
#include <memory> #include <memory>
std::string Client::GetName() {
return Name;
}
void Client::SetName(const std::string& name) {
Name = name;
}
void Client::SetRoles(const std::string& role) {
Role = role;
}
std::string Client::GetRoles() {
return Role;
}
int Client::GetID() {
return ID;
}
void Client::SetID(int id) {
ID = id;
}
void Client::SetStatus(int state) {
Status = state;
}
int Client::GetStatus() {
return Status;
}
void Client::SetUDPAddr(sockaddr_in Addr) {
UDPADDR = Addr;
}
void Client::SetDownSock(SOCKET CSock) {
SOCK[1] = CSock;
}
SOCKET Client::GetDownSock() {
return SOCK[1];
}
sockaddr_in Client::GetUDPAddr() {
return UDPADDR;
}
void Client::SetTCPSock(SOCKET CSock) {
SOCK[0] = CSock;
}
SOCKET Client::GetTCPSock() {
return SOCK[0];
}
void Client::DeleteCar(int ident) { void Client::DeleteCar(int ident) {
for (auto& v : VehicleData) { for (auto& v : VehicleData) {
if (v != nullptr && v->ID == ident) { if (v != nullptr && v->ID == ident) {
@ -95,6 +51,7 @@ std::string Client::GetCarData(int ident) {
DeleteCar(ident); DeleteCar(ident);
return ""; return "";
} }
void Client::SetCarData(int ident, const std::string& Data) { void Client::SetCarData(int ident, const std::string& Data) {
for (auto& v : VehicleData) { for (auto& v : VehicleData) {
if (v != nullptr && v->ID == ident) { if (v != nullptr && v->ID == ident) {