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 24 ConditionState ConditionWizard::query(const int index, const ConditionKey& parameters, 25 const bool isPartialLink) { 26 vector<ConditionState> cache(mAllConditions.size(), ConditionState::kNotEvaluated); 27 28 mAllConditions[index]->isConditionMet( 29 parameters, mAllConditions, isPartialLink, 30 cache); 31 return cache[index]; 32 } 33 34 const set<HashableDimensionKey>* ConditionWizard::getChangedToTrueDimensions( 35 const int index) const { 36 return mAllConditions[index]->getChangedToTrueDimensions(mAllConditions); 37 } 38 39 const set<HashableDimensionKey>* ConditionWizard::getChangedToFalseDimensions( 40 const int index) const { 41 return mAllConditions[index]->getChangedToFalseDimensions(mAllConditions); 42 } 43 44 bool ConditionWizard::IsChangedDimensionTrackable(const int index) { 45 if (index >= 0 && index < (int)mAllConditions.size()) { 46 return mAllConditions[index]->IsChangedDimensionTrackable(); 47 } else { 48 return false; 49 } 50 } 51 52 bool ConditionWizard::IsSimpleCondition(const int index) { 53 if (index >= 0 && index < (int)mAllConditions.size()) { 54 return mAllConditions[index]->IsSimpleCondition(); 55 } else { 56 return false; 57 } 58 } 59 60 bool ConditionWizard::equalOutputDimensions(const int index, const vector<Matcher>& dimensions) { 61 if (index >= 0 && index < (int)mAllConditions.size()) { 62 return mAllConditions[index]->equalOutputDimensions(mAllConditions, dimensions); 63 } else { 64 return false; 65 } 66 } 67 68 } // namespace statsd 69 } // namespace os 70 } // namespace android 71