ICursor.h
1/* Copyright (C) 2006-2026 by Tommi Maekitalo
2 Copyright (C) 2006-2026 by Marc Boris Duerner
3 SPDX-License-Identifier: LGPL-2.1-or-later WITH mif-exception
4*/
5
6#ifndef PT_DB_ICURSOR_H
7#define PT_DB_ICURSOR_H
8
9#include <Pt/Db/Api.h>
10#include <Pt/Db/Result.h>
11#include <Pt/RefCounted.h>
12#include <Pt/Signal.h>
13#include <cstddef>
14
15namespace Pt {
16
17namespace Db {
18
19class Row;
20class IConnection;
21
22
25class PT_DB_API ICursor : public RefCounted
26{
27 friend class IConnection;
28
29 public:
30 typedef std::size_t size_type;
31
35 { return _fetched; }
36
39 bool isOpen() const
40 { return _open; }
41
44 IConnection* connection()
45 { return _conn; }
46
47 protected:
48 explicit ICursor(IConnection* conn)
49 : _conn(conn)
50 , _open(false)
51 {}
52
53 virtual Result onFetchBatch(size_type batchSize) = 0;
54
55 virtual void onBeginBatchFetch(size_type batchSize) = 0;
56 virtual Result onEndBatchFetch() = 0;
57 virtual void onClose() = 0;
58
59 Signal<> _fetched;
60 IConnection* _conn;
61 bool _open;
62};
63
64} // namespace Db
65
66} // namespace Pt
67
68#endif // PT_DB_ICURSOR_H
Database connection backend.
Definition IConnection.h:44
Batch-cursor backend.
Definition ICursor.h:26
bool isOpen() const
Returns true if the cursor is open.
Definition ICursor.h:39
Signal & fetchFinished()
Signal emitted when an asynchronous batch is ready.
Definition ICursor.h:34
IConnection * connection()
Returns the connection that owns this cursor.
Definition ICursor.h:44
One row of a buffered query result.
Definition Row.h:34
Multicast Signal to call multiple slots.
Definition Signal.h:190
Portable SQL database access.
Core module.
Definition Allocator.h:33