1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
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 "log.h"
19 #include "ts_common.h"
20
21 namespace SysTuning {
22 namespace TraceStreamer {
ArgsFilter(TraceDataCache * dataCache,const TraceStreamerFilters * filter)23 ArgsFilter::ArgsFilter(TraceDataCache* dataCache, const TraceStreamerFilters* filter) : FilterBase(dataCache, filter)
24 {
25 traceDataCache_->GetDataTypeData()->AppendNewDataType(BASE_DATA_TYPE_INT, traceDataCache_->GetDataIndex("int"));
26 traceDataCache_->GetDataTypeData()->AppendNewDataType(BASE_DATA_TYPE_STRING,
27 traceDataCache_->GetDataIndex("string"));
28 traceDataCache_->GetDataTypeData()->AppendNewDataType(BASE_DATA_TYPE_DOUBLE,
29 traceDataCache_->GetDataIndex("double"));
30 traceDataCache_->GetDataTypeData()->AppendNewDataType(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 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 argSet->AppendNewArg(it->first, it->second.type, it->second.value, argSetId);
50 }
51 return count_ - 1;
52 }
53 } // namespace TraceStreamer
54 } // namespace SysTuning
55