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 17 #ifndef DISTRIBUTEDDATAMGR_OBJECT_ASSET_MACHINE_H 18 #define DISTRIBUTEDDATAMGR_OBJECT_ASSET_MACHINE_H 19 20 #include "snapshot/machine_status.h" 21 22 namespace OHOS { 23 namespace DistributedObject { 24 using namespace OHOS::DistributedData; 25 struct ChangedAssetInfo { 26 ChangedAssetInfo() = default; 27 std::string deviceId; 28 DistributedData::Asset asset; 29 DistributedData::TransferStatus status = DistributedData::STATUS_STABLE; 30 AssetBindInfo bindInfo; 31 StoreInfo storeInfo; 32 ChangedAssetInfoChangedAssetInfo33 ChangedAssetInfo(const Asset& bindAsset, const AssetBindInfo& assetBindInfo, const StoreInfo& store) 34 { 35 asset = bindAsset; 36 bindInfo = assetBindInfo; 37 storeInfo = store; 38 } 39 }; 40 41 typedef int32_t (*Action) 42 (int32_t eventId, ChangedAssetInfo& changedAsset, Asset& asset, const std::pair<std::string, Asset>& newAsset); 43 44 struct DFAAction { 45 int32_t next; 46 Action before; 47 Action after; 48 }; 49 50 class ObjectAssetMachine { 51 public: 52 ObjectAssetMachine(); 53 54 static int32_t DFAPostEvent(AssetEvent eventId, ChangedAssetInfo& changedAsset, Asset& asset, 55 const std::pair<std::string, Asset>& newAsset = std::pair<std::string, Asset>()); 56 57 private: 58 }; 59 } // namespace DistributedObject 60 } // namespace OHOS 61 #endif // DISTRIBUTEDDATAMGR_OBJECT_ASSET_MACHINE_H 62