Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / animations / FUiAnimVisualElementPropertyAnimation.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FUiAnimVisualElementPropertyAnimation.cpp
20  * @brief       This file contains implementation of VisualElementPropertyAnimation class
21  *
22  * This file contains implementation VisualElementPropertyAnimation class.
23  */
24
25 #include <FBaseSysLog.h>
26
27 #include <FUiAnimVisualElementPropertyAnimation.h>
28
29 #include "FUiAnim_VisualElementPropertyAnimationImpl.h"
30
31 namespace Tizen { namespace Ui { namespace Animations
32 {
33
34 VisualElementPropertyAnimation::VisualElementPropertyAnimation(void)
35         : VisualElementValueAnimation(new (std::nothrow) _VisualElementPropertyAnimationImpl())
36 {
37         if (_pAnimationImpl == null)
38         {
39                 SetLastResult(E_OUT_OF_MEMORY);
40         }
41 }
42
43 VisualElementPropertyAnimation::~VisualElementPropertyAnimation(void)
44 {
45
46 }
47
48 VisualElementPropertyAnimation::VisualElementPropertyAnimation(const VisualElementPropertyAnimation& animation)
49         : VisualElementValueAnimation(null)
50 {
51         ClearLastResult();
52
53         const _VisualElementPropertyAnimationImpl* pAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(animation);
54
55         _pAnimationImpl = new (std::nothrow) _VisualElementPropertyAnimationImpl(*pAnimationImpl);
56         SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationImpl), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
57 }
58
59 VisualElementPropertyAnimation&
60 VisualElementPropertyAnimation::operator =(const VisualElementPropertyAnimation& rhs)
61 {
62         ClearLastResult();
63
64         if (this != (&rhs))
65         {
66                 _VisualElementPropertyAnimationImpl* pAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(*this);
67                 const _VisualElementPropertyAnimationImpl* pRhsAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(rhs);
68
69                 result r = pAnimationImpl->CopyAnimationValue(*pRhsAnimationImpl);
70                 SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, r, "[%s] Failed to copy the animation value.", GetErrorMessage(r));
71         }
72
73         return *this;
74 }
75
76 bool
77 VisualElementPropertyAnimation::operator ==(const VisualElementPropertyAnimation& rhs) const
78 {
79         return VisualElementValueAnimation::operator ==(rhs);
80 }
81
82 bool
83 VisualElementPropertyAnimation::operator !=(const VisualElementPropertyAnimation& rhs) const
84 {
85         return (!operator ==(rhs));
86 }
87
88 bool
89 VisualElementPropertyAnimation::Equals(const Tizen::Base::Object& obj) const
90 {
91         const VisualElementPropertyAnimation* pAnimation = dynamic_cast< const VisualElementPropertyAnimation* >(&obj);
92
93         if (pAnimation == null)
94         {
95                 return false;
96         }
97
98         return (*this == *pAnimation);
99 }
100
101 int
102 VisualElementPropertyAnimation::GetHashCode(void) const
103 {
104         return VisualElementValueAnimation::GetHashCode();
105 }
106
107 VisualElementAnimation*
108 VisualElementPropertyAnimation::CloneN(void) const
109 {
110         VisualElementPropertyAnimation* pCloned = new (std::nothrow) VisualElementPropertyAnimation(*this);
111         SysTryReturn(NID_UI_ANIM, (pCloned != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
112
113         return pCloned;
114 }
115
116 result
117 VisualElementPropertyAnimation::SetPropertyName(const Tizen::Base::String& property)
118 {
119         _VisualElementPropertyAnimationImpl* pAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(*this);
120
121         SysTryReturnResult(NID_UI_ANIM, (property.IsEmpty() == false), E_INVALID_ARG, "Invalid argument(s) is used. property is empty.");
122
123         pAnimationImpl->SetPropertyName(property);
124
125         return E_SUCCESS;
126 }
127
128 Tizen::Base::String
129 VisualElementPropertyAnimation::GetPropertyName(void) const
130 {
131         const _VisualElementPropertyAnimationImpl* pAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(*this);
132
133         return pAnimationImpl->GetPropertyName();
134 }
135
136 }}}   // Tizen::Ui::Animations
137