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 #ifndef STORAGE_SERVICES_DEV_INFO_H 16 #define STORAGE_SERVICES_DEV_INFO_H 17 18 #include <string> 19 #include "file_manager_service_def.h" 20 namespace OHOS { 21 namespace FileManagerService { 22 class DevInfo { 23 public: 24 DevInfo() = default; 25 ~DevInfo() = default; DevInfo(const std::string & nameIn,const std::string & pathIn)26 DevInfo(const std::string &nameIn, const std::string &pathIn) : name_(nameIn), path_(pathIn) 27 {} 28 DevInfo(const DevInfo & dev)29 DevInfo(const DevInfo &dev) 30 { 31 this->name_ = dev.name_; 32 this->path_ = dev.path_; 33 } 34 35 DevInfo& operator=(const DevInfo& dev) 36 { 37 this->name_ = dev.name_; 38 this->path_ = dev.path_; 39 return *this; 40 } 41 GetName()42 std::string GetName() const 43 { 44 return name_; 45 } 46 SetName(const std::string & name)47 void SetName(const std::string& name) 48 { 49 name_ = name; 50 } 51 GetPath()52 std::string GetPath() const 53 { 54 return path_; 55 } 56 SetPath(const std::string & path)57 void SetPath(const std::string& path) 58 { 59 path_ = path; 60 } 61 62 private: 63 std::string name_ {""}; 64 std::string path_ {""}; 65 }; 66 67 class CmdOptions { 68 public: 69 CmdOptions() = default; 70 ~CmdOptions() = default; 71 CmdOptions(DevInfo devIn,int64_t offsetIn,int64_t countIn,bool hasOptIn)72 CmdOptions(DevInfo devIn, int64_t offsetIn, int64_t countIn, bool hasOptIn) 73 : dev_(devIn), offset_(offsetIn), count_(countIn), hasOpt_(hasOptIn) 74 {} CmdOptions(const std::string & nameIn,const std::string & pathIn,int64_t offsetIn,int64_t countIn,bool hasOptIn)75 CmdOptions(const std::string &nameIn, const std::string &pathIn, 76 int64_t offsetIn, int64_t countIn, bool hasOptIn) 77 : dev_(nameIn, pathIn), offset_(offsetIn), count_(countIn), hasOpt_(hasOptIn) 78 {} 79 80 CmdOptions(const CmdOptions &option) = default; 81 CmdOptions& operator=(const CmdOptions& option) = default; 82 GetDevInfo()83 DevInfo GetDevInfo() const 84 { 85 return dev_; 86 } 87 SetDevInfo(const DevInfo & dev)88 void SetDevInfo(const DevInfo& dev) 89 { 90 dev_ = dev; 91 } 92 GetOffset()93 int64_t GetOffset() const 94 { 95 return offset_; 96 } 97 SetOffset(int64_t offset)98 void SetOffset(int64_t offset) 99 { 100 offset_ = offset; 101 } 102 GetCount()103 int64_t GetCount() const 104 { 105 return count_; 106 } 107 setCount(int64_t count)108 void setCount(int64_t count) 109 { 110 count_ = count; 111 } 112 GetHasOpt()113 bool GetHasOpt() const 114 { 115 return hasOpt_; 116 } 117 SetHasOpt(bool hasOpt)118 void SetHasOpt(bool hasOpt) 119 { 120 hasOpt_ = hasOpt; 121 } 122 123 private: 124 DevInfo dev_; 125 int64_t offset_ {0}; 126 int64_t count_ {MAX_NUM}; 127 bool hasOpt_ {false}; 128 }; 129 } // namespace FileManagerService 130 } // namespace OHOS 131 #endif // STORAGE_SERVICES_DEV_INFO_H