Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / common / scene-graph-connection-change-propagator.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_CONNECTION_CHANGE_PROPAGATOR_H
2 #define DALI_INTERNAL_SCENE_GRAPH_CONNECTION_CHANGE_PROPAGATOR_H
3
4 /*
5  * Copyright (c) 2015 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 #include <dali/public-api/common/dali-vector.h>
21
22 namespace Dali
23 {
24 namespace Internal
25 {
26 namespace SceneGraph
27 {
28 class PropertyOwner;
29
30 /**
31  * This class maintains a list of observers that are informed when
32  * it's owner changes it's connections.
33  */
34 class ConnectionChangePropagator
35 {
36 public:
37   class Observer
38   {
39   public:
40     /**
41      * Inform the observer of the object that it's connections have changed
42      * @param[in] object The connection owner
43      */
44     virtual void ConnectionsChanged(PropertyOwner& object) = 0;
45
46     /**
47      * Inform the observer of the object that a connected object has
48      * changed it's uniform map in some way.
49      */
50     virtual void ConnectedUniformMapChanged() = 0;
51
52     /**
53      * Inform the observer of the object that the object is about to be destroyed
54      */
55     virtual void ObservedObjectDestroyed(PropertyOwner& object){}
56
57   protected:
58
59     /**
60      * Virtual destructor, no deletion through this interface
61      */
62     virtual ~Observer() = default;
63   };
64
65   /**
66    * Constructor
67    */
68   ConnectionChangePropagator();
69
70   /**
71    * Destructor
72    */
73   ~ConnectionChangePropagator();
74
75   /**
76    * Add an observer
77    */
78   void Add(Observer& observer);
79
80   /**
81    * Remove an observer
82    */
83   void Remove(Observer& observer);
84
85   /**
86    * Inform the observers that the connections to the object have changed
87    * @param[in] object The connection owner
88    */
89   void ConnectionsChanged(PropertyOwner& object);
90
91   /**
92    * Inform the observers that the uniform map of this or a connected object
93    * has changed.
94    */
95   void ConnectedUniformMapChanged();
96
97   /**
98    * Inform the observers that the object is about to be destroyed
99    * @param[in] object The connection owner
100    */
101   void Destroy( PropertyOwner& object );
102
103 private:
104   using Observers         = Dali::Vector<Observer*>;
105   using ObserversIterator = Observers::Iterator;
106
107   Observers mObservers;
108 };
109
110
111 } // SceneGraph
112 } // Internal
113 } // Dali
114
115 #endif // DALI_INTERNAL_SCENE_GRAPH_CONNECTION_CHANGE_PROPAGATOR_H