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 COMPOSE_RULE_H 16 #define COMPOSE_RULE_H 17 #include <list> 18 #include <map> 19 #include <string> 20 #include <vector> 21 22 #include <json/json.h> 23 namespace OHOS { 24 namespace HiviewDFX { 25 class ComposeRule { 26 public: 27 void ParseComposeRule(const std::string& config, const std::string& type, 28 std::vector<std::string> featureIds); 29 const std::list<std::pair<std::string, std::map<std::string, std::string>>>& GetComposeRule() const; 30 31 private: 32 void ParseRule(const Json::Value& jsonRoot, const std::string& type, std::vector<std::string>& featureIds); 33 static bool ComparePrio(const std::string& featureIdOne, const std::string& featureIdTwo); 34 std::map<std::string, std::string> GetMapFromJson(const Json::Value& json, const std::string& featureId); 35 36 private: 37 std::list<std::pair<std::string, std::map<std::string, std::string>>> composeRules_; 38 }; 39 } // namespace HiviewDFX 40 } // namespace OHOS 41 #endif /* COMPOSE_RULE_H */ 42