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 #include "ConditionWizard.h"
17
18 namespace android {
19 namespace os {
20 namespace statsd {
21
22 using std::vector;
23
query(const int index,const ConditionKey & parameters,const vector<Matcher> & dimensionFields,const bool isSubOutputDimensionFields,const bool isPartialLink,std::unordered_set<HashableDimensionKey> * dimensionKeySet)24 ConditionState ConditionWizard::query(const int index, const ConditionKey& parameters,
25 const vector<Matcher>& dimensionFields,
26 const bool isSubOutputDimensionFields,
27 const bool isPartialLink,
28 std::unordered_set<HashableDimensionKey>* dimensionKeySet) {
29 vector<ConditionState> cache(mAllConditions.size(), ConditionState::kNotEvaluated);
30
31 mAllConditions[index]->isConditionMet(
32 parameters, mAllConditions, dimensionFields, isSubOutputDimensionFields, isPartialLink,
33 cache, *dimensionKeySet);
34 return cache[index];
35 }
36
getMetConditionDimension(const int index,const vector<Matcher> & dimensionFields,const bool isSubOutputDimensionFields,std::unordered_set<HashableDimensionKey> * dimensionsKeySet) const37 ConditionState ConditionWizard::getMetConditionDimension(
38 const int index, const vector<Matcher>& dimensionFields,
39 const bool isSubOutputDimensionFields,
40 std::unordered_set<HashableDimensionKey>* dimensionsKeySet) const {
41 return mAllConditions[index]->getMetConditionDimension(mAllConditions, dimensionFields,
42 isSubOutputDimensionFields,
43 *dimensionsKeySet);
44 }
45
getChangedToTrueDimensions(const int index) const46 const set<HashableDimensionKey>* ConditionWizard::getChangedToTrueDimensions(
47 const int index) const {
48 return mAllConditions[index]->getChangedToTrueDimensions(mAllConditions);
49 }
50
getChangedToFalseDimensions(const int index) const51 const set<HashableDimensionKey>* ConditionWizard::getChangedToFalseDimensions(
52 const int index) const {
53 return mAllConditions[index]->getChangedToFalseDimensions(mAllConditions);
54 }
55
IsChangedDimensionTrackable(const int index)56 bool ConditionWizard::IsChangedDimensionTrackable(const int index) {
57 if (index >= 0 && index < (int)mAllConditions.size()) {
58 return mAllConditions[index]->IsChangedDimensionTrackable();
59 } else {
60 return false;
61 }
62 }
63
IsSimpleCondition(const int index)64 bool ConditionWizard::IsSimpleCondition(const int index) {
65 if (index >= 0 && index < (int)mAllConditions.size()) {
66 return mAllConditions[index]->IsSimpleCondition();
67 } else {
68 return false;
69 }
70 }
71
equalOutputDimensions(const int index,const vector<Matcher> & dimensions)72 bool ConditionWizard::equalOutputDimensions(const int index, const vector<Matcher>& dimensions) {
73 if (index >= 0 && index < (int)mAllConditions.size()) {
74 return mAllConditions[index]->equalOutputDimensions(mAllConditions, dimensions);
75 } else {
76 return false;
77 }
78 }
79
80 } // namespace statsd
81 } // namespace os
82 } // namespace android