1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
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 SQLLITE_PREPAR_CACHE_DATA_H
17 #define SQLLITE_PREPAR_CACHE_DATA_H
18 #include <cstdint>
19 #include <functional>
20 #include <map>
21 #include "sqlite3.h"
22 
23 namespace SysTuning {
24 namespace TraceStreamer {
25 constexpr int32_t SEND_CONTINUE = 0;
26 constexpr int32_t SEND_FINISH = 1;
27 class SqllitePreparCacheData {
28 public:
29     using TLVResultCallBack = std::function<void(const char *data, uint32_t len, uint32_t type, int32_t finish)>;
30     using SphQueryCallBack = std::function<void(sqlite3_stmt *, uint32_t, TLVResultCallBack)>;
31 
32 public:
33     SqllitePreparCacheData();
34     SqllitePreparCacheData(const SqllitePreparCacheData &) = delete;
35     SqllitePreparCacheData &operator=(const SqllitePreparCacheData &) = delete;
36     std::map<uint32_t, SphQueryCallBack> sphQueryFuncMap_;
37     static const uint8_t typeSize_ = sizeof(uint32_t);
38 
39 private:
40     void FillAndSendCpuDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
41     void FillAndSendCpuFreqDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
42     void FillAndSendProcessDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
43     void FillAndSendCpuFreqLimitDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
44     void FillAndSendCpuStateDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
45     void FillAndSendProcessMemDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
46     void FillAndSendProcessSoInitDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
47     void FillAndSendProcessStartupDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
48     void FillAndSendClockDataDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
49     void FillAndSendIrqDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
50     void FillAndSendHiSysEventDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
51     void FillAndSendLogDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
52     void FillAndSendVirtualMemDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
53     void FillAndSendFrameDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
54     void FillAndSendFrameAnimationDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
55     void FillAndSendFrameDynamicDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
56     void FillAndSendTrackerDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
57     void FillAndSendAbilityDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
58     void FillAndSendFrameSpacingDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
59     void FillAndSendEnergyDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
60     void FillAndSendEbpfDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
61     void FillAndSendProcessThreadDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
62     void FillAndSendProcessFuncDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
63     void FillAndSendHiperfDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
64     void FillAndSendHiperfCallChartDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
65     void FillAndSendHiperfCallStackDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
66     void FillAndSendProcessJanksFramesDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
67     void FillAndSendProcessJanksActualDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
68     void FillAndSendProcessInputEventDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
69     void FillAndSendHeapFilesDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
70     void FillAndSendCpuProfilerDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
71     void FillAndSendNativeMemoryNormalProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
72     void FillAndSendNativeMemoryStatisticProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
73     void FillAndSendCpuAbilityDataProto(sqlite3_stmt *stmt, uint32_t type, TLVResultCallBack tLVResultCallBack);
74     void FillSphQueryFuncMapPartOne();
75     void FillSphQueryFuncMapPartTow();
76     void FillSphQueryFuncMapPartThree();
77     void FillSphQueryFuncMapPartFour();
78     void FillSphQueryFuncMapPartFive();
79 };
80 } // namespace TraceStreamer
81 } // namespace SysTuning
82 #endif
83