
AMDG Robert Dailey wrote:
The problem is that the type of the packet is not known until runtime. This makes it very difficult to make things "type safe" at compile time. What Steven has presented is about as type-safe as you can make it. However, the system does not prevent you from mismatching ID's with actual packet types, but that's just a natural problem with data driven designs. You could put the ID in the base Packet type. That should minimize the chances of mismatch. Right now there is no possible way to have a factory that returns the original type of the packet, since what is being passed in (the ID) is not known at compile time, as I've already stated. It seems like a problem in multiple dispatching, which C++ just doesn't support very well natively.
In Christ, Steven Watanabe