• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 UnifiedData {
25 public:
26     API_EXPORT UnifiedData();
27     explicit API_EXPORT UnifiedData(std::shared_ptr<UnifiedDataProperties> properties);
28 
29     int64_t API_EXPORT GetSize();
30     std::string GetGroupId() const;
31 
32     std::shared_ptr<Runtime> API_EXPORT GetRuntime() const;
33     void API_EXPORT SetRuntime(Runtime &runtime);
34 
35     void API_EXPORT AddRecord(const std::shared_ptr<UnifiedRecord> &record);
36     void API_EXPORT AddRecords(const std::vector<std::shared_ptr<UnifiedRecord>> &records);
37     std::shared_ptr<UnifiedRecord> API_EXPORT GetRecordAt(std::size_t index) const;
38     void API_EXPORT SetRecords(std::vector<std::shared_ptr<UnifiedRecord>> records);
39     std::vector<std::shared_ptr<UnifiedRecord>> API_EXPORT GetRecords() const;
40 
41     std::vector<std::string> API_EXPORT GetTypesLabels() const;
42     bool API_EXPORT HasType(const std::string &type) const;
43     bool API_EXPORT HasHigherFileType(const std::string &type) const;
44     std::vector<std::string> API_EXPORT GetEntriesTypes() const;
45     bool API_EXPORT HasTypeInEntries(const std::string &type) const;
46 
47     bool API_EXPORT IsEmpty() const;
48     bool API_EXPORT IsValid();
49     bool API_EXPORT IsComplete();
50     bool HasFileType() const;
51     bool HasUriInfo() const;
52     void ClearUriInfo() const;
53 
54     void API_EXPORT SetProperties(std::shared_ptr<UnifiedDataProperties> properties);
55     std::shared_ptr<UnifiedDataProperties> API_EXPORT GetProperties() const;
56 
57     void API_EXPORT SetDataId(uint32_t dataId);
58     uint32_t GetDataId() const;
59     void SetChannelName(const std::string &name);
60     std::vector<std::string> GetFileUris() const;
61     std::string API_EXPORT GetSdkVersion() const;
62     void API_EXPORT SetSdkVersion(const std::string &version);
63     bool API_EXPORT IsNeedTransferToEntries() const;
64     void API_EXPORT ConvertRecordsToEntries();
65 
66     static constexpr int64_t MAX_DATA_SIZE = 200 * 1024 * 1024;
67 
68 private:
69     std::set<std::string> GetTypIds() const;
70 
71     uint32_t dataId_ = 0;
72     uint32_t recordId_ = 0;
73     std::string channelName_;
74     std::shared_ptr<Runtime> runtime_;
75     std::vector<std::shared_ptr<UnifiedRecord>> records_;
76     std::shared_ptr<UnifiedDataProperties> properties_;
77     std::string sdkVersion_;
78 };
79 } // namespace UDMF
80 } // namespace OHOS
81 #endif // UDMF_UNIFIED_DATA_H
82