From 68b679fa705b7dba6442fa613cc149f6adb5c8a0 Mon Sep 17 00:00:00 2001 From: PioDer Date: Wed, 11 Jan 2017 13:16:56 +0100 Subject: [PATCH] C++11 + poprawki --- Makefile | 2 +- NATItem.cpp | 29 ++++++++++++----------------- NATItem.h | 11 ++++++++--- NATRouter.h | 9 +-------- Packet.cpp | 5 ----- Packet.h | 1 - 6 files changed, 22 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index bdaf719..8b4687a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CXX = g++ -CXXFLAGS = -Wall +CXXFLAGS = -Wall -std=c++11 LDFLAGS = -pthread OBJ = Packet.o Node.o NATItem.o NATRouter.o diff --git a/NATItem.cpp b/NATItem.cpp index cf054d3..8c4953c 100644 --- a/NATItem.cpp +++ b/NATItem.cpp @@ -14,37 +14,32 @@ NATItem::NATItem() this->timeout = 0; } -NATItem::~NATItem() +const string& NATItem::getIp() const { - // TODO Auto-generated destructor stub + return ip; } -void NATItem::setIp(string ip) +void NATItem::setIp(const string& ip) { - + this->ip = ip; } -void NATItem::setPort(int port) +int NATItem::getPort() const { - + return port; } -void NATItem::setTimeout(int timeout) -{ - -} - -string NATItem::getIp() +void NATItem::setPort(int port) { - + this->port = port; } -int NATItem::getPort() +int NATItem::getTimeout() const { - + return timeout; } -int NATItem::getTimeout() +void NATItem::setTimeout(int timeout) { - + this->timeout = timeout; } diff --git a/NATItem.h b/NATItem.h index 03d26f1..096e27a 100644 --- a/NATItem.h +++ b/NATItem.h @@ -18,8 +18,7 @@ class NATItem public: NATItem(); - virtual ~NATItem(); - +/* // settery void setIp(string ip); void setPort(int port); @@ -28,7 +27,13 @@ public: // gettery string getIp(); int getPort(); - int getTimeout(); + int getTimeout();*/ + const string& getIp() const; + void setIp(const string& ip); + int getPort() const; + void setPort(int port); + int getTimeout() const; + void setTimeout(int timeout); }; #endif /* NATITEM_H_ */ diff --git a/NATRouter.h b/NATRouter.h index c336204..310c340 100644 --- a/NATRouter.h +++ b/NATRouter.h @@ -11,14 +11,7 @@ #include "common.h" #include "Node.h" #include "NATItem.h" -/* -typedef struct -{ - string ip; // IP wewn. do którego ma trafić odpowiedź / z którego przyszło żądanie - int port; // port komputera wewn. do którego ma trafić odpowiedź - int timeout; // czas (w sekundach) zajętości portu (0 - port wolny) -} NATItem; -*/ + class NATRouter : public Node { NATItem *natTable; diff --git a/Packet.cpp b/Packet.cpp index 5efe920..c13334e 100644 --- a/Packet.cpp +++ b/Packet.cpp @@ -12,11 +12,6 @@ Packet::Packet(string msg) : Packet() this->setMsg(msg); } -Packet::~Packet() -{ - // TODO Auto-generated destructor stub -} - //settery void Packet::setSrcIp(string srcIp) { diff --git a/Packet.h b/Packet.h index 81ca839..b1e1857 100644 --- a/Packet.h +++ b/Packet.h @@ -20,7 +20,6 @@ class Packet public: Packet() : srcIp("0.0.0.0"), dstIp("0.0.0.0"), srcPort(0), dstPort(0), msg("") {} Packet(string msg); - virtual ~Packet(); // settery void setSrcIp(string srcIp);