• 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 #include "cloud/sync_event.h"
17 
18 namespace OHOS::DistributedData {
EventInfo(int32_t mode,int32_t wait,bool retry,std::shared_ptr<GenQuery> query,GenAsync async)19 SyncEvent::EventInfo::EventInfo(int32_t mode, int32_t wait, bool retry, std::shared_ptr<GenQuery> query, GenAsync async)
20     : retry_(retry), mode_(mode), wait_(wait), query_(std::move(query)), asyncDetail_(std::move(async))
21 {
22 }
23 
EventInfo(SyncEvent::EventInfo && info)24 SyncEvent::EventInfo::EventInfo(SyncEvent::EventInfo &&info) noexcept
25 {
26     operator=(std::move(info));
27 }
28 
operator =(SyncEvent::EventInfo && info)29 SyncEvent::EventInfo &SyncEvent::EventInfo::operator=(SyncEvent::EventInfo &&info) noexcept
30 {
31     if (this == &info) {
32         return *this;
33     }
34     retry_ = info.retry_;
35     mode_ = info.mode_;
36     wait_ = info.wait_;
37     query_ = std::move(info.query_);
38     asyncDetail_ = std::move(info.asyncDetail_);
39     return *this;
40 }
41 
SyncEvent(StoreInfo storeInfo,EventInfo info)42 SyncEvent::SyncEvent(StoreInfo storeInfo, EventInfo info)
43     : CloudEvent(CLOUD_SYNC, std::move(storeInfo)), info_(std::move(info))
44 {
45 }
46 
SyncEvent(int32_t evtId,StoreInfo storeInfo,EventInfo info)47 SyncEvent::SyncEvent(int32_t evtId, StoreInfo storeInfo, EventInfo info)
48     : CloudEvent(evtId, std::move(storeInfo)), info_(std::move(info))
49 {
50 }
51 
GetMode() const52 int32_t SyncEvent::GetMode() const
53 {
54     return info_.mode_;
55 }
56 
GetWait() const57 int32_t SyncEvent::GetWait() const
58 {
59     return info_.wait_;
60 }
61 
AutoRetry() const62 bool SyncEvent::AutoRetry() const
63 {
64     return info_.retry_;
65 }
66 
GetQuery() const67 std::shared_ptr<GenQuery> SyncEvent::GetQuery() const
68 {
69     return info_.query_;
70 }
71 
GetAsyncDetail() const72 GenAsync SyncEvent::GetAsyncDetail() const
73 {
74     return info_.asyncDetail_;
75 }
76 } // namespace OHOS::DistributedData