• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 using namespace std;
21 namespace OHOS {
22 namespace HiviewDFX {
23 namespace {
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 
ParseRule()31 void 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 
GetExtractRule()44 std::map<std::string, FeatureSet> Rule::GetExtractRule()
45 {
46     return extractRule_;
47 }
48 
GetComposeRule()49 std::list<std::pair<std::string, std::map<std::string, std::string>>> Rule::GetComposeRule()
50 {
51     return composeRule_;
52 }
53 
GetSegStatusCfg()54 std::map<std::string, std::vector<std::string>> Rule::GetSegStatusCfg()
55 {
56     return segStatusCfg_;
57 }
58 } // namespace HiviewDFX
59 } // namespace OHOS