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#include "rule.h" 16 17#include "compose_rule.h" 18#include "extract_rule.h" 19 20using namespace std; 21namespace OHOS { 22namespace HiviewDFX { 23namespace { 24 const std::string COMPOSE_CONFIG = "compose_rule.json"; 25 const std::string EXTRACT_CONFIG = "extract_rule.json"; 26} 27 std::map<std::string, FeatureSet> extractRule_; 28 std::list<std::pair<std::string, std::map<std::string, std::string>>> composeRule_; 29 std::map<std::string, std::vector<std::string>> segStatusCfg_; 30 31void Rule::ParseRule() 32{ 33 ExtractRule extractRule; 34 ComposeRule composeRule; 35 std::string extractConfig = analysisConfig_ + "/" + EXTRACT_CONFIG; 36 extractRule.ParseExtractRule(eventType_, extractConfig, eventPath_); 37 extractRule_ = extractRule.GetExtractRule(); 38 segStatusCfg_ = extractRule.GetSegStatusCfg(); 39 std::string composeConfig = analysisConfig_ + "/" + COMPOSE_CONFIG; 40 composeRule.ParseComposeRule(composeConfig, eventType_, extractRule.GetFeatureId()); 41 composeRule_ = composeRule.GetComposeRule(); 42} 43 44std::map<std::string, FeatureSet> Rule::GetExtractRule() 45{ 46 return extractRule_; 47} 48 49std::list<std::pair<std::string, std::map<std::string, std::string>>> Rule::GetComposeRule() 50{ 51 return composeRule_; 52} 53 54std::map<std::string, std::vector<std::string>> Rule::GetSegStatusCfg() 55{ 56 return segStatusCfg_; 57} 58} // namespace HiviewDFX 59} // namespace OHOS