matcher_util.h revision 931945399859ab91545ba2c2a914f044092d5e2e
1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef MATCHER_UTIL_H 18#define MATCHER_UTIL_H 19 20#include <log/log_read.h> 21#include <log/logprint.h> 22#include <set> 23#include <unordered_map> 24#include <vector> 25#include "frameworks/base/cmds/statsd/src/stats_log.pb.h" 26#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" 27 28namespace android { 29namespace os { 30namespace statsd { 31 32typedef struct { 33 int tagId; 34 long timestamp_ns; 35 std::unordered_map<int, long> intMap; 36 std::unordered_map<int, std::string> strMap; 37 std::unordered_map<int, bool> boolMap; 38 std::unordered_map<int, float> floatMap; 39} LogEventWrapper; 40 41enum MatchingState { 42 kNotComputed = -1, 43 kNotMatched = 0, 44 kMatched = 1, 45}; 46 47LogEventWrapper parseLogEvent(log_msg msg); 48 49bool combinationMatch(const std::vector<int>& children, const LogicalOperation& operation, 50 const std::vector<MatchingState>& matcherResults); 51 52bool matchesSimple(const SimpleLogEntryMatcher& simpleMatcher, const LogEventWrapper& wrapper); 53 54} // namespace statsd 55} // namespace os 56} // namespace android 57#endif // MATCHER_UTIL_H 58