Hi,

Currently I'm using Boost.Signals to transfer Packet objects to subscribers. Right now my Boost.Signal looks like below:

boost::signal<void (Packet const& p)>

Right now Packet is the base class for several other packet types, each having the specific data a subscriber needs access to. Of course, given this design, the only way to obtain the data is to perform a downcast via static_cast or dynamic_cast:

WalkPacket const& wp = static_cast<WalkPacket const&>( p ); // 'p' here is a generic Packet object.

This is obviously bad design since it isn't type safe at all. It's also repetitive and tedious since each subscriber must duplicate the logic to perform the downcast. I'm wondering if there's anything in Boost you guys can suggest that I use to make this a little better. I would prefer to have a common Signal object that can take differently typed Slot objects. For example, I want to pass in a slot that looks like: "void (WalkPacket& p)" and have the signal utilize implicit conversions or something. Templates aren't even being used here because I can't find a way to fit them in, since everything is being done at runtime and not compile time.

Keep this important note in mind: The type of the packet that will be dispatched to subscribers can only be known at compile time via a factory method. Data is received from the network, and that data is packed into the correct packet and returned as a Packet* base class pointer, so that we can transfer the data to subscribers through a common interface.