1 /*
2  * Copyright (c) 2021 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 #include "screen_manager/rs_screen_props.h"
17 
18 namespace OHOS {
19 namespace Rosen {
RSScreenProps(std::string propName,uint32_t propId,uint64_t value)20 RSScreenProps::RSScreenProps(std::string propName, uint32_t propId, uint64_t value)
21     : propName_(propName), propId_(propId), value_(value)
22 {
23 }
24 
SetPropertyName(const std::string & propName)25 void RSScreenProps::SetPropertyName(const std::string& propName)
26 {
27     propName_ = propName;
28 }
29 
SetPropId(uint32_t propId)30 void RSScreenProps::SetPropId(uint32_t propId)
31 {
32     propId_ = propId;
33 }
34 
SetValue(uint64_t value)35 void RSScreenProps::SetValue(uint64_t value)
36 {
37     value_ = value;
38 }
39 
GetPropertyName() const40 const std::string& RSScreenProps::GetPropertyName() const
41 {
42     return propName_;
43 }
44 
GetPropId() const45 uint32_t RSScreenProps::GetPropId() const
46 {
47     return propId_;
48 }
49 
GetValue() const50 uint64_t RSScreenProps::GetValue() const
51 {
52     return value_;
53 }
54 
Marshalling(Parcel & parcel) const55 bool RSScreenProps::Marshalling(Parcel &parcel) const
56 {
57     if (!parcel.WriteString(propName_)) {
58         return false;
59     }
60     if (!parcel.WriteUint32(propId_)) {
61         return false;
62     }
63     if (!parcel.WriteUint64(value_)) {
64         return false;
65     }
66     return true;
67 }
68 
Unmarshalling(Parcel & parcel)69 RSScreenProps* RSScreenProps::Unmarshalling(Parcel &parcel)
70 {
71     std::string propName;
72     uint32_t propId;
73     uint64_t value;
74     if (!parcel.ReadString(propName)) {
75         return nullptr;
76     }
77     if (!parcel.ReadUint32(propId)) {
78         return nullptr;
79     }
80     if (!parcel.ReadUint64(value)) {
81         return nullptr;
82     }
83     RSScreenProps* screenProps = new RSScreenProps(propName, propId, value);
84     return screenProps;
85 }
86 }
87 }
88