1 /* 2 * Copyright (c) 2024 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 MTPFS_TYPE_BASIC_H 17 #define MTPFS_TYPE_BASIC_H 18 19 #include <string> 20 #include <cstdint> 21 22 class MtpFsTypeBasic { 23 public: MtpFsTypeBasic()24 MtpFsTypeBasic() : id_(0), parentId_(0), storageId_(0), name_() {} 25 MtpFsTypeBasic(uint32_t id,uint32_t parentId,uint32_t storageId,const std::string & name)26 MtpFsTypeBasic(uint32_t id, uint32_t parentId, uint32_t storageId, const std::string &name) 27 : id_(id), parentId_(parentId), storageId_(storageId), name_(name) 28 {} 29 MtpFsTypeBasic(const MtpFsTypeBasic & copy)30 MtpFsTypeBasic(const MtpFsTypeBasic ©) 31 : id_(copy.id_), parentId_(copy.parentId_), storageId_(copy.storageId_), name_(copy.name_) 32 {} 33 Id()34 uint32_t Id() const 35 { 36 return id_; 37 } ParentId()38 uint32_t ParentId() const 39 { 40 return parentId_; 41 } StorageId()42 uint32_t StorageId() const 43 { 44 return storageId_; 45 } Name()46 std::string Name() const 47 { 48 return name_; 49 } 50 SetId(uint32_t id)51 void SetId(uint32_t id) 52 { 53 id_ = id; 54 } SetParent(uint32_t parentId)55 void SetParent(uint32_t parentId) 56 { 57 parentId_ = parentId; 58 } SetStorage(uint32_t storageId)59 void SetStorage(uint32_t storageId) 60 { 61 storageId_ = storageId; 62 } SetName(const std::string & name)63 void SetName(const std::string &name) 64 { 65 name_ = name; 66 } 67 68 MtpFsTypeBasic &operator = (const MtpFsTypeBasic &rhs) 69 { 70 id_ = rhs.id_; 71 parentId_ = rhs.parentId_; 72 storageId_ = rhs.storageId_; 73 name_ = rhs.name_; 74 return *this; 75 } 76 77 bool operator == (const std::string &rhs) const 78 { 79 return name_ == rhs; 80 } 81 bool operator == (const MtpFsTypeBasic &rhs) const 82 { 83 return name_ == rhs.name_; 84 } 85 bool operator < (const std::string &rhs) const 86 { 87 return name_ < rhs; 88 } 89 bool operator < (const MtpFsTypeBasic &rhs) const 90 { 91 return name_ < rhs.name_; 92 } 93 94 protected: 95 uint32_t id_; 96 uint32_t parentId_; 97 uint32_t storageId_; 98 std::string name_; 99 }; 100 101 #endif // MTPFS_TYPE_BASIC_H 102