Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [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 | #pragma once |
| 18 | |
| 19 | #include <log/logprint.h> |
| 20 | #include <set> |
| 21 | #include <vector> |
| 22 | #include "frameworks/base/cmds/statsd/src/stats_log.pb.h" |
| 23 | #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" |
| 24 | #include "field_util.h" |
| 25 | |
| 26 | namespace android { |
| 27 | namespace os { |
| 28 | namespace statsd { |
| 29 | |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 30 | // Returns the leaf node from the DimensionsValue proto. It assume that the input has only one |
| 31 | // leaf node at most. |
| 32 | const DimensionsValue* getSingleLeafValue(const DimensionsValue* value); |
| 33 | DimensionsValue getSingleLeafValue(const DimensionsValue& value); |
| 34 | |
Yangster-mac | 87718e2 | 2018-01-11 16:16:26 -0800 | [diff] [blame] | 35 | // Appends the leaf node to the parent tree. |
| 36 | void appendLeafNodeToParent(const Field& field, const DimensionsValue& value, |
| 37 | DimensionsValue* parentValue); |
| 38 | |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 39 | // Constructs the DimensionsValue protos from the FieldMatcher. Each DimensionsValue proto |
| 40 | // represents a tree. When the input proto has repeated fields and the input "dimensions" wants |
| 41 | // "ANY" locations, it will return multiple trees. |
| 42 | void findDimensionsValues( |
| 43 | const FieldValueMap& fieldValueMap, |
| 44 | const FieldMatcher& matcher, |
| 45 | std::vector<DimensionsValue>* rootDimensionsValues); |
| 46 | |
| 47 | // Utils to build FieldMatcher proto for simple one-depth atoms. |
| 48 | FieldMatcher buildSimpleAtomFieldMatcher(const int tagId, const int atomFieldNum); |
| 49 | FieldMatcher buildSimpleAtomFieldMatcher(const int tagId); |
| 50 | |
| 51 | // Utils to build FieldMatcher proto for attribution nodes. |
| 52 | FieldMatcher buildAttributionUidFieldMatcher(const int tagId, const Position position); |
| 53 | FieldMatcher buildAttributionTagFieldMatcher(const int tagId, const Position position); |
| 54 | FieldMatcher buildAttributionFieldMatcher(const int tagId, const Position position); |
| 55 | |
| 56 | // Utils to print pretty string for DimensionsValue proto. |
| 57 | std::string DimensionsValueToString(const DimensionsValue& value); |
| 58 | void DimensionsValueToString(const DimensionsValue& value, std::string *flattened); |
| 59 | |
| 60 | bool IsSubDimension(const DimensionsValue& dimension, const DimensionsValue& sub); |
| 61 | |
Yangster-mac | a7fb12d | 2018-01-03 17:17:20 -0800 | [diff] [blame] | 62 | // Helper function to get long value from the DimensionsValue proto. |
| 63 | long getLongFromDimenValue(const DimensionsValue& dimensionValue); |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 64 | } // namespace statsd |
| 65 | } // namespace os |
| 66 | } // namespace android |