X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=blobdiff_plain;f=source%2Fprotocol.h;h=4bde291ea5c263ce519ea4cac690a6120758fc92;hp=8ae5cdd149170c0bfdc0e5dcf3342e226ff27946;hb=a81c41acd873cda7f40bca634782230d9e57dc4f;hpb=c016a1ae2bc93a48074e4b8cafab70b9d2c9fc20 diff --git a/source/protocol.h b/source/protocol.h index 8ae5cdd..4bde291 100644 --- a/source/protocol.h +++ b/source/protocol.h @@ -20,9 +20,9 @@ private: PacketDefBase(unsigned i): id(i) { } public: virtual ~PacketDefBase() { } - virtual unsigned get_class_id() const =0; + virtual unsigned get_class_id() const = 0; unsigned get_id() const { return id; } - virtual const char *disassemble(ReceiverBase &, const char *, const char *) const =0; + virtual const char *disassemble(ReceiverBase &, const char *, const char *) const = 0; static unsigned next_class_id; }; @@ -34,8 +34,8 @@ private: FieldBase() { } public: virtual ~FieldBase() { } - virtual char *assemble(const P &, char *, char *) const =0; - virtual const char *disassemble(P &, const char *, const char *) const =0; + virtual char *assemble(const P &, char *, char *) const = 0; + virtual const char *disassemble(P &, const char *, const char *) const = 0; }; template @@ -63,7 +63,7 @@ protected: public: PacketDef(unsigned i): PacketDefBase(i) - { if(!class_id) class_id=next_class_id++; } + { if(!class_id) class_id = next_class_id++; } ~PacketDef() { @@ -80,18 +80,18 @@ protected: char *assemble(const P &p, char *d, char *e) const { for(typename std::vector *>::const_iterator i=fields.begin(); i!=fields.end(); ++i) - d=(*i)->assemble(p, d, e); + d = (*i)->assemble(p, d, e); return d; } const char *disassemble(ReceiverBase &r, const char *d, const char *e) const { - PacketReceiver

*prcv=dynamic_cast *>(&r); + PacketReceiver

*prcv = dynamic_cast *>(&r); if(!prcv) throw Exception("Packet type not supported by receiver"); P pkt; for(typename std::vector *>::const_iterator i=fields.begin(); i!=fields.end(); ++i) - d=(*i)->disassemble(pkt, d, e); + d = (*i)->disassemble(pkt, d, e); prcv->receive(pkt); return d; } @@ -105,7 +105,7 @@ protected: PacketMap packet_class_defs; PacketMap packet_id_defs; - Protocol(unsigned =1); + Protocol(unsigned = 1); public: ~Protocol(); @@ -116,7 +116,7 @@ protected: template PacketDef

&add() { - PacketDef

*pdef=new PacketDef

(next_packet_id++); + PacketDef

*pdef = new PacketDef

(next_packet_id++); add_packet(*pdef); return *pdef; } @@ -128,10 +128,10 @@ public: template unsigned assemble(const P &pkt, char *buf, unsigned size) const { - unsigned id=PacketDef

::class_id; - const PacketDef

&pdef=static_cast &>(get_packet_by_class(id)); - char *ptr=pdef.assemble(pkt, buf+4, buf+size); - assemble_header(buf, pdef.get_id(), (size=ptr-buf)); + unsigned id = PacketDef

::class_id; + const PacketDef

&pdef = static_cast &>(get_packet_by_class(id)); + char *ptr = pdef.assemble(pkt, buf+4, buf+size); + assemble_header(buf, pdef.get_id(), (size = ptr-buf)); return size; } @@ -152,7 +152,7 @@ private: }; template -unsigned Protocol::PacketDef

::class_id=0; +unsigned Protocol::PacketDef

::class_id = 0; } // namespace Net } // namespace Msp