• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_cpu_table.h"
17 
18 namespace SysTuning {
19 namespace TraceStreamer {
20 enum class Index : int32_t { ID = 0, THREAD_NAME_ID, START_TIME, THREAD_TIME, THREAD_LOADS, THREAD_ENERGY };
XpowerAppDetaileCpuTable(const TraceDataCache * dataCache)21 XpowerAppDetaileCpuTable::XpowerAppDetaileCpuTable(const TraceDataCache *dataCache) : TableBase(dataCache)
22 {
23     tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER"));
24     tableColumn_.push_back(TableBase::ColumnInfo("thread_name_id", "INTEGER"));
25     tableColumn_.push_back(TableBase::ColumnInfo("start_time", "INTEGER"));
26     tableColumn_.push_back(TableBase::ColumnInfo("thread_time", "INTEGER"));
27     tableColumn_.push_back(TableBase::ColumnInfo("thread_loads", "INTEGER"));
28     tableColumn_.push_back(TableBase::ColumnInfo("thread_energy", "INTEGER"));
29     tablePriKey_.push_back("id");
30 }
31 
~XpowerAppDetaileCpuTable()32 XpowerAppDetaileCpuTable::~XpowerAppDetaileCpuTable() {}
33 
CreateCursor()34 std::unique_ptr<TableBase::Cursor> XpowerAppDetaileCpuTable::CreateCursor()
35 {
36     return std::make_unique<Cursor>(dataCache_, this);
37 }
38 
Cursor(const TraceDataCache * dataCache,TableBase * table)39 XpowerAppDetaileCpuTable::Cursor::Cursor(const TraceDataCache *dataCache, TableBase *table)
40     : TableBase::Cursor(dataCache, table, static_cast<uint32_t>(dataCache->GetConstXPowerAppDetailCPUInfo().Size())),
41       xPowerAppDetailCPUObj_(dataCache->GetConstXPowerAppDetailCPUInfo())
42 {
43 }
44 
~Cursor()45 XpowerAppDetaileCpuTable::Cursor::~Cursor() {}
Column(int32_t column) const46 int32_t XpowerAppDetaileCpuTable::Cursor::Column(int32_t column) const
47 {
48     switch (static_cast<Index>(column)) {
49         case Index::ID:
50             sqlite3_result_int64(context_, xPowerAppDetailCPUObj_.IdsData()[CurrentRow()]);
51             break;
52         case Index::THREAD_NAME_ID:
53             sqlite3_result_int64(context_, xPowerAppDetailCPUObj_.ThreadNamesData()[CurrentRow()]);
54             break;
55         case Index::START_TIME:
56             SetTypeColumnInt64(xPowerAppDetailCPUObj_.TimeStampData()[CurrentRow()], INVALID_INT64);
57             break;
58         case Index::THREAD_TIME:
59             SetTypeColumnInt64(xPowerAppDetailCPUObj_.ThreadTimesData()[CurrentRow()], INVALID_INT64);
60             break;
61         case Index::THREAD_LOADS:
62             SetTypeColumnInt64(xPowerAppDetailCPUObj_.ThreadLoadsData()[CurrentRow()], INVALID_INT64);
63             break;
64         case Index::THREAD_ENERGY:
65             SetTypeColumnInt64(xPowerAppDetailCPUObj_.ThreadEnergysData()[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