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 "hidump_table.h"
17
18 namespace SysTuning {
19 namespace TraceStreamer {
20 namespace {
21 enum Index { TS = 0, FPS };
22 }
HidumpTable(const TraceDataCache * dataCache)23 HidumpTable::HidumpTable(const TraceDataCache* dataCache) : TableBase(dataCache)
24 {
25 tableColumn_.push_back(TableBase::ColumnInfo("ts", "UNSIGNED BIG INT"));
26 tableColumn_.push_back(TableBase::ColumnInfo("fps", "UNSIGNED INT"));
27 tablePriKey_.push_back("ts");
28 }
29
~HidumpTable()30 HidumpTable::~HidumpTable() {}
31
CreateCursor()32 void HidumpTable::CreateCursor()
33 {
34 cursor_ = std::make_unique<Cursor>(dataCache_);
35 }
36
Cursor(const TraceDataCache * dataCache)37 HidumpTable::Cursor::Cursor(const TraceDataCache* dataCache)
38 : TableBase::Cursor(dataCache, 0, static_cast<uint32_t>(dataCache->GetConstHidumpData().Size())),
39 hidumpObj_(dataCache->GetConstHidumpData())
40 {
41 }
42
~Cursor()43 HidumpTable::Cursor::~Cursor() {}
44
Column(int column) const45 int HidumpTable::Cursor::Column(int column) const
46 {
47 switch (column) {
48 case TS:
49 sqlite3_result_int64(context_, static_cast<int64_t>(hidumpObj_.TimeStamData()[CurrentRow()]));
50 break;
51 case FPS: {
52 sqlite3_result_int64(context_, static_cast<int64_t>(hidumpObj_.Fpss()[CurrentRow()]));
53 break;
54 }
55 default:
56 TS_LOGF("Unregistered column : %d", column);
57 break;
58 }
59 return SQLITE_OK;
60 }
61 } // namespace TraceStreamer
62 } // namespace SysTuning
63