[dali_1.0.31] Merge branch 'tizen'
[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/internal/event/common/object-impl.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 class Actor;
31
32 /**
33  * Stores an actor pointer and connects/disconnects to any required signals appropriately when set/unset.
34  */
35 struct ActorObserver : public Object::Observer
36 {
37 public:
38
39   // Construction & Destruction
40
41   /**
42    * Constructor.
43    */
44   ActorObserver();
45
46   /**
47    * Non virtual destructor
48    */
49   ~ActorObserver();
50
51   // Methods
52
53   /**
54    * Return the stored Actor pointer.
55    * @return The Actor pointer.
56    */
57   Actor* GetActor();
58
59   /**
60    * Assignment operator.
61    * This disconnects the required signals from the currently set actor and connects to the required
62    * signals for the the actor specified (if set).
63    */
64   void SetActor( Actor* actor );
65
66   /**
67    * Resets the set actor and disconnects any connected signals.
68    */
69   void ResetActor();
70
71 private:
72
73   // Undefined
74   ActorObserver( const ActorObserver& );
75   ActorObserver& operator=( const ActorObserver& );
76
77 private:
78
79   /**
80    * This will never get called as we do not observe objects that have not been added to the scene.
81    * @param[in] object The object object.
82    * @see Object::Observer::SceneObjectAdded()
83    */
84   virtual void SceneObjectAdded(Object& object) { }
85
86   /**
87    * This will be called when the actor is removed from the stage, we should clear and stop
88    * observing it.
89    * @param[in] object The object object.
90    * @see Object::Observer::SceneObjectRemoved()
91    */
92   virtual void SceneObjectRemoved(Object& object);
93
94   /**
95    * This will be called when the actor is destroyed. We should clear the actor.
96    * No need to stop observing as the object is being destroyed anyway.
97    * @see Object::Observer::ObjectDestroyed()
98    */
99   virtual void ObjectDestroyed(Object& object);
100
101 private:
102   Actor* mActor;              ///< Raw pointer to an Actor.
103   bool  mActorDisconnected;   ///< Indicates whether the actor has been disconnected from the scene
104 };
105
106 } // namespace Internal
107
108 } // namespace Dali
109
110 #endif // __DALI_INTERNAL_ACTOR_OBSERVER_H__
111