License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / animation-playlist.h
1 #ifndef __DALI_INTERNAL_ANIMATION_PLAYLIST_H__
2 #define __DALI_INTERNAL_ANIMATION_PLAYLIST_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/animation/animation.h>
23 #include <dali/public-api/common/set-wrapper.h>
24 #include <dali/internal/common/message.h>
25 #include <dali/internal/event/animation/animation-finished-notifier.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 class Animation;
34
35 /**
36  * AnimationPlaylist provides notifications to applications when animations are finished.
37  * It reference-counts playing animations, to allow "fire and forget" behaviour.
38  */
39 class AnimationPlaylist : public AnimationFinishedNotifier
40 {
41 public:
42
43   /**
44    * Create an AnimationPlaylist.
45    * @return A newly allocated animation playlist.
46    */
47   static AnimationPlaylist* New();
48
49   /**
50    * Virtual destructor.
51    */
52   virtual ~AnimationPlaylist();
53
54   /**
55    * Called when an animation is constructed.
56    */
57   void AnimationCreated( Animation& animation );
58
59   /**
60    * Called when an animation is destroyed.
61    */
62   void AnimationDestroyed( Animation& animation );
63
64   /**
65    * Called when an animation is playing.
66    * @post The animation will be referenced by AnimationPlaylist, until the "Finished" signal is emitted.
67    */
68   void OnPlay( Animation& animation );
69
70   /**
71    * Called when an animation is cleared.
72    * @post The animation will no longer be referenced by AnimationPlaylist.
73    */
74   void OnClear( Animation& animation );
75
76   /**
77    * From AnimationFinishedNotifier; emit "Finished" signal on any animations that have finished.
78    * This method should be called in the event-thread; the update-thread must use AnimationFinishedMessage.
79    * @post The "Finished" animations will no longer be referenced by AnimationPlaylist.
80    */
81   void NotifyFinishedAnimations();
82
83 private:
84
85   /**
86    * Create an AnimationPlaylist.
87    */
88   AnimationPlaylist();
89
90   // Undefined
91   AnimationPlaylist(const AnimationPlaylist&);
92
93   // Undefined
94   AnimationPlaylist& operator=(const AnimationPlaylist& rhs);
95
96 private:
97
98   std::set< Animation* > mAnimations; ///< All existing animations (not referenced)
99
100   std::set< Dali::Animation > mPlaylist; ///< The currently playing animations (reference counted)
101 };
102
103 } // namespace Internal
104
105 } // namespace Dali
106
107 #endif // __DALI_INTERNAL_NOTIFICATION_MANAGER_H__
108