Packets and AbstractValue

Dear all,

There was the idea to define Packet for each protocol using AbstractValue (Utils/AbstractValue, check my latest dev revision):

Generics:
typedef AbstractValue
Packet;

BitTorrent::Packets:
typedef AbstractValue Packet;

Gnutella::Packets:
typedef AbstractValue Packet;

The advantage would be that working with Packet inside each of the packages would be easy and conversions would be done transparently when necessary.

The problem I have is that this would require each protocol to also define its own BadPacket class. If the one from Generics is always used, then there might be a problem at runtime - casting BadPacket which is derived from Generics::PacketBase to DataBase (that’s fine) and then casing is to e.g. BitTorrent::Packets::PacketBase, which is unrelated to BadPacket!

How to solve that? It may actually make sense to have a BadPacket for each protocol because this way we would be able to say “that’s a bad packet received from a BitTorrent connection”. Maybe I could make Generics::BadPacket a template class, so that each protocol could simple define a typedef passing its own PacketBase as a parameter.

Any ideas?

Regards,

Peter

Would you like to post a relpy?


This post starts a thread.
No follow-ups yet.