I am now working on a motion control system. I want to make the motion control interface more flexible, so I want to provide an api that can specifiy the controlled axis.
It just like.
void moveTo(/*data*/, Axis which);
Axis parameter is used to define how the motion data should be treated as and the internal implement will check the data according the requested axis.
So i want to define a operation rules on Axis parameters.
I tried the bit flags, defined as follow.
enum class Axis : std::uint_fast16_t {
X = 1l << 0,
Y = 1l << 1,
Z = 1l << 2
};
// operator | and & and so on are also defined.
It can be used as follow.
const auto which = Axis::X | Axis::Y;
But what i want is that, Axis::X | Axis::Y and Axis::Y | Axis::X should be different, but now they have same value. There is no way to distinguish them inside the function.
How should I define such a bit mask that appears to be related to "order of operations"?
It seems to do this by listing all allowed combined states in a single enumeration. But I still want to ask if there is a more elegant and clear solution.
Or any suggestion for a better implementation of such functionality?
I hope the final usage is still as simple as the bit mask, I don't mind if I do some really complicated work behind the scenes, I don't mind using any 3rd party library.