I have an enum like (this is just an example):
enum tStates
{
STOP = (1<<0),
PLAYING = (1<<1),
SYNCHRONISING = (1<<2),
READY_TO_PLAY = (1<<3),
CONNECTED = (1<<4),
}
So it can be playing and connected at the same time etc... Multiple states at once is possible. I need to test different states, for instance:
if (m_pDeviceHealth->getHealth().isSet(PLAYING))
{
}
else if (m_pDeviceHealth->getHealth().isSet(STOP))
{
}
It tends to become quite big and difficult to read.
Is there a clearer way to check for a flag? Is it possible to use a switch for instance?