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 #include "resource_manager_napi_context.h"
16 
17 #include "resource_manager_napi_sync_impl.h"
18 #include "resource_manager_napi_async_impl.h"
19 namespace OHOS {
20 namespace Global {
21 namespace Resource {
ResourceManagerNapiContext()22 ResourceManagerNapiContext::ResourceManagerNapiContext()
23 {}
24 
~ResourceManagerNapiContext()25 ResourceManagerNapiContext::~ResourceManagerNapiContext()
26 {}
27 
ContextGetResource(napi_env env,napi_callback_info info,const std::string & methodName,FunctionType functionType)28 napi_value ResourceManagerNapiContext::ContextGetResource(napi_env env, napi_callback_info info,
29     const std::string &methodName, FunctionType functionType)
30 {
31     std::shared_ptr<ResourceManagerNapiBase> napiBase;
32     if (functionType == FunctionType::SYNC) {
33         napiBase = std::make_shared<ResourceManagerNapiSyncImpl>();
34     } else {
35         napiBase = std::make_shared<ResourceManagerNapiAsyncImpl>();
36     }
37     return napiBase->GetResource(env, info, methodName);
38 }
39 } // namespace Resource
40 } // namespace Global
41 } // namespace OHOS