• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     parcel.WriteString(id_);
65     parcel.WriteInt32(type_);
66     parcel.WriteString(diskId_);
67     parcel.WriteInt32(state_);
68     parcel.WriteBool(errorFlag_);
69     return true;
70 }
71 
Unmarshalling(Parcel & parcel)72 std::unique_ptr<VolumeCore> VolumeCore::Unmarshalling(Parcel &parcel)
73 {
74     auto obj = std::make_unique<VolumeCore>();
75     obj->id_ = parcel.ReadString();
76     obj->type_ = parcel.ReadInt32();
77     obj->diskId_ = parcel.ReadString();
78     obj->state_ = parcel.ReadInt32();
79     obj->errorFlag_ = parcel.ReadBool();
80     return obj;
81 }
82 }
83 }