]> git.tdb.fi Git - libs/net.git/commitdiff
Some largely cosmetic touch-up
authorMikko Rasa <tdb@tdb.fi>
Sun, 9 Oct 2016 17:34:33 +0000 (20:34 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 9 Oct 2016 17:34:33 +0000 (20:34 +0300)
source/net/communicator.cpp
source/net/protocol.h

index 07c3be4f6b1d7c25623a957217a98f5bccea21a6..051e45a14bbb4f33d262429df400fe4f6b6b60dd 100644 (file)
@@ -116,9 +116,7 @@ void Communicator::data_available()
                while(more)
                {
                        if(handshake_status==2)
                while(more)
                {
                        if(handshake_status==2)
-                       {
                                more = receive_packet(protocol, receiver);
                                more = receive_packet(protocol, receiver);
-                       }
                        else
                        {
                                HandshakeProtocol hsproto;
                        else
                        {
                                HandshakeProtocol hsproto;
index 0a8110c9518182f91ada3cfe48f0f09ecd579b98..7ff63cb1e7dd12cc2a8fb3e9ba1e092062bcc754 100644 (file)
@@ -48,10 +48,9 @@ private:
        template<typename C, typename S>
        struct CompoundDef: public CompoundTypeDef<C>
        {
        template<typename C, typename S>
        struct CompoundDef: public CompoundTypeDef<C>
        {
-               S *serializer;
+               S serializer;
 
                CompoundDef(const S &);
 
                CompoundDef(const S &);
-               virtual ~CompoundDef();
 
                virtual std::string describe() const;
                virtual char *serialize(const C &, char *, char *) const;
 
                virtual std::string describe() const;
                virtual char *serialize(const C &, char *, char *) const;
@@ -197,7 +196,7 @@ private:
 
                const CompoundTypeDef<P> &get_compound() const { return *compound; }
 
 
                const CompoundTypeDef<P> &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;
                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<std::vector<T> >
 
 template<typename C, typename S>
 Protocol::CompoundDef<C, S>::CompoundDef(const S &s):
 
 template<typename C, typename S>
 Protocol::CompoundDef<C, S>::CompoundDef(const S &s):
-       serializer(new S(s))
+       serializer(s)
 { }
 
 { }
 
-template<typename C, typename S>
-Protocol::CompoundDef<C, S>::~CompoundDef()
-{
-       delete serializer;
-}
-
 template<typename C, typename S>
 std::string Protocol::CompoundDef<C, S>::describe() const
 {
 template<typename C, typename S>
 std::string Protocol::CompoundDef<C, S>::describe() const
 {
-       return "{"+serializer->describe()+"}";
+       return "{"+serializer.describe()+"}";
 }
 
 template<typename C, typename S>
 char *Protocol::CompoundDef<C, S>::serialize(const C &com, char *buf, char *end) const
 {
 }
 
 template<typename C, typename S>
 char *Protocol::CompoundDef<C, S>::serialize(const C &com, char *buf, char *end) const
 {
-       return serializer->serialize(com, buf, end);
+       return serializer.serialize(com, buf, end);
 }
 
 template<typename C, typename S>
 const char *Protocol::CompoundDef<C, S>::deserialize(C &com, const char *buf, const char *end) const
 {
 }
 
 template<typename C, typename S>
 const char *Protocol::CompoundDef<C, S>::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<P, Head, S>::describe() const
 }
 
 template<typename P, typename Head, typename S>
 }
 
 template<typename P, typename Head, typename S>
-char * Protocol::Serializer<P, Head, S>::serialize(const P &pkt, char *buf, char *end) const
+char *Protocol::Serializer<P, Head, S>::serialize(const P &pkt, char *buf, char *end) const
 {
        buf = Head::serialize(pkt, buf, end);
        return ser.serialize(pkt.*ptr, buf, end);
 }
 
 template<typename P, typename Head, typename S>
 {
        buf = Head::serialize(pkt, buf, end);
        return ser.serialize(pkt.*ptr, buf, end);
 }
 
 template<typename P, typename Head, typename S>
-const char * Protocol::Serializer<P, Head, S>::deserialize(P &pkt, const char *buf, const char *end) const
+const char *Protocol::Serializer<P, Head, S>::deserialize(P &pkt, const char *buf, const char *end) const
 {
        buf = Head::deserialize(pkt, buf, end);
        return ser.deserialize(pkt.*ptr, buf, end);
 {
        buf = Head::deserialize(pkt, buf, end);
        return ser.deserialize(pkt.*ptr, buf, end);
@@ -488,12 +481,6 @@ void Protocol::PacketTypeDef<P>::set_serializer(const S &ser)
        compound = new CompoundDef<P, S>(ser);
 }
 
        compound = new CompoundDef<P, S>(ser);
 }
 
-template<typename P>
-std::string Protocol::PacketTypeDef<P>::describe() const
-{
-       return compound->describe();
-}
-
 template<typename P>
 char *Protocol::PacketTypeDef<P>::serialize(const P &pkt, char *buf, char *end) const
 {
 template<typename P>
 char *Protocol::PacketTypeDef<P>::serialize(const P &pkt, char *buf, char *end) const
 {