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 TRACE_STREAMER_SELECTOR_H 17 #define TRACE_STREAMER_SELECTOR_H 18 #include <functional> 19 #include <memory> 20 #include "sdk/sdk_data_parser.h" 21 #include "trace_data/trace_data_cache.h" 22 23 namespace SysTuning { 24 namespace TraceStreamer { 25 class SDKDataParser; 26 enum TraceFileType { TRACE_FILETYPE_UN_KNOW }; 27 class TraceStreamerSelector { 28 public: 29 TraceStreamerSelector(); 30 ~TraceStreamerSelector(); 31 static bool ParseTraceDataSegment(std::unique_ptr<uint8_t[]> data, size_t size); 32 void EnableMetaTable(bool enabled); 33 static void SetCleanMode(bool cleanMode); 34 int32_t ExportDatabase(const std::string &outputName) const; 35 int32_t SearchData(); 36 int32_t OperateDatabase(const std::string &sql); 37 int32_t SearchDatabase(const std::string &sql, DemoTraceDataDB::ResultCallBack resultCallBack); 38 int32_t SearchDatabase(const std::string &sql, uint8_t *out, int32_t outLen); 39 MetaData *GetMetaData(); 40 static void WaitForParserEnd(); 41 void Clear(); 42 void SetDataType(TraceFileType type); 43 void SetCancel(bool cancel); 44 std::unique_ptr<SDKDataParser> sdkDataParser_ = {}; 45 46 private: 47 void InitFilter(); 48 std::unique_ptr<TraceDataCache> traceDataCache_ = {}; 49 }; 50 } // namespace TraceStreamer 51 } // namespace SysTuning 52 53 #endif // TRACE_STREAMER_SELECTOR_H 54