1 /*
2  * Copyright (c) 2020 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_ACELITE_DIRECTIVE_WATCHER_CALLBACK_H
17 #define OHOS_ACELITE_DIRECTIVE_WATCHER_CALLBACK_H
18 
19 #include "directive/descriptor_utils.h"
20 #include "non_copyable.h"
21 #include "wrapper/js.h"
22 
23 namespace OHOS {
24 namespace ACELite {
25 class DirectiveWatcherCallback final : public MemoryHeap {
26 public:
27     ACE_DISALLOW_COPY_AND_MOVE(DirectiveWatcherCallback);
28 
29     /**
30      * @brief Destructor.
31      */
~DirectiveWatcherCallback()32     ~DirectiveWatcherCallback() {}
33 
34     /**
35      * @brief The watcher callback function which will be trigger when the directive condition was changed.
36      * @param func The watcher callback function.
37      * @param context The execute context of watcher callback.
38      * @param args The arguments of watcher callback function.
39      * @param argsSize the arguments size of watcher callback function.
40      * @return The return value when the watcher callback was executed.
41      */
42     static JSValue Handler(const JSValue func, const JSValue context, const JSValue args[], const JSSize argsSize);
43 
44 private:
45     /**
46      * @brief The arguments size of watcher callback function.
47      */
48     static const int CALLBACK_ARGS_LENGTH;
49 
50     /**
51      * @brief The index of options argument.
52      */
53     static const int ARG_IDX_OPTIONS;
54 };
55 } // namespace ACELite
56 } // namespace OHOS
57 
58 #endif // OHOS_ACELITE_DIRECTIVE_WATCHER_CALLBACK_H
59