} // anon namespace
+int UtcDaliValueFromEnum(void)
+{
+ enum class T {
+ None, V1 = 1, V2 = 2
+ };
+
+ Property::Value v1 = T::V1;
+ Property::Value v2 = T::V2;
+
+ T t = T::None;
+ DALI_TEST_CHECK( v1.Get<T>() == T::V1 );
+ DALI_TEST_CHECK( v2.Get<T>() == T::V2 );
+ DALI_TEST_CHECK( v1.Get(t) && t == T::V1 );
+ DALI_TEST_CHECK( v2.Get(t) && t == T::V2 );
+
+ END_TEST;
+}
+
int UtcDaliScriptingNewImageNegative01(void)
{
// Invalid filename
// EXTERNAL INCLUDES
#include <iosfwd>
+#include <type_traits>
#include <utility>
#include <initializer_list>
#include <dali/public-api/object/property.h>
#include <dali/public-api/math/rect.h>
+
namespace Dali
{
/**
Value( const Extents& extentsValue );
/**
+ * @brief Creates an enumeration property value.
+ *
+ * @SINCE_1_4.36
+ * @param[in] enumValue An enumeration value
+ */
+ template< typename T, typename std::enable_if< std::is_enum< T >::value >::type* = nullptr >
+ Value( T enumValue ) : Value( static_cast< int32_t >( enumValue ) )
+ {
+ }
+
+ /**
* @brief Explicitly sets a type and initialize it.
*
* @SINCE_1_0.0
/**
* @brief Retrieves a specific value.
*
- * Works on a best-effort approach; if value type is not convertible returns a default value of the type.
+ * Works on a best-effort approach; if value type is different returns a default value of the type.
*
- * @SINCE_1_0.0
+ * @SINCE_1_4.36
* @return A value of type T
*/
- template <typename T>
+ template< typename T, typename std::enable_if< ! std::is_enum< T >::value >::type* = nullptr >
T DALI_INTERNAL Get() const
{
T temp = T(); // value (zero) initialize
}
/**
+ * @brief Retrieves a specific value.
+ *
+ * Works on a best-effort approach; if value type is different returns a default value of the type.
+ * Specialization for enumeration values
+ *
+ * @SINCE_1_4.36
+ * @return A value of type T
+ */
+ template< typename T, typename std::enable_if< std::is_enum< T >::value >::type* = nullptr >
+ T DALI_INTERNAL Get() const
+ {
+ int32_t temp = 0; // value (zero) initialize
+ Get( temp );
+ return static_cast< T >( temp );
+ }
+
+ /**
+ * @brief Retrieves an enumeration value.
+ *
+ * @SINCE_1_4.36
+ * @param[out] enumValue On return, an enumeration value
+ * @return @c true if the value is successfully retrieved, @c false if the type is different
+ * @pre GetType() is any enumeration
+ */
+ template< typename T, typename std::enable_if< std::is_enum< T >::value >::type* = nullptr >
+ bool DALI_INTERNAL Get( T& enumValue ) const
+ {
+ int32_t temp = 0;
+ if( ! Get( temp ) )
+ {
+ return false;
+ }
+ enumValue = static_cast< T >( temp );
+ return true;
+ }
+
+ /**
* @brief Retrieves a boolean value.
*
* @SINCE_1_0.0