• 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 
16 #ifndef HI_SYS_EVENT_MEASURE_FILTER_H
17 #define HI_SYS_EVENT_MEASURE_FILTER_H
18 
19 #include <map>
20 #include <string_view>
21 #include <tuple>
22 
23 #include "double_map.h"
24 #include "filter_base.h"
25 #include "trace_data_cache.h"
26 #include "trace_streamer_filters.h"
27 #include "triple_map.h"
28 
29 namespace SysTuning {
30 namespace TraceStreamer {
31 class HiSysEventMeasureFilter : private FilterBase {
32 public:
33     HiSysEventMeasureFilter(TraceDataCache* dataCache, const TraceStreamerFilters* filter);
34     HiSysEventMeasureFilter(const HiSysEventMeasureFilter&) = delete;
35     HiSysEventMeasureFilter& operator=(const HiSysEventMeasureFilter&) = delete;
36     ~HiSysEventMeasureFilter() override;
37     DataIndex GetOrCreateFilterId(DataIndex eventSource);
38     DataIndex GetOrCreateFilterId(DataIndex eventSource, DataIndex appName);
39     std::tuple<DataIndex, DataIndex> GetOrCreateFilterId(DataIndex eventSource, DataIndex appName, DataIndex key);
40     DataIndex AppendNewValue(uint64_t serial,
41                              uint64_t timestamp,
42                              DataIndex appNameId,
43                              DataIndex key,
44                              int32_t type,
45                              double numericValue,
46                              DataIndex strValue);
47     void AppendNewValue(int32_t brightnessState,
48                         int32_t btState,
49                         int32_t locationState,
50                         int32_t wifiState,
51                         int32_t streamDefault,
52                         int32_t voiceCall,
53                         int32_t music,
54                         int32_t streamRing,
55                         int32_t media,
56                         int32_t voiceAssistant,
57                         int32_t system,
58                         int32_t alarm,
59                         int32_t notification,
60                         int32_t bluetoolthSco,
61                         int32_t enforcedAudible,
62                         int32_t streamDtmf,
63                         int32_t streamTts,
64                         int32_t accessibility,
65                         int32_t recording,
66                         int32_t streamAll);
67     void Clear();
68 
69 private:
70     DataIndex GetOrCreateFilterIdInternal(DataIndex appNameId, DataIndex key);
71     DoubleMap<DataIndex, DataIndex, DataIndex> appKey_;
72     DoubleMap<DataIndex, DataIndex, DataIndex> appName_;
73     std::map<DataIndex, DataIndex> eventSource_;
74 };
75 } // namespace TraceStreamer
76 } // namespace SysTuning
77 #endif // HI_SYS_EVENT_MEASURE_FILTER_H
78