up-to-date submodule(rive-cpp)
[platform/core/uifw/rive-tizen.git] / submodule / include / animation / state_machine_instance.hpp
1 #ifndef _RIVE_STATE_MACHINE_INSTANCE_HPP_
2 #define _RIVE_STATE_MACHINE_INSTANCE_HPP_
3
4 #include <string>
5 #include <stddef.h>
6 #include "animation/linear_animation_instance.hpp"
7
8 namespace rive
9 {
10         class StateMachine;
11         class LayerState;
12         class SMIInput;
13         class Artboard;
14         class SMIBool;
15         class SMINumber;
16         class SMITrigger;
17
18         class StateMachineLayerInstance;
19
20         class StateMachineInstance
21         {
22                 friend class SMIInput;
23
24         private:
25                 const StateMachine* m_Machine;
26                 bool m_NeedsAdvance = false;
27
28                 size_t m_InputCount;
29                 SMIInput** m_InputInstances;
30                 size_t m_LayerCount;
31                 StateMachineLayerInstance* m_Layers;
32
33                 void markNeedsAdvance();
34
35         public:
36                 StateMachineInstance(const StateMachine* machine);
37                 ~StateMachineInstance();
38
39                 // Advance the state machine by the specified time. Returns true if the
40                 // state machine will continue to animate after this advance.
41                 bool advance(Artboard* artboard, float seconds);
42
43                 // Returns true when the StateMachineInstance has more data to process.
44                 bool needsAdvance() const;
45
46                 // Returns a pointer to the instance's stateMachine
47                 const StateMachine* stateMachine() const { return m_Machine; }
48
49                 size_t inputCount() const { return m_InputCount; }
50                 SMIInput* input(size_t index) const;
51
52                 SMIBool* getBool(std::string name) const;
53                 SMINumber* getNumber(std::string name) const;
54                 SMITrigger* getTrigger(std::string name) const;
55
56                 const size_t currentAnimationCount() const;
57                 const LinearAnimationInstance*
58                 currentAnimationByIndex(size_t index) const;
59
60                 // The number of state changes that occurred across all layers on the
61                 // previous advance.
62                 size_t stateChangedCount() const;
63
64                 // Returns the state name for states that changed in layers on the
65                 // previously called advance. If the index of out of range, it returns
66                 // the empty string.
67                 const LayerState* stateChangedByIndex(size_t index) const;
68         };
69 } // namespace rive
70 #endif