Revert "[Tizen] Add codes for Dali Windows Backend"
[platform/core/uifw/dali-core.git] / dali / public-api / object / ref-object.h
1 #ifndef __DALI_REF_OBJECT_H__
2 #define __DALI_REF_OBJECT_H__
3
4 /*
5  * Copyright (c) 2018 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/common/dali-common.h>
23 #include <dali/public-api/common/intrusive-ptr.h>
24
25 namespace Dali
26 {
27 /**
28  * @addtogroup dali_core_object
29  * @{
30  */
31
32 class Value;
33
34 /**
35  * @brief Base class for reference counted objects.
36  *
37  * Typically this should be used with an intrusive pointer,
38  * instead of calling Reference() and Unreference() methods directly.
39  * @SINCE_1_0.0
40  */
41 class DALI_CORE_API RefObject
42 {
43 public:
44
45   /**
46    * @brief Increments the object's reference count.
47    * @SINCE_1_0.0
48    */
49   void Reference();
50
51   /**
52    * @brief Decrements the object's reference count.
53    *
54    * When the reference count drops to zero, the object will self-destruct.
55    * @SINCE_1_0.0
56    */
57   void Unreference();
58
59   /**
60    * @brief Retrieves the object's reference count.
61    *
62    * @SINCE_1_0.0
63    * @return The reference count
64    */
65   int ReferenceCount();
66
67 protected:
68
69   /**
70    * @brief Default constructor.
71    * @SINCE_1_0.0
72    */
73   RefObject();
74
75   /**
76    * @brief RefObject is intended as a base class.
77    *
78    * A RefObject may only be deleted when its reference count is zero.
79    * @SINCE_1_0.0
80    */
81   virtual ~RefObject();
82
83   /**
84    * @brief Copy constructor.
85    *
86    * The newly copied object will have a reference count of zero.
87    * @SINCE_1_0.0
88    * @param[in] rhs The object to copy
89    */
90   RefObject(const RefObject& rhs);
91
92   /**
93    * @brief Assignment operator.
94    *
95    * The newly copied object will have a reference count of zero.
96    * @SINCE_1_0.0
97    * @param[in] rhs The object to copy
98    * @return A reference to this
99    */
100   RefObject& operator=(const RefObject& rhs);
101
102 private:
103
104   volatile int mCount; ///< Reference count
105 };
106
107 /**
108  * @}
109  */
110 } // namespace Dali
111
112 #endif // __DALI_REF_OBJECT_H__