• 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 #ifndef IASSET_LOADER_H
16 #define IASSET_LOADER_H
17 
18 #include <cstdint>
19 #include <functional>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include "cloud/cloud_store_types.h"
24 
25 namespace DistributedDB {
26 class IAssetLoader {
27 public:
28     virtual ~IAssetLoader() = default;
29 
30     // for single primary key data, prefix is the key; otherwise, prefix is default value of std::std::monostate
Download(const std::string & tableName,const std::string & gid,const Type & prefix,std::map<std::string,Assets> & assets)31     virtual DBStatus Download(const std::string &tableName, const std::string &gid, const Type &prefix,
32         std::map<std::string, Assets> &assets)
33     {
34         return DBStatus::OK;
35     }
36 
RemoveLocalAssets(const std::vector<Asset> & assets)37     virtual DBStatus RemoveLocalAssets(const std::vector<Asset> &assets)
38     {
39         return DBStatus::OK;
40     }
41 
RemoveLocalAssets(const std::string & tableName,const std::string & gid,const Type & prefix,std::map<std::string,Assets> & assets)42     virtual DBStatus RemoveLocalAssets(const std::string &tableName, const std::string &gid, const Type &prefix,
43         std::map<std::string, Assets> &assets)
44     {
45         return DBStatus::OK;
46     }
47 
48     struct AssetRecord {
49         const std::string gid;
50         const Type prefix;
51         std::map<std::string, Assets> assets;
52         DBStatus status = OK;
53     };
54 
BatchDownload(const std::string & tableName,std::vector<AssetRecord> & downloadAssets)55     virtual void BatchDownload(const std::string &tableName, std::vector<AssetRecord> &downloadAssets)
56     {
57     }
58 
BatchRemoveLocalAssets(const std::string & tableName,std::vector<AssetRecord> & removeAssets)59     virtual void BatchRemoveLocalAssets(const std::string &tableName, std::vector<AssetRecord> &removeAssets)
60     {
61     }
62 
CancelDownload()63     virtual DBStatus CancelDownload()
64     {
65         return OK;
66     }
67 };
68 } // namespace DistributedDB
69 
70 #endif // IASSET_LOADER_H