#ifndef ANIMATOR_HH #define ANIMATOR_HH #include class Animation; class Looper; class Animator { public: class Observer { public: virtual ~Observer() {} // Called after all active animations callbacks has been called. // Not called if there are no active animations. virtual void tick(Animator* animator) = 0; protected: Observer() {} }; class AnimationObserver { public: virtual ~AnimationObserver() {} // Called after the animation has been updated with the new value virtual void ticked(Animator* animator, Animation* animation, double value) = 0; // Called after the animation stopped, either because stop() was called // or because animation->tick() return false. // If animation->tick() returned false ticked method above is always called // first virtual void stopped(Animator* animator, Animation* animation) = 0; protected: AnimationObserver() {} }; virtual ~Animator() {} static Animator* create(std::shared_ptr const& looper); virtual void start(std::shared_ptr const& animation, AnimationObserver* observer) = 0; virtual bool observe(Animation* animation, AnimationObserver* observer) = 0; virtual bool stop(Animation* animation) = 0; virtual bool active(Animation* animation) const = 0; virtual bool active() const = 0; virtual void add_observer(Observer* observer) = 0; virtual void remove_observer(Observer* observer) = 0; protected: Animator() {} Animator(Animator const&) = delete; Animator& operator=(Animator const&) = delete; }; #endif // ANIMATOR_HH