/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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( const Rect<float>& rectValue )
+ : type( Property::VECTOR4 ),
+ vector4Value( new Vector4( rectValue.x, rectValue.y, rectValue.width, rectValue.height ) )
+ {
+ }
+
Impl( const Property::Array& arrayValue )
: type( Property::ARRAY ),
arrayValue( new Property::Array( arrayValue ) )
{
}
+ 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 ) )
{
}
+ Impl( const std::initializer_list< KeyValuePair >& values )
+ : type( Property::MAP ),
+ mapValue( new Property::Map( values ) )
+ {
+ }
+
/**
* Destructor, takes care of releasing the dynamically allocated types
*/
private:
- Impl( const Impl& ); ///< Undefined
- Impl& operator=( const Impl& ); ///< Undefined
+ // non-copyable
+ Impl( const Impl& ) = delete;
+ Impl& operator=( const Impl& ) = delete;
+
};
Property::Value::Value()
-: mImpl( NULL )
+: mImpl( nullptr )
{
}
{
}
-Property::Value::Value( const Rect<int>& rectValue )
+Property::Value::Value( const Rect<int32_t>& rectValue )
+: mImpl( new Impl( rectValue ) )
+{
+}
+
+Property::Value::Value( const Rect<float>& rectValue )
: mImpl( new Impl( rectValue ) )
{
}
}
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( const std::initializer_list< KeyValuePair >& values )
+: mImpl( new Impl( values ) )
+{
+}
+
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;
return converted;
}
-bool Property::Value::Get( int& integerValue ) const
+bool Property::Value::Get( int32_t& integerValue ) const
{
bool converted = false;
if( mImpl )
return converted;
}
-bool Property::Value::Get( Rect<int>& rectValue ) const
+bool Property::Value::Get( Rect<int32_t>& rectValue ) const
{
bool converted = false;
if( mImpl && (mImpl->type == RECTANGLE) ) // type cannot change in mImpl so rect is allocated
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;
}