1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_PROPERTIES_ANIMATABLE_ARITHMETIC_PROXY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_PROPERTIES_ANIMATABLE_ARITHMETIC_PROXY_H
18 
19 #include "core/components_ng/animation/animatable_arithmetic.h"
20 
21 namespace OHOS::Ace::NG {
22 class AnimatableArithmeticProxy : public AnimatableArithmetic<AnimatableArithmeticProxy> {
23 public:
24     AnimatableArithmeticProxy() = default;
AnimatableArithmeticProxy(RefPtr<CustomAnimatableArithmetic> object)25     explicit AnimatableArithmeticProxy(RefPtr<CustomAnimatableArithmetic> object) : object_(object) {}
26     virtual ~AnimatableArithmeticProxy() = default;
27 
Add(const AnimatableArithmeticProxy & val)28     AnimatableArithmeticProxy Add(const AnimatableArithmeticProxy& val) const override
29     {
30         if (!object_) {
31             return {};
32         }
33         if (!val.object_) {
34             return {};
35         }
36 
37         return AnimatableArithmeticProxy(object_->Add(val.object_));
38     }
39 
Minus(const AnimatableArithmeticProxy & val)40     AnimatableArithmeticProxy Minus(const AnimatableArithmeticProxy& val) const override
41     {
42         if (!object_) {
43             return {};
44         }
45         if (!val.object_) {
46             return {};
47         }
48         return AnimatableArithmeticProxy(object_->Minus(val.object_));
49     }
50 
Multiply(const float scale)51     AnimatableArithmeticProxy Multiply(const float scale) const override
52     {
53         if (!object_) {
54             return {};
55         }
56         return AnimatableArithmeticProxy(object_->Multiply(scale));
57     }
58 
IsEqual(const AnimatableArithmeticProxy & val)59     bool IsEqual(const AnimatableArithmeticProxy& val) const override
60     {
61         if (!object_) {
62             return {};
63         }
64         if (!val.object_) {
65             return {};
66         }
67         return object_->IsEqual(val.object_);
68     }
69 
GetObject()70     RefPtr<CustomAnimatableArithmetic> GetObject() const
71     {
72         return object_;
73     }
74 
75 private:
76     RefPtr<CustomAnimatableArithmetic> object_;
77 };
78 } // namespace OHOS::Ace::NG
79 
80 #endif // FOUNDATION_ACE_FRAMEWORKS_COMPONENTS_NG_PROPERTIES_ANIMATABLE_ARITHMETIC_PROXY_H
81