Merge "Check whether the scene-graph RenderTask object is valid" into devel/master
[platform/core/uifw/dali-core.git] / dali / devel-api / common / ref-counted-dali-vector.h
1 #ifndef REF_COUNTED_DALI_VECTOR_H
2 #define REF_COUNTED_DALI_VECTOR_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 // INTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/public-api/object/ref-object.h>
24
25 namespace Dali
26 {
27 /**
28  * @brief A reference counting wrapper for a vector class that allows
29  * a set of referencing smart pointers to collaborate in managing its
30  * lifetime and eventually cleaning it up.
31  *
32  * This should only be allocated on the new/delete heap, not a thread's
33  * stack.
34  * @tparam T type of the data that the vector holds
35  */
36 template<typename T>
37 class RefCountedVector : public RefObject
38 {
39 public:
40   /**
41    * @brief Construct empty vector.
42    */
43   RefCountedVector()
44   {
45   }
46
47   /**
48    * @brief Get the referenced vector.
49    *
50    * @return A reference to the vector that this object wraps.
51    */
52   Vector<T>& GetVector()
53   {
54     return mVector;
55   }
56
57   // Not copyable or movable
58   RefCountedVector(const RefCountedVector&) = delete;            ///< Deleted copy constructor
59   RefCountedVector(RefCountedVector&&)      = delete;            ///< Deleted move constructor
60   RefCountedVector& operator=(const RefCountedVector&) = delete; ///< Deleted copy assignment operator
61   RefCountedVector& operator=(RefCountedVector&&) = delete;      ///< Deleted move assignment operator
62
63 protected:
64   virtual ~RefCountedVector()
65   {
66   }
67
68 private:
69   Vector<T> mVector; ///< The vector of data
70 };
71
72 } // namespace Dali
73
74 #endif // REF_COUNTED_DALI_VECTOR_H