1 /*
2 * Copyright (c) Huawei Technologies Co., Ltd. 2024. 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 "xpower_app_detaile_wifi_table.h"
17
18 namespace SysTuning {
19 namespace TraceStreamer {
20 enum class Index : int32_t { ID = 0, START_TIME, TX_PACKETS, RX_PACKETS, TX_BYTES, RX_BYTES };
XpowerAppDetaileWifiTable(const TraceDataCache * dataCache)21 XpowerAppDetaileWifiTable::XpowerAppDetaileWifiTable(const TraceDataCache *dataCache) : TableBase(dataCache)
22 {
23 tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER"));
24 tableColumn_.push_back(TableBase::ColumnInfo("start_time", "INTEGER"));
25 tableColumn_.push_back(TableBase::ColumnInfo("tx_packets", "INTEGER"));
26 tableColumn_.push_back(TableBase::ColumnInfo("rx_packets", "INTEGER"));
27 tableColumn_.push_back(TableBase::ColumnInfo("tx_bytes", "INTEGER"));
28 tableColumn_.push_back(TableBase::ColumnInfo("rx_bytes", "INTEGER"));
29 tablePriKey_.push_back("id");
30 }
31
~XpowerAppDetaileWifiTable()32 XpowerAppDetaileWifiTable::~XpowerAppDetaileWifiTable() {}
33
CreateCursor()34 std::unique_ptr<TableBase::Cursor> XpowerAppDetaileWifiTable::CreateCursor()
35 {
36 return std::make_unique<Cursor>(dataCache_, this);
37 }
38
Cursor(const TraceDataCache * dataCache,TableBase * table)39 XpowerAppDetaileWifiTable::Cursor::Cursor(const TraceDataCache *dataCache, TableBase *table)
40 : TableBase::Cursor(dataCache, table, static_cast<uint32_t>(dataCache->GetConstXPowerAppDetailWifiInfo().Size())),
41 xPowerAppDetailWifiObj_(dataCache->GetConstXPowerAppDetailWifiInfo())
42 {
43 }
44
~Cursor()45 XpowerAppDetaileWifiTable::Cursor::~Cursor() {}
Column(int32_t column) const46 int32_t XpowerAppDetaileWifiTable::Cursor::Column(int32_t column) const
47 {
48 switch (static_cast<Index>(column)) {
49 case Index::ID:
50 sqlite3_result_int64(context_, xPowerAppDetailWifiObj_.IdsData()[CurrentRow()]);
51 break;
52 case Index::START_TIME:
53 sqlite3_result_int64(context_, xPowerAppDetailWifiObj_.TimeStampData()[CurrentRow()]);
54 break;
55 case Index::TX_PACKETS:
56 SetTypeColumnInt64(xPowerAppDetailWifiObj_.TxPacketsData()[CurrentRow()], INVALID_INT64);
57 break;
58 case Index::RX_PACKETS:
59 SetTypeColumnInt64(xPowerAppDetailWifiObj_.RxPacketsData()[CurrentRow()], INVALID_INT64);
60 break;
61 case Index::TX_BYTES:
62 SetTypeColumnInt64(xPowerAppDetailWifiObj_.TxBytesData()[CurrentRow()], INVALID_INT64);
63 break;
64 case Index::RX_BYTES:
65 SetTypeColumnInt64(xPowerAppDetailWifiObj_.RxBytesData()[CurrentRow()], INVALID_INT64);
66 break;
67 default:
68 TS_LOGF("Unregistered column : %d", column);
69 }
70 return SQLITE_OK;
71 }
72 } // namespace TraceStreamer
73 } // namespace SysTuning
74