C
Chris
Hi
My application reads writes/messages from a socket. It contains inbound
and outbound std::queue<Message*> queues.
I have a base Message and derived classes eg LoginMessage (outbound),
LoginReplyMessage (inbound).
My question is when creating an inbound message from the raw data which
of the following approaches is better?
- a: Directly create object of Message type, add onto the inbound
message queue . Then when using it later create a new LoginReplyMessage
from the message data.
- b: Pass the buffer to a 'factory' method which returns a message of
exact type, eg LoginReplyMessage, using a add onto inbound message queue
(upcasting). When processing downcast to appropriate type and use.
Thanks for reading.
Chris
My application reads writes/messages from a socket. It contains inbound
and outbound std::queue<Message*> queues.
I have a base Message and derived classes eg LoginMessage (outbound),
LoginReplyMessage (inbound).
My question is when creating an inbound message from the raw data which
of the following approaches is better?
- a: Directly create object of Message type, add onto the inbound
message queue . Then when using it later create a new LoginReplyMessage
from the message data.
- b: Pass the buffer to a 'factory' method which returns a message of
exact type, eg LoginReplyMessage, using a add onto inbound message queue
(upcasting). When processing downcast to appropriate type and use.
Thanks for reading.
Chris