Clean up the code to build successfully on macOS
[platform/core/uifw/dali-core.git] / dali / internal / event / common / base-object-impl.h
1 #ifndef DALI_BASE_OBJECT_IMPL_H
2 #define DALI_BASE_OBJECT_IMPL_H
3
4 /*
5  * Copyright (c) 2020 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23
24 namespace Dali
25 {
26
27 /**
28  * @brief Holds the Implementation for the BaseObject class
29  */
30 class BaseObject::Impl
31 {
32
33 public:
34
35   /**
36    * @brief Retrieves the implementation of the internal BaseObject class.
37    * @param[in] internalBaseObject A ref to the BaseObject whose internal implementation is required
38    * @return The internal implementation
39    */
40   static BaseObject::Impl& Get( BaseObject& baseObject );
41
42   /**
43    * @copydoc Get( BaseObject& )
44    */
45   static const BaseObject::Impl& Get( const BaseObject& baseObject );
46
47   /**
48    * @brief Constructor.
49    * @param[in] baseObject The base object which owns this implementation
50    */
51   Impl( BaseObject& baseObject );
52
53   /**
54    * @brief Destructor.
55    */
56   ~Impl();
57
58   class Observer
59   {
60   public:
61
62     /**
63      * Called shortly before the object itself is destroyed; no further callbacks will be received.
64      * @param[in] object The base object.
65      */
66     virtual void ObjectDestroyed( BaseObject& object ) = 0;
67
68   protected:
69
70     /**
71      * Virtual destructor
72      */
73     virtual ~Observer() {}
74   };
75
76   /**
77    * Add an observer to the object.
78    * @param[in] observer The observer to add.
79    */
80   void AddObserver( Observer& observer );
81
82   /**
83    * Remove an observer from the object
84    * @pre The observer has already been added.
85    * @param[in] observer The observer to remove.
86    */
87   void RemoveObserver( Observer& observer );
88
89 private:
90
91   BaseObject& mBaseObject;
92   Dali::Vector<Observer*> mObservers;
93 };
94
95 } // namespace Dali
96
97 #endif // DALI_BASE_OBJECT_IMPL_H