blob: 53dacba7fd8dc3711856c4b3710a988501d777fe [file] [log] [blame]
Primiano Tucci463af6f2018-09-09 15:10:42 +01001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SRC_TRACE_PROCESSOR_COUNTERS_TABLE_H_
18#define SRC_TRACE_PROCESSOR_COUNTERS_TABLE_H_
19
20#include <limits>
21#include <memory>
22
23#include "src/trace_processor/table.h"
24#include "src/trace_processor/trace_storage.h"
25
26namespace perfetto {
27namespace trace_processor {
28
29class CountersTable : public Table {
30 public:
31 enum Column {
32 kTimestamp = 0,
33 kName = 1,
34 kValue = 2,
35 kDuration = 3,
36 kRef = 4,
37 kRefType = 5,
38 };
39
40 static void RegisterTable(sqlite3* db, const TraceStorage* storage);
41
42 CountersTable(const TraceStorage*);
43
44 // Table implementation.
45 std::unique_ptr<Table::Cursor> CreateCursor() override;
46 int BestIndex(const QueryConstraints&, BestIndexInfo*) override;
47
48 private:
49 class Cursor : public Table::Cursor {
50 public:
51 Cursor(const TraceStorage*);
52
53 // Implementation of Table::Cursor.
54 int Filter(const QueryConstraints&, sqlite3_value**) override;
55 int Next() override;
56 int Eof() override;
57 int Column(sqlite3_context*, int N) override;
58
59 private:
60 bool filter_by_cpu_ = false;
61 uint32_t current_cpu_ = 0;
62 size_t index_in_cpu_ = 0;
63 uint32_t filter_cpu_ = 0;
64
65 const TraceStorage* const storage_;
66 };
67
68 const TraceStorage* const storage_;
69};
70} // namespace trace_processor
71} // namespace perfetto
72
73#endif // SRC_TRACE_PROCESSOR_COUNTERS_TABLE_H_