Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 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 COMBINATION_CONDITION_TRACKER_H |
| 18 | #define COMBINATION_CONDITION_TRACKER_H |
| 19 | |
| 20 | #include "ConditionTracker.h" |
| 21 | #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" |
| 22 | |
| 23 | namespace android { |
| 24 | namespace os { |
| 25 | namespace statsd { |
| 26 | |
| 27 | class CombinationConditionTracker : public virtual ConditionTracker { |
| 28 | public: |
| 29 | CombinationConditionTracker(const std::string& name, const int index); |
| 30 | |
| 31 | ~CombinationConditionTracker(); |
| 32 | |
Stefan Lafon | 12d01fa | 2017-12-04 20:56:09 -0800 | [diff] [blame] | 33 | bool init(const std::vector<Predicate>& allConditionConfig, |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 34 | const std::vector<sp<ConditionTracker>>& allConditionTrackers, |
| 35 | const std::unordered_map<std::string, int>& conditionNameIndexMap, |
| 36 | std::vector<bool>& stack) override; |
| 37 | |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 38 | void evaluateCondition(const LogEvent& event, |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 39 | const std::vector<MatchingState>& eventMatcherValues, |
| 40 | const std::vector<sp<ConditionTracker>>& mAllConditions, |
| 41 | std::vector<ConditionState>& conditionCache, |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 42 | std::vector<bool>& changedCache) override; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 43 | |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 44 | void isConditionMet(const ConditionKey& conditionParameters, |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 45 | const std::vector<sp<ConditionTracker>>& allConditions, |
Yangster | 7c334a1 | 2017-11-22 14:24:24 -0800 | [diff] [blame] | 46 | std::vector<ConditionState>& conditionCache) const override; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 47 | |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 48 | private: |
| 49 | LogicalOperation mLogicalOperation; |
Stefan Lafon | 12d01fa | 2017-12-04 20:56:09 -0800 | [diff] [blame] | 50 | // Store index of the children Predicates. |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 51 | // We don't store string name of the Children, because we want to get rid of the hash map to |
| 52 | // map the name to object. We don't want to store smart pointers to children, because it |
| 53 | // increases the risk of circular dependency and memory leak. |
| 54 | std::vector<int> mChildren; |
| 55 | }; |
| 56 | |
| 57 | } // namespace statsd |
| 58 | } // namespace os |
| 59 | } // namespace android |
| 60 | |
| 61 | #endif // COMBINATION_CONDITION_TRACKER_H |