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 "volume_core.h"
17
18 namespace OHOS {
19 namespace StorageManager {
VolumeCore()20 VolumeCore::VolumeCore() {}
21
VolumeCore(std::string id,int type,std::string diskId)22 VolumeCore::VolumeCore(std::string id, int type, std::string diskId)
23 {
24 id_ = id;
25 type_ = type;
26 diskId_ = diskId;
27 }
28
VolumeCore(std::string id,int type,std::string diskId,int32_t state)29 VolumeCore::VolumeCore(std::string id, int type, std::string diskId, int32_t state)
30 {
31 id_ = id;
32 type_ = type;
33 diskId_ = diskId;
34 state_ = state;
35 }
36
SetState(int32_t state)37 void VolumeCore::SetState(int32_t state)
38 {
39 state_ = state;
40 }
41
GetId()42 std::string VolumeCore::GetId()
43 {
44 return id_;
45 }
46
GetType()47 int VolumeCore::GetType()
48 {
49 return type_;
50 }
51
GetDiskId()52 std::string VolumeCore::GetDiskId()
53 {
54 return diskId_;
55 }
56
GetState()57 int32_t VolumeCore::GetState()
58 {
59 return state_;
60 }
61
Marshalling(Parcel & parcel) const62 bool VolumeCore::Marshalling(Parcel &parcel) const
63 {
64 if (!parcel.WriteString(id_)) {
65 return false;
66 }
67
68 if (!parcel.WriteInt32(type_)) {
69 return false;
70 }
71
72 if (!parcel.WriteString(diskId_)) {
73 return false;
74 }
75
76 if (!parcel.WriteInt32(state_)) {
77 return false;
78 }
79
80 if (!parcel.WriteBool(errorFlag_)) {
81 return false;
82 }
83
84 return true;
85 }
86
Unmarshalling(Parcel & parcel)87 std::unique_ptr<VolumeCore> VolumeCore::Unmarshalling(Parcel &parcel)
88 {
89 auto obj = std::make_unique<VolumeCore>();
90 obj->id_ = parcel.ReadString();
91 obj->type_ = parcel.ReadInt32();
92 obj->diskId_ = parcel.ReadString();
93 obj->state_ = parcel.ReadInt32();
94 obj->errorFlag_ = parcel.ReadBool();
95 return obj;
96 }
97 }
98 }
99