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