|
Boost Users : |
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-03-29 16:06:28
On Sat, Mar 29, 2008 at 12:08 PM, Steven Watanabe <watanabesj_at_[hidden]>
wrote:
> AMDG
>
> Robert Dailey wrote:
> >
> > You could put the ID in the base Packet type. That should
> > minimize the
> > chances of mismatch.
> >
> >
> > Right now I'm already putting the ID as a static constant variable in
> > each derived type. I don't see a way to set the ID in the base Packet
> > class, since that would more than likely require CRTP or something.
> > From what I have seen the Packet base class cannot be a template. I
> > suppose you could do this if you used 3 levels of inheritance, but
> > that seems ugly.
>
> I'm thinking of a non static member variable in the base class, which
> can be set in
> the constructor.
>
> In Christ,
> Steven Watanabe
>
Is there any reason why the ID needs to be available at runtime? Instead of
your specialization, I do:
class WalkPacket : Packet
{
static const PacketId ID = PID_WALKPACKET;
};
Is there any reason why this isn't sufficient?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net