/* * Copyright (C) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TRACE_JSON_PARSER_H #define TRACE_JSON_PARSER_H #include #include #include #include "hitrace_define.h" #include "nocopyable.h" namespace OHOS { namespace HiviewDFX { namespace Hitrace { enum TraceType { USER = 0, KERNEL }; struct TraceTag { std::string description; uint64_t tag; TraceType type; std::vector enablePath; std::vector formatPath; }; class TraceJsonParser { public: static TraceJsonParser& Instance(); const std::map& GetAllTagInfos() const { return traceTagInfos_; } const std::map>& GetTagGroups() const { return tagGroups_; } const std::vector& GetBaseFmtPath() const { return baseTraceFormats_; } const AgeingParam& GetAgeingParam(TraceDumpType type) const; int GetSnapshotDefaultBufferSizeKb() const { return snapshotBufSzKb_; } private: std::map traceTagInfos_ = {}; std::map> tagGroups_ = {}; std::vector baseTraceFormats_ = {}; int snapshotBufSzKb_ = 0; AgeingParam snapShotAgeingParam_ = {}; AgeingParam recordAgeingParam_ = {}; TraceJsonParser(const std::string& hitraceUtilsJson, const std::string& productConfigJson); void InitSnapshotDefaultBufferSize(); void InitAgeingParam(); void ParseHitraceUtilsJson(const std::string& hitraceUtilsJson); void ParseProductConfigJson(const std::string& productConfigJson); void PrintParseResult(); ~TraceJsonParser() = default; DISALLOW_COPY_AND_MOVE(TraceJsonParser); }; } // namespace Hitrace } // namespace HiviewDFX } // namespace OHOS #endif // TRACE_JSON_PARSER_H