From: Mikko Rasa Date: Sun, 9 Oct 2016 17:34:33 +0000 (+0300) Subject: Some largely cosmetic touch-up X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5f312d842b55f53ac78ae2c658cab064debe74e6;p=libs%2Fnet.git Some largely cosmetic touch-up --- diff --git a/source/net/communicator.cpp b/source/net/communicator.cpp index 07c3be4..051e45a 100644 --- a/source/net/communicator.cpp +++ b/source/net/communicator.cpp @@ -116,9 +116,7 @@ void Communicator::data_available() while(more) { if(handshake_status==2) - { more = receive_packet(protocol, receiver); - } else { HandshakeProtocol hsproto; diff --git a/source/net/protocol.h b/source/net/protocol.h index 0a8110c..7ff63cb 100644 --- a/source/net/protocol.h +++ b/source/net/protocol.h @@ -48,10 +48,9 @@ private: template struct CompoundDef: public CompoundTypeDef { - S *serializer; + S serializer; CompoundDef(const S &); - virtual ~CompoundDef(); virtual std::string describe() const; virtual char *serialize(const C &, char *, char *) const; @@ -197,7 +196,7 @@ private: const CompoundTypeDef

&get_compound() const { return *compound; } - virtual std::string describe() const; + virtual std::string describe() const { return compound->describe(); } char *serialize(const P &, char *, char *) const; const char *deserialize(P &, const char *, const char *) const; virtual const char *dispatch(ReceiverBase &, const char *, const char *) const; @@ -355,31 +354,25 @@ struct Protocol::Traits > template Protocol::CompoundDef::CompoundDef(const S &s): - serializer(new S(s)) + serializer(s) { } -template -Protocol::CompoundDef::~CompoundDef() -{ - delete serializer; -} - template std::string Protocol::CompoundDef::describe() const { - return "{"+serializer->describe()+"}"; + return "{"+serializer.describe()+"}"; } template char *Protocol::CompoundDef::serialize(const C &com, char *buf, char *end) const { - return serializer->serialize(com, buf, end); + return serializer.serialize(com, buf, end); } template const char *Protocol::CompoundDef::deserialize(C &com, const char *buf, const char *end) const { - return serializer->deserialize(com, buf, end); + return serializer.deserialize(com, buf, end); } @@ -448,14 +441,14 @@ std::string Protocol::Serializer::describe() const } template -char * Protocol::Serializer::serialize(const P &pkt, char *buf, char *end) const +char *Protocol::Serializer::serialize(const P &pkt, char *buf, char *end) const { buf = Head::serialize(pkt, buf, end); return ser.serialize(pkt.*ptr, buf, end); } template -const char * Protocol::Serializer::deserialize(P &pkt, const char *buf, const char *end) const +const char *Protocol::Serializer::deserialize(P &pkt, const char *buf, const char *end) const { buf = Head::deserialize(pkt, buf, end); return ser.deserialize(pkt.*ptr, buf, end); @@ -488,12 +481,6 @@ void Protocol::PacketTypeDef

::set_serializer(const S &ser) compound = new CompoundDef(ser); } -template -std::string Protocol::PacketTypeDef

::describe() const -{ - return compound->describe(); -} - template char *Protocol::PacketTypeDef

::serialize(const P &pkt, char *buf, char *end) const {