[reSIProcate] avoid dynamic_cast!
hongsion
hongsion at gmail.com
Wed Jan 10 02:55:27 CST 2007
Hi,
In reciprocate there is so many dynamic_cast. It let code difficult
to read also I think it will affect performance. I have a advice to avoid
these dynamic_cast, please give comments!
Define an abstract class:
Class MessageProcessor
{
virtual void ProcessMessage(Message &msg)
{
msg.Process(*this);
}
virtrual void Process(Message &msg) = 0;
virtual void Process(SipMessage &msg) = 0;
virtual void Process(KeepAliveMessage &msg) = 0;
...
};
And in class Message add member function
Class Message
{
virtual void Process(MessageProcessor &processor) = 0;
};
And in every concrete messge add such member function:
Class SipMessage
{
Void Process(MessageProcessor &processor)
{
processor.Process(*this);
}
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20070110/d4669f5d/attachment.htm>
More information about the resiprocate-devel
mailing list