• 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 DRIVE_KIT_RECORD_H
17 #define DRIVE_KIT_RECORD_H
18 
19 #include <map>
20 
21 #include "dk_record_field.h"
22 #include "dk_reference.h"
23 
24 namespace DriveKit {
25 struct DKRecordsResponse {
26     int64_t time;
27     std::string deviceName;
28     std::string appId;
29 };
30 using DKFieldKey = std::string;
31 using DKRecordData = std::map<DKFieldKey, DKRecordField>;
32 class DKRecord {
33 public:
GetRecordId()34     DKRecordId GetRecordId() const
35     {
36         return id_;
37     };
GetRecordType()38     DKRecordType GetRecordType() const
39     {
40         return type_;
41     };
GetRecordCreateInfo()42     DKRecordsResponse GetRecordCreateInfo() const
43     {
44         return createInfo_;
45     };
GetRecordModifiedInfo()46     DKRecordsResponse GetRecordModifiedInfo() const
47     {
48         return modifiedInfo_;
49     };
GetRecordData(DKRecordData & fields)50     void GetRecordData(DKRecordData &fields) const
51     {
52         fields = this->fields_;
53     };
StealRecordData(DKRecordData & fields)54     void StealRecordData(DKRecordData &fields)
55     {
56         fields = std::move(fields_);
57     };
GetIsDelete()58     bool GetIsDelete() const
59     {
60         return isDelete_;
61     };
GetVersion()62     unsigned long GetVersion() const
63     {
64         return version_;
65     };
GetCreateTime()66     uint64_t GetCreateTime() const
67     {
68         return createdTime_;
69     }
GetEditedTime()70     uint64_t GetEditedTime() const
71     {
72         return editedTime_;
73     }
SetRecordId(DKRecordId id)74     void SetRecordId(DKRecordId id)
75     {
76         id_ = id;
77     };
SetRecordType(DKRecordType type)78     void SetRecordType(DKRecordType type)
79     {
80         type_ = type;
81     };
SetCreateInfo(DKRecordsResponse create)82     void SetCreateInfo(DKRecordsResponse create)
83     {
84         createInfo_ = std::move(create);
85     };
SetModifiedInfo(DKRecordsResponse modified)86     void SetModifiedInfo(DKRecordsResponse modified)
87     {
88         modifiedInfo_ = std::move(modified);
89     };
SetRecordData(const DKRecordData & fields)90     void SetRecordData(const DKRecordData &fields)
91     {
92         this->fields_ = std::move(fields);
93     };
SetRecordData(DKRecordData && fields)94     void SetRecordData(DKRecordData &&fields)
95     {
96         this->fields_ = std::move(fields);
97     };
SetDelete(bool isDelete)98     void SetDelete(bool isDelete)
99     {
100         isDelete_ = isDelete;
101     };
SetVersion(unsigned long version)102     void SetVersion(unsigned long version)
103     {
104         version_ = version;
105     };
SetNewCreate(bool isNew)106     void SetNewCreate(bool isNew)
107     {
108         isNewCreate_ = isNew;
109     };
SetCreateTime(uint64_t createdTime)110     void SetCreateTime(uint64_t createdTime)
111     {
112         createdTime_ = createdTime;
113     }
SetEditedTime(uint64_t editedTime)114     void SetEditedTime(uint64_t editedTime)
115     {
116         editedTime_ = editedTime;
117     }
118 private:
119     DKRecordId id_;
120     DKRecordType type_;
121     DKRecordsResponse createInfo_;
122     DKRecordsResponse modifiedInfo_;
123     DKRecordData fields_;
124     bool isDelete_;
125     unsigned long version_;
126     bool isNewCreate_ = false;
127     uint64_t createdTime_ = 0;
128     uint64_t editedTime_ = 0;
129 };
130 } // namespace DriveKit
131 #endif
132