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"
22namespace OHOS {
23namespace UDMF {
24class API_EXPORT UnifiedData {
25public:
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) const;
38    void SetRecords(std::vector<std::shared_ptr<UnifiedRecord>> records);
39    std::vector<std::shared_ptr<UnifiedRecord>> GetRecords() const;
40
41    std::string GetTypes();
42    std::vector<std::string> GetTypesLabels() const;
43    bool HasType(const std::string &type) const;
44    std::vector<std::string> GetEntriesTypes() const;
45    bool HasTypeInEntries(const std::string &type) const;
46
47    bool IsEmpty() const;
48    bool IsValid();
49    bool IsComplete();
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
58    static constexpr int64_t MAX_DATA_SIZE = 200 * 1024 * 1024;
59
60private:
61    uint32_t dataId_ = 0;
62    uint32_t recordId_ = 0;
63    std::string channelName_;
64    std::shared_ptr<Runtime> runtime_;
65    std::vector<std::shared_ptr<UnifiedRecord>> records_;
66    std::shared_ptr<UnifiedDataProperties> properties_;
67};
68} // namespace UDMF
69} // namespace OHOS
70#endif // UDMF_UNIFIED_DATA_H
71