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 private: 33 friend SyncEvent; 34 bool retry_ = false; 35 int32_t mode_ = -1; 36 int32_t wait_ = 0; 37 std::shared_ptr<GenQuery> query_; 38 GenAsync asyncDetail_; 39 bool isCompensation_ = false; 40 int32_t triggerMode_ = MODE_DEFAULT; 41 std::string prepareTraceId_; 42 int32_t user_ = 0; 43 }; 44 SyncEvent(StoreInfo storeInfo, EventInfo info); 45 ~SyncEvent() override = default; 46 int32_t GetMode() const; 47 int32_t GetWait() const; 48 bool AutoRetry() const; 49 std::shared_ptr<GenQuery> GetQuery() const; 50 GenAsync GetAsyncDetail() const; 51 bool IsCompensation() const; 52 int32_t GetTriggerMode() const; 53 std::string GetPrepareTraceId() const; 54 int32_t GetUser() const; 55 protected: 56 SyncEvent(int32_t evtId, StoreInfo storeInfo, EventInfo info); 57 58 private: 59 EventInfo info_; 60 }; 61 } // namespace OHOS::DistributedData 62 #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_SYNC_EVENT_H 63