I have the following structs:
struct IAnimateAction{};
struct AnimateActions {
int mSec;
std::vector<IAnimateAction> actions;
};
struct ZoomAction : public IAnimateAction {
explicit ZoomAction(int targetZoom);
int targetZoom;
};
struct TranslateAction : public IAnimateAction{
TranslateAction(int targetX, int targetY);
int targetX;
int targetY;
};
struct TurnAction: public IAnimateAction {
explicit TurnAction(float targetAngle);
float targetAngle; //radials
};
A ZoomAction
and TranslateAction
can be combined inside the AnimateActions
like this:
AnimateActions actions;
actions.mSec = 5000;
actions.actions.push_back(ZoomAction(130));
actions.actions.push_back(TurnAction(270));
c.animatelist.push(actions);
This will tell my animation system to both do a 'zoom' and 'turn' action in 5 seconds. (The std::vector can probably just be a simple array I just realized)..
They are stored in std::queue<AnimateActions> animatelist;
.
But I'm stuck on retrieving them, how would I know which type of struct I'm retrieving? I want my IDE to give me typehints for the specific struct I'm handling, in this loop:
if (!animatelist.empty()) {
auto element = animatelist.front();
for (auto action : elelement.actions) {
//cast to specific struct?
}
animatelist.pop();
}