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 UDMF_UNIFIED_DATA_NAPI_H
17 #define UDMF_UNIFIED_DATA_NAPI_H
18 
19 #include "unified_data_properties_napi.h"
20 #include "visibility.h"
21 namespace OHOS {
22 namespace UDMF {
23 class UnifiedData;
24 class UnifiedRecord;
25 class API_EXPORT UnifiedDataNapi {
26 public:
27     static napi_value Constructor(napi_env env);
28     static napi_status NewInstance(napi_env env, std::shared_ptr<UnifiedData> in, napi_value &out);
29     UnifiedDataPropertiesNapi *GetPropertiesNapi(napi_env env);
30 
31     std::shared_ptr<UnifiedData> value_;
32     napi_ref propertyRef_ = nullptr;
33 
34 private:
35     static napi_value New(napi_env env, napi_callback_info info);
36     static void Destructor(napi_env env, void *data, void *hint);
37     static UnifiedDataNapi *GetUnifiedData(napi_env env, napi_callback_info info);
38 
39     static napi_value AddRecord(napi_env env, napi_callback_info info);
40     static napi_value GetRecords(napi_env env, napi_callback_info info);
41     static void GetRecord(napi_env env, std::shared_ptr<UnifiedRecord> in, napi_value &out);
42 
43     static napi_value GetTypes(napi_env env, napi_callback_info info);
44     static napi_value HasType(napi_env env, napi_callback_info info);
45     static napi_value GetProperties(napi_env env, napi_callback_info info);
46     static napi_value SetProperties(napi_env env, napi_callback_info info);
47     static napi_ref NewWithRef(napi_env env, size_t argc, napi_value *argv, void **out, napi_value constructor);
48     static napi_status Unwrap(napi_env env, napi_value in, void **out, napi_value constructor);
49 };
50 } // namespace UDMF
51 } // namespace OHOS
52 #endif // UDMF_UNIFIED_DATA_NAPI_H
53