| Flutter Impeller |

archive_database.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_ARCHIVIST_ARCHIVE_DATABASE_H_
6 #define FLUTTER_IMPELLER_ARCHIVIST_ARCHIVE_DATABASE_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11
12 #include "impeller/archivist/archive_transaction.h"
13
14 namespace impeller {
15
16 class ArchiveStatement;
17 class ArchiveClassRegistration;
18 struct ArchiveDef;
19
20 //------------------------------------------------------------------------------
21 /// @brief A handle to the underlying database connection for an archive.
22 ///
23 class ArchiveDatabase {
24 public:
25 explicit ArchiveDatabase(const std::string& filename);
26
27 ~ArchiveDatabase();
28
29 bool IsValid() const;
30
31 int64_t GetLastInsertRowID();
32
33 const ArchiveClassRegistration* GetRegistrationForDefinition(
34 const ArchiveDef& definition);
35
36 ArchiveTransaction CreateTransaction(int64_t& transactionCount);
37
38 private:
39 struct Handle;
40 std::unique_ptr<Handle> handle_;
41 std::map<std::string, std::unique_ptr<ArchiveClassRegistration>>
42 registrations_;
43 std::unique_ptr<ArchiveStatement> begin_transaction_stmt_;
44 std::unique_ptr<ArchiveStatement> end_transaction_stmt_;
45 std::unique_ptr<ArchiveStatement> rollback_transaction_stmt_;
46
47 friend class ArchiveClassRegistration;
48
49 ArchiveStatement CreateStatement(const std::string& statementString) const;
50
51 ArchiveDatabase(const ArchiveDatabase&) = delete;
52
53 ArchiveDatabase& operator=(const ArchiveDatabase&) = delete;
54 };
55
56 } // namespace impeller
57
58 #endif // FLUTTER_IMPELLER_ARCHIVIST_ARCHIVE_DATABASE_H_
impeller::ArchiveDatabase::GetLastInsertRowID
int64_t GetLastInsertRowID()
Definition: archive_database.cc:90
impeller::ArchiveDef
Definition: archivable.h:15
impeller::ArchiveDatabase
A handle to the underlying database connection for an archive.
Definition: archive_database.h:23
impeller::ArchiveClassRegistration
Definition: archive_class_registration.h:17
impeller::ArchiveDatabase::ArchiveDatabase
ArchiveDatabase(const std::string &filename)
Definition: archive_database.cc:55
impeller::ArchiveDatabase::Handle
Definition: archive_database.cc:19
impeller::ArchiveStatement
Represents a read/write query to an archive database. Statements are expensive to create and must be ...
Definition: archive_statement.h:20
impeller::ArchiveDatabase::GetRegistrationForDefinition
const ArchiveClassRegistration * GetRegistrationForDefinition(const ArchiveDef &definition)
Definition: archive_database.cc:105
archive_transaction.h
impeller::ArchiveTransaction
All writes made to the archive within a transaction that is not marked as ready for commit will be ro...
Definition: archive_transaction.h:22
impeller::ArchiveDatabase::IsValid
bool IsValid() const
Definition: archive_database.cc:86
impeller::ArchiveDatabase::~ArchiveDatabase
~ArchiveDatabase()
impeller
Definition: aiks_context.cc:10
impeller::ArchiveDatabase::CreateTransaction
ArchiveTransaction CreateTransaction(int64_t &transactionCount)
Definition: archive_database.cc:135