[4.0] If a RenderTask's exclusive actor is destoryed, then ensure the RenderTaskList...
[platform/core/uifw/dali-core.git] / dali / internal / event / events / actor-observer.h
1 #ifndef __DALI_INTERNAL_ACTOR_OBSERVER_H__
2 #define __DALI_INTERNAL_ACTOR_OBSERVER_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/signals/callback.h>
23 #include <dali/internal/event/common/object-impl.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 class Actor;
32
33 /**
34  * Stores an actor pointer and connects/disconnects to any required signals appropriately when set/unset.
35  */
36 struct ActorObserver : public Object::Observer
37 {
38 public:
39
40   // Construction & Destruction
41
42   /**
43    * Constructor.
44    */
45   ActorObserver();
46
47   /**
48    * Constructor with a callback which is called when the observed actor is removed from the scene.
49    *
50    * The callback should have the following signature:
51    * @code
52    * void MyCallback( Actor* actor );
53    * @endcode
54    * Where actor is a pointer to the object that has been removed from the scene.
55    *
56    * @param[in]  callback  The callback to connect to.
57    *
58    * @note Ownership of callback is passed onto this class.
59    */
60   ActorObserver( CallbackBase* callback );
61
62   /**
63    * Non virtual destructor
64    */
65   ~ActorObserver();
66
67   // Movable.
68
69   /**
70    *
71    */
72   ActorObserver( ActorObserver&& other );
73
74   /**
75    *
76    */
77   ActorObserver& operator=( ActorObserver&& other );
78
79   // Not copyable
80
81   ActorObserver( const ActorObserver& ) = delete;   ///< Deleted copy constructor.
82   ActorObserver& operator=( const ActorObserver& ) = delete;   ///< Deleted copy assignment operator.
83
84
85   // Methods
86
87   /**
88    * Return the stored Actor pointer.
89    * @return The Actor pointer.
90    */
91   Actor* GetActor() const;
92
93   /**
94    * Assignment operator.
95    * This disconnects the required signals from the currently set actor and connects to the required
96    * signals for the the actor specified (if set).
97    */
98   void SetActor( Actor* actor );
99
100   /**
101    * Resets the set actor and disconnects any connected signals.
102    */
103   void ResetActor();
104
105 private:
106
107   /**
108    * This will never get called as we do not observe objects that have not been added to the scene.
109    * @param[in] object The object object.
110    * @see Object::Observer::SceneObjectAdded()
111    */
112   virtual void SceneObjectAdded(Object& object) { }
113
114   /**
115    * This will be called when the actor is removed from the stage, we should clear and stop
116    * observing it.
117    * @param[in] object The object object.
118    * @see Object::Observer::SceneObjectRemoved()
119    */
120   virtual void SceneObjectRemoved(Object& object);
121
122   /**
123    * This will be called when the actor is destroyed. We should clear the actor.
124    * No need to stop observing as the object is being destroyed anyway.
125    * @see Object::Observer::ObjectDestroyed()
126    */
127   virtual void ObjectDestroyed(Object& object);
128
129 private:
130   Actor* mActor;                 ///< Raw pointer to an Actor.
131   bool  mActorDisconnected;      ///< Indicates whether the actor has been disconnected from the scene
132   CallbackBase* mRemoveCallback; ///< Callback to call when the observed actor is removed from the scene
133 };
134
135 } // namespace Internal
136
137 } // namespace Dali
138
139 #endif // __DALI_INTERNAL_ACTOR_OBSERVER_H__
140