Boost logo

Boost Users :

From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-03-29 16:43:40


On Sat, Mar 29, 2008 at 3:40 PM, Steven Watanabe <watanabesj_at_[hidden]>
wrote:

> AMDG
>
> Robert Dailey wrote:
> > It seems that so far we've gotten everything done without RTTI, I
> > would hate to introduce it here.
>
> RTTI is not always evil. It may be less efficient to hash the strings,
> but it is not worse from a design perspective.
>
> > I see what you're saying now. Something like this might be in order:
> >
> > struct Packet
> > {
> > virtual PacketId GetId() const = 0;
> > };
> >
> > struct WalkPacket : Packet
> > {
> > static const PacketId ID = PID_WALKPACKET;
> > virtual PacketId GetId() const { return ID; }
> > };
>
> Yep. That works. Just thought I'd point out that this is not so very
> different
> from RTTI, after all.
>
> In Christ,
> Steven Watanabe
>

Well I'm not 100% sure of the performance impact RTTI will have on the
application. What I've read is that RTTI can get very expensive in terms of
executable size if you have a lot of classes in your application.
Unfortunately I don't think I could get away with using strings since the
network is assigning integral values to the packets in order to uniquely
identify them. I like the string idea because it doesn't have the repetitive
code in each derived class (the overridden GetID method that will be the
same in each derived class).



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