1 #ifndef DALI_INDIRECT_VALUE_H
2 #define DALI_INDIRECT_VALUE_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali/public-api/common/intrusive-ptr.h>
21 #include <dali/public-api/object/property-value.h>
22 #include <dali/public-api/object/property.h>
23 #include <dali/public-api/object/ref-object.h>
28 * @addtogroup dali_core_object
35 * @brief Dali::IndirectValue is an intermediate object that enables a simpler
36 * syntax for addressing properties.
39 * object["property"] = value;
40 * float value = object["property"];
42 * It is not intended to be directly instantiated, instead, any Handle type
43 * will generate a temporary object using the above syntax.
45 class DALI_CORE_API IndirectValue
49 * @brief Assignment operator
52 * Enables "handle[property] = value" syntax.
53 * @param[in] value The value to assign
55 void operator=(Property::Value value);
58 * @brief Explicit cast operator for property value.
61 * Enables implicit promotion of this to a Property::Value type parameter
62 * @return The property value
64 operator Property::Value()
70 * @brief Cast operator
73 * Enables "value = handle[property]" syntax.
74 * @tparam Type The type of the associated property
75 * @return The associated property cast to the desired type
77 template<typename Type>
78 inline operator Type()
80 Property::Value value = GetProperty();
81 return value.Get<Type>();
88 * @brief Move constructor.
91 * Making this private to prevent construction of auto type or IndirectValue type.
92 * @param[in] rhs The object to move
94 DALI_INTERNAL IndirectValue(IndirectValue&& rhs);
97 * @brief Move assignment operator.
100 * Making this private to prevent assignment to auto type or IndirectValue type.
101 * @param[in] rhs The object to move
103 DALI_INTERNAL IndirectValue& operator=(IndirectValue&& rhs);
106 * @brief Accessor for handle property.
109 * @return The handle's property value
110 * @note Asserts if the handle is empty
112 Property::Value GetProperty();
114 friend class Handle; ///< Only Handle types can construct this object
117 * @brief Private constructor
120 * @param[in] handle A reference to the associated handle
121 * @param[in] index The index to the associated property
123 DALI_INTERNAL IndirectValue(Handle& handle, Property::Index index);
126 IntrusivePtr<Dali::RefObject> mHandle; ///< A handle to the property owner
127 Property::Index mIndex; ///< Index of the property in the property owner.
129 struct Extension; ///< Reserved for future use
130 Extension* mExtension; ///< Reserved for future use
140 #endif // DALI_INDIRECT_VALUE_H