X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fobject%2Fref-object.h;h=5aab626c43ed03f8008d16634ae91822e308b90e;hb=36ea2dd0841fadf61696fffc8bb649b63ebfe4b6;hp=4b518506fed9b0ff14ad4b69a8f3afe6a133935e;hpb=f09cea89519b3a7bdee3266b1bd26f97150d95cc;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/object/ref-object.h b/dali/public-api/object/ref-object.h index 4b51850..5aab626 100644 --- a/dali/public-api/object/ref-object.h +++ b/dali/public-api/object/ref-object.h @@ -1,8 +1,8 @@ -#ifndef __DALI_REF_OBJECT_H__ -#define __DALI_REF_OBJECT_H__ +#ifndef DALI_REF_OBJECT_H +#define DALI_REF_OBJECT_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,10 @@ */ // EXTERNAL INCLUDES +#include +#include // uint32_t + +// INTERNAL INCLUDES #include #include @@ -34,22 +38,21 @@ class Value; /** * @brief Base class for reference counted objects. * - * Typically this should be used with an instrusive pointer, + * Typically this should be used with an intrusive pointer, * instead of calling Reference() and Unreference() methods directly. * @SINCE_1_0.0 */ -class DALI_IMPORT_API RefObject +class DALI_CORE_API RefObject { public: - /** - * @brief Increment the object's reference count. + * @brief Increments the object's reference count. * @SINCE_1_0.0 */ void Reference(); /** - * @brief Decrement the object's reference count. + * @brief Decrements the object's reference count. * * When the reference count drops to zero, the object will self-destruct. * @SINCE_1_0.0 @@ -57,15 +60,14 @@ public: void Unreference(); /** - * @brief Retrieve the object's reference count. + * @brief Retrieves the object's reference count. * * @SINCE_1_0.0 * @return The reference count */ - int ReferenceCount(); + uint32_t ReferenceCount(); protected: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -95,13 +97,17 @@ protected: * The newly copied object will have a reference count of zero. * @SINCE_1_0.0 * @param[in] rhs The object to copy - * @return a reference to this + * @return A reference to this */ RefObject& operator=(const RefObject& rhs); -private: + // Not movable + + RefObject(RefObject&& rhs) = delete; ///< Deleted move constructor + RefObject& operator=(RefObject&& rhs) = delete; ///< Deleted move assignment operator - volatile int mCount; ///< Reference count +private: + std::atomic_uint32_t mCount{0u}; ///< Reference count }; /** @@ -109,4 +115,4 @@ private: */ } // namespace Dali -#endif // __DALI_REF_OBJECT_H__ +#endif // DALI_REF_OBJECT_H