• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "args_filter.h"
17 #include "filter_filter.h"
18 #include "ts_common.h"
19 
20 namespace SysTuning {
21 namespace TraceStreamer {
ArgsFilter(TraceDataCache * dataCache,const TraceStreamerFilters * filter)22 ArgsFilter::ArgsFilter(TraceDataCache *dataCache, const TraceStreamerFilters *filter) : FilterBase(dataCache, filter)
23 {
24     (void)traceDataCache_->GetDataTypeData()->UpdateNewDataType(BASE_DATA_TYPE_INT,
25                                                                 traceDataCache_->GetDataIndex("int32_t"));
26     (void)traceDataCache_->GetDataTypeData()->UpdateNewDataType(BASE_DATA_TYPE_STRING,
27                                                                 traceDataCache_->GetDataIndex("string"));
28     (void)traceDataCache_->GetDataTypeData()->UpdateNewDataType(BASE_DATA_TYPE_DOUBLE,
29                                                                 traceDataCache_->GetDataIndex("double"));
30     (void)traceDataCache_->GetDataTypeData()->UpdateNewDataType(BASE_DATA_TYPE_BOOLEAN,
31                                                                 traceDataCache_->GetDataIndex("boolean"));
32 }
33 
~ArgsFilter()34 ArgsFilter::~ArgsFilter() {}
35 
NewArgs(const ArgsSet & args)36 uint32_t ArgsFilter::NewArgs(const ArgsSet &args)
37 {
38     auto argSet = traceDataCache_->GetArgSetData();
39     for (auto it = args.valuesMap_.begin(); it != args.valuesMap_.end(); it++) {
40         (void)argSet->AppendNewArg(it->first, it->second.type, it->second.value, count_);
41     }
42     count_++;
43     return count_ - 1;
44 }
AppendArgs(const ArgsSet & args,const size_t argSetId)45 uint32_t ArgsFilter::AppendArgs(const ArgsSet &args, const size_t argSetId)
46 {
47     auto argSet = traceDataCache_->GetArgSetData();
48     for (auto it = args.valuesMap_.begin(); it != args.valuesMap_.end(); it++) {
49         (void)argSet->AppendNewArg(it->first, it->second.type, it->second.value, argSetId);
50     }
51     return count_ - 1;
52 }
53 } // namespace TraceStreamer
54 } // namespace SysTuning
55