/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
END_TEST;
}
+
+int UtcDaliPropertyArrayCopyConstructor(void)
+{
+ Property::Array array1;
+ array1.PushBack( 0 );
+ array1.PushBack( 1 );
+ array1.PushBack( 2 );
+ DALI_TEST_EQUALS( 3u, array1.Size(), TEST_LOCATION );
+
+ Property::Array array2( array1 );
+ DALI_TEST_EQUALS( 3u, array1.Size(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 3u, array2.Size(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayAssignmentOperator(void)
+{
+ Property::Array array1;
+ array1.PushBack( 0 );
+ array1.PushBack( 1 );
+ array1.PushBack( 2 );
+ DALI_TEST_EQUALS( 3u, array1.Size(), TEST_LOCATION );
+
+ Property::Array array2;
+ array2.PushBack( 4 );
+ DALI_TEST_EQUALS( 1u, array2.Size(), TEST_LOCATION );
+
+ array2 = array1;
+ DALI_TEST_EQUALS( 3u, array1.Size(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 3u, array2.Size(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayMoveConstructor(void)
+{
+ Property::Array array1;
+ array1.PushBack( 0 );
+ array1.PushBack( 1 );
+ array1.PushBack( 2 );
+ DALI_TEST_EQUALS( 3u, array1.Size(), TEST_LOCATION );
+
+ Property::Array array2( std::move( array1 ) );
+ DALI_TEST_EQUALS( 3u, array2.Size(), TEST_LOCATION );
+
+ // Calling any methods on array1 will debug assert
+ const char * exceptionMessage = "Cannot use an object previously used as an r-value";
+ DALI_TEST_ASSERTION( array1.Count(), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.PushBack( Property::Value() ), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Count(), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Clear(), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Reserve( 1 ), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Resize( 1 ), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Capacity(), exceptionMessage );
+ DALI_TEST_ASSERTION( array1[ 0 ], exceptionMessage );
+ DALI_TEST_ASSERTION( const_cast< const Property::Array& >( array1 )[ 0 ], exceptionMessage );
+ DALI_TEST_ASSERTION( Property::Array temp; array1 = temp, exceptionMessage );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayMoveAssignmentOperator(void)
+{
+ Property::Array array1;
+ array1.PushBack( 0 );
+ array1.PushBack( 1 );
+ array1.PushBack( 2 );
+ DALI_TEST_EQUALS( 3u, array1.Size(), TEST_LOCATION );
+
+ Property::Array array2;
+ array2.PushBack( 4 );
+ DALI_TEST_EQUALS( 1u, array2.Size(), TEST_LOCATION );
+
+ array2 = std::move( array1 );
+ DALI_TEST_EQUALS( 3u, array2.Size(), TEST_LOCATION );
+
+ // Calling any methods on array1 will debug assert
+ const char * exceptionMessage = "Cannot use an object previously used as an r-value";
+ DALI_TEST_ASSERTION( array1.Count(), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.PushBack( Property::Value() ), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Count(), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Clear(), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Reserve( 1 ), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Resize( 1 ), exceptionMessage );
+ DALI_TEST_ASSERTION( array1.Capacity(), exceptionMessage );
+ DALI_TEST_ASSERTION( array1[ 0 ], exceptionMessage );
+ DALI_TEST_ASSERTION( const_cast< const Property::Array& >( array1 )[ 0 ], exceptionMessage );
+ DALI_TEST_ASSERTION( Property::Array temp; array1 = temp, exceptionMessage );
+
+ // Self assignemnt
+ array2 = std::move( array2 );
+ DALI_TEST_EQUALS( 3u, array2.Size(), TEST_LOCATION ); // still works, no debug assert
+
+ END_TEST;
+}
+
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
END_TEST;
}
+int UtcDaliPropertyMapMoveConstructor(void)
+{
+ Property::Map map1;
+ map1[ "hello" ] = 1;
+ map1[ "world" ] = 2;
+ map1[ 10 ] = "DALi";
+ DALI_TEST_EQUALS( 3u, map1.Count(), TEST_LOCATION );
+
+ Property::Map map2( std::move( map1 ) );
+ DALI_TEST_EQUALS( 3u, map2.Count(), TEST_LOCATION );
+
+ // Calling any methods on map1 will debug assert
+ const char * exceptionMessage = "Cannot use an object previously used as an r-value";
+ DALI_TEST_ASSERTION( map1.Count(), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Empty(), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Insert( (const char *)"key", Property::Value() ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Insert( std::string( "key" ), Property::Value() ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Insert( 0, Property::Value() ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetValue( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetKey( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetKeyAt( 1 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetPair( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetKeyValue( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( (const char *)"key" ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( std::string( "key" ) ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( 0, "key" ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( "key", Property::INTEGER ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( 0, Property::INTEGER ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Clear(), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Merge( Property::Map() ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1[ "key" ], exceptionMessage );
+ DALI_TEST_ASSERTION( const_cast< const Property::Map& >( map1 )[ "key" ], exceptionMessage );
+ DALI_TEST_ASSERTION( map1[ 0 ], exceptionMessage );
+ DALI_TEST_ASSERTION( const_cast< const Property::Map& >( map1 )[ 0 ], exceptionMessage );
+ DALI_TEST_ASSERTION( Property::Map temp; map1 = temp, exceptionMessage );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyMapMoveAssignmentOperator(void)
+{
+ Property::Map map1;
+ map1[ "hello" ] = 1;
+ map1[ "world" ] = 2;
+ map1[ 10 ] = "DALi";
+ DALI_TEST_EQUALS( 3u, map1.Count(), TEST_LOCATION );
+
+ Property::Map map2;
+ map2[ 10 ] = "DALi again";
+ DALI_TEST_EQUALS( 1u, map2.Count(), TEST_LOCATION );
+
+ map2 = std::move( map1 );
+ DALI_TEST_EQUALS( 3u, map2.Count(), TEST_LOCATION );
+
+ // Calling any methods on map1 will debug assert
+ const char * exceptionMessage = "Cannot use an object previously used as an r-value";
+ DALI_TEST_ASSERTION( map1.Count(), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Empty(), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Insert( (const char *)"key", Property::Value() ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Insert( std::string( "key" ), Property::Value() ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Insert( 0, Property::Value() ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetValue( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetKey( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetKeyAt( 1 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetPair( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.GetKeyValue( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( (const char *)"key" ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( std::string( "key" ) ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( 0 ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( 0, "key" ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( "key", Property::INTEGER ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Find( 0, Property::INTEGER ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Clear(), exceptionMessage );
+ DALI_TEST_ASSERTION( map1.Merge( Property::Map() ), exceptionMessage );
+ DALI_TEST_ASSERTION( map1[ "key" ], exceptionMessage );
+ DALI_TEST_ASSERTION( const_cast< const Property::Map& >( map1 )[ "key" ], exceptionMessage );
+ DALI_TEST_ASSERTION( map1[ 0 ], exceptionMessage );
+ DALI_TEST_ASSERTION( const_cast< const Property::Map& >( map1 )[ 0 ], exceptionMessage );
+ DALI_TEST_ASSERTION( Property::Map temp; map1 = temp, exceptionMessage );
+
+ // Self assignment
+ map2 = std::move( map2 );
+ DALI_TEST_EQUALS( 3u, map2.Count(), TEST_LOCATION ); // No debug assert as nothing should happen
+
+ END_TEST;
+}
+
int UtcDaliPropertyMapConstOperator(void)
{
Property::Map map;
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
END_TEST;
}
+int UtcDaliPropertyValueMoveConstructor(void)
+{
+ Property::Value value1( Vector4::ONE );
+ DALI_TEST_EQUALS( Property::VECTOR4, value1.GetType(), TEST_LOCATION );
+
+ Vector4 valueVector;
+ DALI_TEST_EQUALS( true, value1.Get( valueVector ), TEST_LOCATION ); // Able to convert
+ DALI_TEST_EQUALS( valueVector, Vector4::ONE, TEST_LOCATION );
+
+ Property::Value value2( std::move( value1 ) );
+ DALI_TEST_EQUALS( Property::NONE, value1.GetType(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value1.Get( valueVector ), TEST_LOCATION ); // Unable to convert, but no crash either
+ DALI_TEST_EQUALS( Property::VECTOR4, value2.GetType(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value2.Get( valueVector ), TEST_LOCATION ); // Able to convert
+ DALI_TEST_EQUALS( valueVector, Vector4::ONE, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyValueMoveConstructorArray(void)
+{
+ Property::Array array;
+ array.PushBack( 1 );
+ array.PushBack( 2 );
+ array.PushBack( 3 );
+ DALI_TEST_EQUALS( 3u, array.Size(), TEST_LOCATION );
+
+ Property::Value value( std::move( array ) );
+ DALI_TEST_ASSERTION( array.Size(), "Cannot use an object previously used as an r-value" ); // Our local variable should become invalid
+
+ Property::Array* arrayPtr = value.GetArray();
+ DALI_TEST_CHECK( arrayPtr );
+ DALI_TEST_EQUALS( 3u, arrayPtr->Size(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyValueMoveConstructorMap(void)
+{
+ Property::Map map;
+ map[ 1 ] = 1;
+ map[ 2 ] = 2;
+ map[ 3 ] = 3;
+ DALI_TEST_EQUALS( 3u, map.Count(), TEST_LOCATION );
+
+ Property::Value value( std::move( map ) );
+ DALI_TEST_ASSERTION( map.Count(), "Cannot use an object previously used as an r-value" ); // Our local variable should become invalid
+
+ Property::Map* mapPtr = value.GetMap();
+ DALI_TEST_CHECK( mapPtr );
+ DALI_TEST_EQUALS( 3u, mapPtr->Count(), TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliPropertyValueAssignmentSelfP(void)
{
Property::Value value;
END_TEST;
}
+int UtcDaliPropertyValueMoveAssignmentOperator(void)
+{
+ Property::Value value1( Vector4::ONE );
+ DALI_TEST_EQUALS( Property::VECTOR4, value1.GetType(), TEST_LOCATION );
+
+ Vector4 valueVector;
+ DALI_TEST_EQUALS( true, value1.Get( valueVector ), TEST_LOCATION ); // Able to convert
+ DALI_TEST_EQUALS( valueVector, Vector4::ONE, TEST_LOCATION );
+
+ Property::Value value2;
+ value2 = std::move( value1 );
+ DALI_TEST_EQUALS( Property::NONE, value1.GetType(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value1.Get( valueVector ), TEST_LOCATION ); // Unable to convert, but no crash either
+ DALI_TEST_EQUALS( Property::VECTOR4, value2.GetType(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value2.Get( valueVector ), TEST_LOCATION ); // Able to convert
+ DALI_TEST_EQUALS( valueVector, Vector4::ONE, TEST_LOCATION );
+
+ // Change to another value type
+ value2 = std::move( Property::Value( 1.0f ) );
+ DALI_TEST_EQUALS( false, value2.Get( valueVector ), TEST_LOCATION ); // Should not be able to convert to a Vector4 now
+ float valueFloat;
+ DALI_TEST_EQUALS( true, value2.Get( valueFloat ), TEST_LOCATION ); // Should be able to convert to a float now
+ DALI_TEST_EQUALS( valueFloat, 1.0f, TEST_LOCATION );
+
+ // Ensure self assignment doesn't do anything silly
+ value2 = std::move( value2 );
+ DALI_TEST_EQUALS( true, value2.Get( valueFloat ), TEST_LOCATION );
+ DALI_TEST_EQUALS( valueFloat, 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliPropertyValueGetTypeP(void)
{
Property::Value value;
Property::Value empty;
std::ostringstream stream;
stream << empty;
- DALI_TEST_EQUALS( stream.str(), "empty type", TEST_LOCATION );
+ DALI_TEST_EQUALS( stream.str(), "undefined type", TEST_LOCATION );
}
{
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
mImpl->mArray = other.mImpl->mArray;
}
+Property::Array::Array( Property::Array&& other )
+: mImpl( other.mImpl )
+{
+ other.mImpl = nullptr;
+}
+
Property::Array::~Array()
{
delete mImpl;
Property::Array::SizeType Property::Array::Count() const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
return mImpl->mArray.size();
}
void Property::Array::PushBack( const Value& value )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
mImpl->mArray.push_back( value );
}
void Property::Array::Clear()
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
mImpl->mArray.clear();
}
void Property::Array::Reserve( SizeType size )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
mImpl->mArray.reserve(size);
}
void Property::Array::Resize( SizeType size )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
mImpl->mArray.resize(size);
}
Property::Array::SizeType Property::Array::Capacity()
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
return mImpl->mArray.capacity();
}
const Property::Value& Property::Array::operator[]( SizeType index ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
+ // Note says no bounds checking is performed so we don't need to verify mImpl as Count() will return 0 anyway
return mImpl->mArray[ index ];
}
Property::Value& Property::Array::operator[]( SizeType index )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
+ // Note says no bounds checking is performed so we don't need to verify mImpl as Count() will return 0 anyway
return mImpl->mArray[ index ];
}
Property::Array& Property::Array::operator=( const Property::Array& other )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
if( this != &other )
{
- delete mImpl;
- mImpl = new Impl;
mImpl->mArray = other.mImpl->mArray;
}
return *this;
}
+Property::Array& Property::Array::operator=( Property::Array&& other )
+{
+ if( this != &other )
+ {
+ delete mImpl;
+ mImpl = other.mImpl;
+ other.mImpl = nullptr;
+ }
+ return *this;
+}
+
std::ostream& operator<<( std::ostream& stream, const Property::Array& array )
{
stream << "Array(" << array.Count() << ") = [";
-#ifndef __DALI_PROPERTY_ARRAY_H__
-#define __DALI_PROPERTY_ARRAY_H__
+#ifndef DALI_PROPERTY_ARRAY_H
+#define DALI_PROPERTY_ARRAY_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
Array( const Array& other );
/**
+ * @brief Move Constructor.
+ *
+ * @SINCE_1_4.17
+ * @param[in] other The Array to move from
+ * @note The other array is an r-value so becomes invalid and is no longer usable.
+ */
+ Array( Array&& other );
+
+ /**
* @brief Non-virtual destructor.
* @SINCE_1_0.0
*/
Array& operator=( const Array& other );
/**
+ * @brief Move Assignment Operator.
+ *
+ * @SINCE_1_4.17
+ * @param[in] other The array to copy from
+ *
+ * @return The moved array.
+ *
+ * @note The other array is an r-value so becomes invalid and is no longer usable.
+ */
+ Array& operator=( Array&& other );
+
+ /**
* @brief Output to stream.
* @SINCE_1_1.28
*/
*/
} // namespace Dali
-#endif // __DALI_PROPERTY_ARRAY_H__
+#endif // DALI_PROPERTY_ARRAY_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
mImpl->mIndexValueContainer = other.mImpl->mIndexValueContainer;
}
+Property::Map::Map( Property::Map&& other )
+: mImpl( other.mImpl )
+{
+ other.mImpl = nullptr;
+}
+
Property::Map::~Map()
{
delete mImpl;
Property::Map::SizeType Property::Map::Count() const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
return mImpl->mStringValueContainer.size() + mImpl->mIndexValueContainer.size();
}
bool Property::Map::Empty() const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
return mImpl->mStringValueContainer.empty() && mImpl->mIndexValueContainer.empty();
}
void Property::Map::Insert( const char* key, const Value& value )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
mImpl->mStringValueContainer.push_back( std::make_pair( key, value ) );
}
void Property::Map::Insert( const std::string& key, const Value& value )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
mImpl->mStringValueContainer.push_back( std::make_pair( key, value ) );
}
void Property::Map::Insert( Property::Index key, const Value& value )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
mImpl->mIndexValueContainer.push_back( std::make_pair( key, value ) );
}
Property::Value& Property::Map::GetValue( SizeType position ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
SizeType numStringKeys = mImpl->mStringValueContainer.size();
SizeType numIndexKeys = mImpl->mIndexValueContainer.size();
DALI_ASSERT_ALWAYS( position < ( numStringKeys + numIndexKeys ) && "position out-of-bounds" );
{
DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetKey() is deprecated and will be removed from next release.\n" );
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
SizeType numStringKeys = mImpl->mStringValueContainer.size();
DALI_ASSERT_ALWAYS( position < numStringKeys && "position out-of-bounds" );
Property::Key Property::Map::GetKeyAt( SizeType position ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
SizeType numStringKeys = mImpl->mStringValueContainer.size();
SizeType numIndexKeys = mImpl->mIndexValueContainer.size();
DALI_ASSERT_ALWAYS( position < ( numStringKeys + numIndexKeys ) && "position out-of-bounds" );
{
DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetPair() is deprecated and will be removed from next release.\n" );
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
SizeType numStringKeys = mImpl->mStringValueContainer.size();
DALI_ASSERT_ALWAYS( position < ( numStringKeys ) && "position out-of-bounds" );
KeyValuePair Property::Map::GetKeyValue( SizeType position ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
SizeType numStringKeys = mImpl->mStringValueContainer.size();
SizeType numIndexKeys = mImpl->mIndexValueContainer.size();
Property::Value* Property::Map::Find( const char* key ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
for ( StringValueContainer::iterator iter = mImpl->mStringValueContainer.begin(), endIter = mImpl->mStringValueContainer.end(); iter != endIter; ++iter )
{
if ( iter->first == key )
Property::Value* Property::Map::Find( Property::Index key ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
for ( IndexValueContainer::iterator iter = mImpl->mIndexValueContainer.begin(), endIter = mImpl->mIndexValueContainer.end(); iter != endIter; ++iter )
{
if ( iter->first == key )
Property::Value* Property::Map::Find( const std::string& key, Property::Type type ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
for ( StringValueContainer::iterator iter = mImpl->mStringValueContainer.begin(), endIter = mImpl->mStringValueContainer.end(); iter != endIter; ++iter )
{
if( (iter->second.GetType() == type) && (iter->first == key) )
Property::Value* Property::Map::Find( Property::Index key, Property::Type type ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
for ( IndexValueContainer::iterator iter = mImpl->mIndexValueContainer.begin(), endIter = mImpl->mIndexValueContainer.end(); iter != endIter; ++iter )
{
if( (iter->second.GetType() == type) && (iter->first == key) )
void Property::Map::Clear()
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
mImpl->mStringValueContainer.clear();
mImpl->mIndexValueContainer.clear();
}
void Property::Map::Merge( const Property::Map& from )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
// Ensure we're not attempting to merge with ourself
if ( this != &from )
{
const Property::Value& Property::Map::operator[]( const std::string& key ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
for ( StringValueContainer::const_iterator iter = mImpl->mStringValueContainer.begin(), endIter = mImpl->mStringValueContainer.end(); iter != endIter; ++iter )
{
if ( iter->first == key )
Property::Value& Property::Map::operator[]( const std::string& key )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
for ( StringValueContainer::iterator iter = mImpl->mStringValueContainer.begin(), endIter = mImpl->mStringValueContainer.end(); iter != endIter; ++iter )
{
if ( iter->first == key )
const Property::Value& Property::Map::operator[]( Property::Index key ) const
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
for ( IndexValueContainer::const_iterator iter = mImpl->mIndexValueContainer.begin(), endIter = mImpl->mIndexValueContainer.end(); iter != endIter; ++iter )
{
if ( iter->first == key )
Property::Value& Property::Map::operator[]( Property::Index key )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
for ( IndexValueContainer::iterator iter = mImpl->mIndexValueContainer.begin(), endIter = mImpl->mIndexValueContainer.end(); iter != endIter; ++iter )
{
if ( iter->first == key )
Property::Map& Property::Map::operator=( const Property::Map& other )
{
+ DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" );
+
if( this != &other )
{
- delete mImpl;
- mImpl = new Impl;
mImpl->mStringValueContainer = other.mImpl->mStringValueContainer;
mImpl->mIndexValueContainer = other.mImpl->mIndexValueContainer;
}
return *this;
}
+Property::Map& Property::Map::operator=( Property::Map&& other )
+{
+ if( this != &other )
+ {
+ delete mImpl;
+ mImpl = other.mImpl;
+ other.mImpl = nullptr;
+ }
+ return *this;
+}
+
std::ostream& operator<<( std::ostream& stream, const Property::Map& map )
{
stream << "Map(" << map.Count() << ") = {";
- int32_t count = 0;
- // Output the String-Value pairs
- for ( StringValueContainer::iterator iter = map.mImpl->mStringValueContainer.begin(), endIter = map.mImpl->mStringValueContainer.end(); iter != endIter; ++iter )
+ if ( map.mImpl )
{
- if( count++ > 0 )
+ int32_t count = 0;
+ // Output the String-Value pairs
+ for ( StringValueContainer::iterator iter = map.mImpl->mStringValueContainer.begin(), endIter = map.mImpl->mStringValueContainer.end(); iter != endIter; ++iter )
{
- stream<<", ";
+ if( count++ > 0 )
+ {
+ stream<<", ";
+ }
+ stream<< iter->first << ":"<<iter->second;
}
- stream<< iter->first << ":"<<iter->second;
- }
- // Output the Index-Value pairs
- for ( IndexValueContainer::iterator iter = map.mImpl->mIndexValueContainer.begin(), endIter = map.mImpl->mIndexValueContainer.end(); iter != endIter; ++iter )
- {
- if( count++ > 0 )
+ // Output the Index-Value pairs
+ for ( IndexValueContainer::iterator iter = map.mImpl->mIndexValueContainer.begin(), endIter = map.mImpl->mIndexValueContainer.end(); iter != endIter; ++iter )
{
- stream<<", ";
+ if( count++ > 0 )
+ {
+ stream<<", ";
+ }
+ stream<< iter->first << ":"<<iter->second;
}
- stream<< iter->first << ":"<<iter->second;
}
stream << "}";
-#ifndef __DALI_PROPERTY_MAP_H__
-#define __DALI_PROPERTY_MAP_H__
+#ifndef DALI_PROPERTY_MAP_H
+#define DALI_PROPERTY_MAP_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
Map( const Map& other );
/**
+ * @brief Move Constructor.
+ *
+ * @SINCE_1_4.17
+ * @param[in] other The Map to move from
+ * @note The other array is an r-value so becomes invalid and is no longer usable.
+ */
+ Map( Map&& other );
+
+ /**
* @brief Non-virtual destructor.
* @SINCE_1_0.0
*/
Map& operator=( const Map& other );
/**
+ * @brief Move Assignment Operator.
+ *
+ * @SINCE_1_4.17
+ * @param[in] other The map to move from
+ *
+ * @return The moved map
+ *
+ * @note The other array is an r-value so becomes invalid and is no longer usable.
+ */
+ Map& operator=( Map&& other );
+
+ /**
* @brief Output to stream.
* @SINCE_1_1.28
*/
*/
} // namespace Dali
-#endif // __DALI_PROPERTY_MAP_H__
+#endif // DALI_PROPERTY_MAP_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
struct Property::Value::Impl
{
- Impl()
- : type( Property::NONE ),
- integerValue( 0 )
- { }
-
Impl( bool booleanValue )
: type( Property::BOOLEAN ),
integerValue( booleanValue )
quaternionValue.ToAxisAngle( angleAxisValue->axis, angleAxisValue->angle );
}
- Impl(const std::string& stringValue)
+ Impl( const std::string& stringValue )
: type( Property::STRING ),
stringValue( new std::string( stringValue ) )
{
{
}
+ Impl( Property::Array&& arrayValue )
+ : type( Property::ARRAY ),
+ arrayValue( new Property::Array( std::move( arrayValue ) ) )
+ {
+ }
+
Impl( const Property::Map& mapValue )
: type( Property::MAP ),
mapValue( new Property::Map( mapValue ) )
{
}
+ Impl( Property::Map&& mapValue )
+ : type( Property::MAP ),
+ mapValue( new Property::Map( std::move( mapValue ) ) )
+ {
+ }
+
Impl( const Extents& extentsValue )
: type( Property::EXTENTS ),
extentsValue( new Extents( extentsValue ) )
};
Property::Value::Value()
-: mImpl( NULL )
+: mImpl( nullptr )
{
}
}
Property::Value::Value( const char* stringValue )
-: mImpl( NULL )
+: mImpl( nullptr )
{
- if( stringValue ) // string constructor is undefined with NULL pointer
+ if( stringValue ) // string constructor is undefined with nullptr
{
mImpl = new Impl( std::string(stringValue) );
}
{
}
+Property::Value::Value( Property::Array&& arrayValue )
+: mImpl( new Impl( std::move( arrayValue ) ) )
+{
+}
+
Property::Value::Value( Property::Map& mapValue )
: mImpl( new Impl( mapValue ) )
{
}
+Property::Value::Value( Property::Map&& mapValue )
+: mImpl( new Impl( std::move( mapValue ) ) )
+{
+}
+
Property::Value::Value( const Extents& extentsValue )
: mImpl( new Impl( extentsValue ) )
{
}
Property::Value::Value( Type type )
-: mImpl( NULL )
+: mImpl( nullptr )
{
switch (type)
{
}
case Property::NONE:
{
- mImpl = new Impl();
+ // No need to create an Impl
break;
}
}
}
Property::Value::Value( const Property::Value& value )
-: mImpl( NULL )
+: mImpl( nullptr )
{
// reuse assignment operator
operator=( value );
}
+Property::Value::Value( Property::Value&& value )
+: mImpl( value.mImpl )
+{
+ value.mImpl = nullptr;
+}
+
Property::Value& Property::Value::operator=( const Property::Value& value )
{
if ( this == &value )
if( !value.mImpl )
{
delete mImpl;
- mImpl = NULL;
+ mImpl = nullptr;
return *this;
}
// first check if the type is the same, no need to change impl, just assign
break;
}
case Property::NONE:
- { // mImpl will be NULL, there's no way to get to this case
+ { // mImpl will be a nullptr, there's no way to get to this case
}
}
}
else
{
// different type, release old impl and create new
- Impl* newImpl( NULL );
+ Impl* newImpl( nullptr );
switch ( value.mImpl->type )
{
case Property::BOOLEAN:
break;
}
case Property::NONE:
- { // NULL value will be used for "empty" value
+ { // nullptr value will be used for "empty" value
}
}
delete mImpl;
return *this;
}
+Property::Value& Property::Value::operator=( Property::Value&& value )
+{
+ if( this != &value )
+ {
+ delete mImpl;
+ mImpl = value.mImpl;
+ value.mImpl = nullptr;
+ }
+
+ return *this;
+}
+
Property::Value::~Value()
{
delete mImpl;
Property::Array* Property::Value::GetArray() const
{
- Property::Array* array = NULL;
+ Property::Array* array = nullptr;
if( mImpl && (mImpl->type == ARRAY) ) // type cannot change in mImpl so array is allocated
{
array = mImpl->arrayValue;
Property::Map* Property::Value::GetMap() const
{
- Property::Map* map = NULL;
+ Property::Map* map = nullptr;
if( mImpl && (mImpl->type == MAP) ) // type cannot change in mImpl so map is allocated
{
map = mImpl->mapValue;
break;
}
case Dali::Property::NONE:
- {
- stream << "undefined type";
- break;
+ { // mImpl will be a nullptr, there's no way to get to this case
}
}
}
else
{
- stream << "empty type";
+ stream << "undefined type";
}
return stream;
}
#define __DALI_PROPERTY_VALUE_H__
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
Value( Property::Array& arrayValue );
/**
+ * @brief Creates an array property value.
+ *
+ * @SINCE_1_4.16
+ * @param[in] arrayValue An r-value array
+ */
+ Value( Property::Array&& arrayValue );
+
+ /**
* @brief Creates a map property value.
*
* @SINCE_1_0.0
- * @param[in] mapValue An array
+ * @param[in] mapValue A map
*/
Value( Property::Map& mapValue );
/**
+ * @brief Creates a map property value.
+ *
+ * @SINCE_1_4.16
+ * @param[in] mapValue An r-value map
+ */
+ Value( Property::Map&& mapValue );
+
+ /**
* @brief Creates an extents property value.
*
* @SINCE_1_2.62
Value( const Value& value );
/**
+ * @brief Move constructor.
+ *
+ * @SINCE_1_4.16
+ * @param[in] value The property value to move from
+ */
+ Value( Value&& value );
+
+ /**
* @brief Assigns a property value.
*
* @SINCE_1_0.0
Value& operator=( const Value& value );
/**
+ * @brief Move assignment operator.
+ *
+ * @SINCE_1_4.16
+ * @param[in] value The property value to move from
+ * @return a reference to this
+ */
+ Value& operator=( Value&& value );
+
+ /**
* @brief Non-virtual destructor.
*
* This class is not a base class.