• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 HDC_HOST_UNITY_H
16 #define HDC_HOST_UNITY_H
17 #include "host_common.h"
18 
19 namespace Hdc {
20 class HdcHostUnity : public HdcTaskBase {
21 public:
22     HdcHostUnity(HTaskInfo hTaskInfo);
23     virtual ~HdcHostUnity();
24     bool CommandDispatch(const uint16_t command, uint8_t *payload, const int payloadSize);
25     void StopTask();
26     bool ReadyForRelease();
27 
28 private:
29     struct ContextUnity {
30         bool enableLog;
31         uv_file fileLog;
32         uint64_t fileIOIndex;
33         uint64_t fileBufIndex;
34         bool hasFilelogClosed;
35         uv_fs_t fsClose;
36         HdcHostUnity *thisClass;
37     };
38     struct CtxUnityIO {
39         uv_fs_t fs;
40         uint8_t *bufIO;
41         ContextUnity *context;
42     };
43     static void OnFileIO(uv_fs_t *req);
44     static void OnFileClose(uv_fs_t *req);
45     bool InitLocalLog(const char *path);
46     bool AppendLocalLog(const char *bufLog, const int sizeLog);
47 
48     ContextUnity opContext = {};
49 };
50 }  // namespace Hdc
51 #endif  // HDC_HOST_UNITY_H