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_CLOUD_SERVER_H 17 #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_SERVER_H 18 #include "cloud/asset_loader.h" 19 #include "cloud/cloud_db.h" 20 #include "cloud/cloud_info.h" 21 #include "cloud/schema_meta.h" 22 #include "cloud/sharing_center.h" 23 #include "executor_pool.h" 24 #include "visibility.h" 25 namespace OHOS::DistributedData { 26 class API_EXPORT CloudServer { 27 public: 28 using Database = SchemaMeta::Database; 29 API_EXPORT static CloudServer *GetInstance(); 30 API_EXPORT static bool RegisterCloudInstance(CloudServer *instance); 31 32 virtual CloudInfo GetServerInfo(int32_t userId, bool needSpaceInfo = true); 33 virtual std::pair<int32_t, SchemaMeta> GetAppSchema(int32_t userId, const std::string &bundleName); 34 virtual int32_t Subscribe(int32_t userId, const std::map<std::string, std::vector<Database>> &dbs); 35 virtual int32_t Unsubscribe(int32_t userId, const std::map<std::string, std::vector<Database>> &dbs); 36 virtual std::shared_ptr<AssetLoader> ConnectAssetLoader( 37 const std::string &bundleName, int user, const Database &dbMeta); 38 virtual std::shared_ptr<AssetLoader> ConnectAssetLoader(uint32_t tokenId, const Database &dbMeta); 39 virtual std::shared_ptr<CloudDB> ConnectCloudDB(const std::string &bundleName, int user, const Database &dbMeta); 40 virtual std::shared_ptr<CloudDB> ConnectCloudDB(uint32_t tokenId, const Database &dbMeta); 41 virtual std::shared_ptr<SharingCenter> ConnectSharingCenter(int32_t userId, const std::string &bunleName); 42 virtual void Clean(int32_t userId); 43 virtual void ReleaseUserInfo(int32_t userId); 44 virtual void Bind(std::shared_ptr<ExecutorPool> executor); 45 virtual bool IsSupportCloud(int32_t userId); 46 47 private: 48 static CloudServer *instance_; 49 }; 50 } // namespace OHOS::DistributedData 51 #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_SERVER_H