1 /* 2 * Copyright (c) 2023 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 UDMF_UNIFIED_DATA_H 17 #define UDMF_UNIFIED_DATA_H 18 19 #include "unified_data_properties.h" 20 #include "unified_record.h" 21 #include "visibility.h" 22 namespace OHOS { 23 namespace UDMF { 24 class API_EXPORT UnifiedData { 25 public: 26 UnifiedData(); 27 explicit UnifiedData(std::shared_ptr<UnifiedDataProperties> properties); 28 29 int64_t GetSize(); 30 std::string GetGroupId() const; 31 32 std::shared_ptr<Runtime> GetRuntime() const; 33 void SetRuntime(Runtime &runtime); 34 35 void AddRecord(const std::shared_ptr<UnifiedRecord> &record); 36 void AddRecords(const std::vector<std::shared_ptr<UnifiedRecord>> &records); 37 std::shared_ptr<UnifiedRecord> GetRecordAt(std::size_t index); 38 void SetRecords(std::vector<std::shared_ptr<UnifiedRecord>> records); 39 std::vector<std::shared_ptr<UnifiedRecord>> GetRecords() const; 40 41 std::vector<std::string> GetTypesLabels() const; 42 bool HasType(const std::string &type) const; 43 std::vector<std::string> GetEntriesTypes() const; 44 bool HasTypeInEntries(const std::string &type) const; 45 46 bool IsEmpty() const; 47 bool IsValid(); 48 bool IsComplete(); 49 bool HasFileType() const; 50 51 void SetProperties(std::shared_ptr<UnifiedDataProperties> properties); 52 std::shared_ptr<UnifiedDataProperties> GetProperties() const; 53 54 void SetDataId(uint32_t dataId); 55 uint32_t GetDataId() const; 56 void SetChannelName(const std::string &name); 57 std::vector<std::string> GetFileUris() const; 58 59 static constexpr int64_t MAX_DATA_SIZE = 200 * 1024 * 1024; 60 61 private: 62 std::set<std::string> GetTypIds() const; 63 64 uint32_t dataId_ = 0; 65 uint32_t recordId_ = 0; 66 std::string channelName_; 67 std::shared_ptr<Runtime> runtime_; 68 std::vector<std::shared_ptr<UnifiedRecord>> records_; 69 std::shared_ptr<UnifiedDataProperties> properties_; 70 }; 71 } // namespace UDMF 72 } // namespace OHOS 73 #endif // UDMF_UNIFIED_DATA_H 74