• 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 OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_SYNC_EVENT_H
17 #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_SYNC_EVENT_H
18 #include "cloud/cloud_event.h"
19 #include "store/general_value.h"
20 #include "visibility.h"
21 namespace OHOS::DistributedData {
22 class API_EXPORT SyncEvent : public CloudEvent {
23 public:
24     class EventInfo {
25     public:
26         API_EXPORT EventInfo(int32_t mode, int32_t wait, bool retry, std::shared_ptr<GenQuery> query, GenAsync async);
27         API_EXPORT EventInfo(const SyncParam &syncParam, bool retry, std::shared_ptr<GenQuery> query, GenAsync async);
28         API_EXPORT EventInfo(EventInfo &&info) noexcept;
29         EventInfo(const EventInfo &info) = default;
30         API_EXPORT EventInfo &operator=(EventInfo &&info) noexcept;
31         EventInfo &operator=(const EventInfo &info) = default;
32 
33     private:
34         friend SyncEvent;
35         bool retry_ = false;
36         int32_t mode_ = -1;
37         int32_t wait_ = 0;
38         std::shared_ptr<GenQuery> query_;
39         GenAsync asyncDetail_;
40         bool isCompensation_ = false;
41         int32_t triggerMode_ = MODE_DEFAULT;
42         std::string prepareTraceId_;
43         int32_t user_ = 0;
44     };
45     SyncEvent(StoreInfo storeInfo, EventInfo info);
46     ~SyncEvent() override = default;
47     int32_t GetMode() const;
48     int32_t GetWait() const;
49     bool AutoRetry() const;
50     std::shared_ptr<GenQuery> GetQuery() const;
51     GenAsync GetAsyncDetail() const;
52     bool IsCompensation() const;
53     int32_t GetTriggerMode() const;
54     std::string GetPrepareTraceId() const;
55     int32_t GetUser() const;
56 
57 protected:
58     SyncEvent(int32_t evtId, StoreInfo storeInfo, EventInfo info);
59 
60 private:
61     EventInfo info_;
62 };
63 } // namespace OHOS::DistributedData
64 #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_SYNC_EVENT_H