I have these Enum declarations:
enum MessageType{
REQ_LOGIN,
REQ_GET_FIELD,
RES_LOGIN,
RES_GET_FIELD
}
enum Request{
REQ_LOGIN,
REQ_GET_FIELD
};
enum Respond{
RES_LOGIN,
RES_GET_FIELD
};
Obviously I'm repeating elements in Enum's. Is there any way to prevent this?
EDIT: I'm using "MessageType" on a general purpose class to send it through network, on the other side I parse the object of this class and dispatch message. But I have different clients; some expects only objects with "Request" type member and some expects only objects with "Response" type member.
Using "Message" class, I'm creating "DispatcherRequest"s.
class Message
{
public:
……….
MessageType messageType;
}
struct DispatcherRequest
{
..........
Request type;
};
Why not try something like this?
enum MainType{
REQUEST,
RESPONSE
};
enum SubType{
LOGIN,
GET_FIELD
};
class Message {
MainType type;
SubType sub_type;
...
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With