• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
16 #ifndef ARG_RULES_H
17 #define ARG_RULES_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "rule_type.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 struct QueryArg {
27     long long beginTime;
28     long long endTime;
29     int maxEvents;
30     long long fromSeq;
31     long long toSeq;
32     QueryArg(const long long beginTime = -1, const long long endTime = -1, const int maxEvents = -1,
33         const long long fromSeq = -1, const long long toSeq = -1)
beginTimeQueryArg34         : beginTime(beginTime), endTime(endTime), maxEvents(maxEvents), fromSeq(fromSeq), toSeq(toSeq) {}
QueryArgQueryArg35     QueryArg() {}
36 };
37 
38 class ListenerRule {
39 public:
40     ListenerRule(const std::string& domain, const std::string& eventName,
domain(domain)41         const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD, uint32_t eventType = 0) : domain(domain),
42         eventName(eventName), tag(tag), ruleType(ruleType), eventType(eventType) {}
43     ListenerRule(const std::string& domain, const std::string& eventName,
44         RuleType ruleType = RuleType::WHOLE_WORD) : ListenerRule(domain, eventName, "", ruleType) {}
45     ListenerRule(const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)
46         : ListenerRule("", "", tag, ruleType) {}
47 
48 public:
GetDomain()49     std::string GetDomain() const
50     {
51         return domain;
52     }
GetEventName()53     std::string GetEventName() const
54     {
55         return eventName;
56     }
GetTag()57     std::string GetTag() const
58     {
59         return tag;
60     }
GetRuleType()61     RuleType GetRuleType() const
62     {
63         return ruleType;
64     }
GetEventType()65     uint32_t GetEventType() const
66     {
67         return eventType;
68     }
69 
70 private:
71     std::string domain;
72     std::string eventName;
73     std::string tag;
74     RuleType ruleType;
75     uint32_t eventType;
76 };
77 
78 class QueryRule {
79 public:
80     QueryRule(const std::string& domain, const std::vector<std::string>& eventList,
81         RuleType ruleType = RuleType::WHOLE_WORD, uint32_t eventType = 0, const std::string& cond = "")
domain(domain)82         : domain(domain), eventList(eventList), ruleType(ruleType), eventType(eventType), condition(cond) {}
83 
84 public:
GetDomain()85     std::string GetDomain() const
86     {
87         return domain;
88     }
GetEventList()89     std::vector<std::string> GetEventList() const
90     {
91         return eventList;
92     }
GetRuleType()93     RuleType GetRuleType() const
94     {
95         return ruleType;
96     }
GetEventType()97     uint32_t GetEventType() const
98     {
99         return eventType;
100     }
GetCondition()101     std::string GetCondition() const
102     {
103         return condition;
104     }
105 
106 private:
107     std::string domain;
108     std::vector<std::string> eventList;
109     RuleType ruleType;
110     uint32_t eventType;
111     std::string condition;
112 };
113 } // namespace HiviewDFX
114 } // namespace OHOS
115 
116 #endif // ARG_RULES_H
117 
118