Support for ASTC compressed textures wrapped in KTX files
[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) 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
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 instrusive pointer,
38  * instead of calling Reference() and Unreference() methods directly.
39  */
40 class DALI_IMPORT_API RefObject
41 {
42 public:
43
44   /**
45    * @brief Increment the object's reference count.
46    */
47   void Reference();
48
49   /**
50    * @brief Decrement the object's reference count.
51    *
52    * When the reference count drops to zero, the object will self-destruct.
53    */
54   void Unreference();
55
56   /**
57    * @brief Retrieve the object's reference count.
58    *
59    * @return The reference count
60    */
61   int ReferenceCount();
62
63 protected:
64
65   /**
66    * @brief Default constructor.
67    */
68   RefObject();
69
70   /**
71    * @brief RefObject is intended as a base class.
72    *
73    * A RefObject may only be deleted when its reference count is zero.
74    */
75   virtual ~RefObject();
76
77   /**
78    * @brief Copy constructor.
79    *
80    * The newly copied object will have a reference count of zero.
81    * @param[in] rhs The object to copy
82    */
83   RefObject(const RefObject& rhs);
84
85   /**
86    * @brief Assignment operator.
87    *
88    * The newly copied object will have a reference count of zero.
89    * @param[in] rhs The object to copy
90    * @return a reference to this
91    */
92   RefObject& operator=(const RefObject& rhs);
93
94 private:
95
96   volatile int mCount; ///< Reference count
97 };
98
99 /**
100  * @}
101  */
102 } // namespace Dali
103
104 #endif // __DALI_REF_OBJECT_H__