• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     (void)traceDataCache_->GetDataTypeData()->UpdateNewDataType(BASE_DATA_TYPE_INT,
26                                                                 traceDataCache_->GetDataIndex("int32_t"));
27     (void)traceDataCache_->GetDataTypeData()->UpdateNewDataType(BASE_DATA_TYPE_STRING,
28                                                                 traceDataCache_->GetDataIndex("string"));
29     (void)traceDataCache_->GetDataTypeData()->UpdateNewDataType(BASE_DATA_TYPE_DOUBLE,
30                                                                 traceDataCache_->GetDataIndex("double"));
31     (void)traceDataCache_->GetDataTypeData()->UpdateNewDataType(BASE_DATA_TYPE_BOOLEAN,
32                                                                 traceDataCache_->GetDataIndex("boolean"));
33 }
34 
~ArgsFilter()35 ArgsFilter::~ArgsFilter() {}
36 
NewArgs(const ArgsSet & args)37 uint32_t ArgsFilter::NewArgs(const ArgsSet& args)
38 {
39     auto argSet = traceDataCache_->GetArgSetData();
40     for (auto it = args.valuesMap_.begin(); it != args.valuesMap_.end(); it++) {
41         (void)argSet->AppendNewArg(it->first, it->second.type, it->second.value, count_);
42     }
43     count_++;
44     return count_ - 1;
45 }
AppendArgs(const ArgsSet & args,const size_t argSetId)46 uint32_t ArgsFilter::AppendArgs(const ArgsSet& args, const size_t argSetId)
47 {
48     auto argSet = traceDataCache_->GetArgSetData();
49     for (auto it = args.valuesMap_.begin(); it != args.valuesMap_.end(); it++) {
50         (void)argSet->AppendNewArg(it->first, it->second.type, it->second.value, argSetId);
51     }
52     return count_ - 1;
53 }
54 } // namespace TraceStreamer
55 } // namespace SysTuning
56