diff options
author | Aaron Seigo <aseigo@kde.org> | 2014-12-15 19:28:05 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2014-12-15 19:28:05 +0100 |
commit | 3dd90236e7927028ff5c98635f8075189c9869c2 (patch) | |
tree | aefb7ce4e698b6c9d6993546d5e437a61d7ce4e3 | |
parent | cb0f5fb769380db5771ff8e0dba8d780cdc92edb (diff) | |
download | sink-3dd90236e7927028ff5c98635f8075189c9869c2.tar.gz sink-3dd90236e7927028ff5c98635f8075189c9869c2.zip |
namespace everything in libs with Akonadi2
-rw-r--r-- | client/main.cpp | 7 | ||||
-rw-r--r-- | client/resourceaccess.cpp | 5 | ||||
-rw-r--r-- | client/resourceaccess.h | 5 | ||||
-rw-r--r-- | common/commands.cpp | 7 | ||||
-rw-r--r-- | common/commands.h | 5 | ||||
-rw-r--r-- | common/console.cpp | 5 | ||||
-rw-r--r-- | common/console.h | 5 | ||||
-rw-r--r-- | common/storage.h | 5 | ||||
-rw-r--r-- | common/storage_common.cpp | 4 | ||||
-rw-r--r-- | common/storage_lmdb.cpp | 5 | ||||
-rw-r--r-- | common/storage_unqlite.cpp | 4 | ||||
-rw-r--r-- | dummyresource/facade.cpp | 7 | ||||
-rw-r--r-- | synchronizer/listener.cpp | 28 | ||||
-rw-r--r-- | synchronizer/main.cpp | 6 | ||||
-rw-r--r-- | tests/dummyresourcefacadetest.cpp | 6 | ||||
-rw-r--r-- | tests/hawd/dataset.cpp | 6 | ||||
-rw-r--r-- | tests/hawd/dataset.h | 2 | ||||
-rw-r--r-- | tests/storagebenchmark.cpp | 14 | ||||
-rw-r--r-- | tests/storagetest.cpp | 22 |
19 files changed, 98 insertions, 50 deletions
diff --git a/client/main.cpp b/client/main.cpp index 1748331..4f86792 100644 --- a/client/main.cpp +++ b/client/main.cpp | |||
@@ -9,9 +9,8 @@ int main(int argc, char *argv[]) | |||
9 | { | 9 | { |
10 | QApplication app(argc, argv); | 10 | QApplication app(argc, argv); |
11 | 11 | ||
12 | new Console("Akonadi2 Client"); | 12 | new Akonadi2::Console("Akonadi2 Client"); |
13 | 13 | ||
14 | ResourceAccess *resAccess = 0; | ||
15 | QCommandLineParser cliOptions; | 14 | QCommandLineParser cliOptions; |
16 | cliOptions.addPositionalArgument(QObject::tr("[resource]"), | 15 | cliOptions.addPositionalArgument(QObject::tr("[resource]"), |
17 | QObject::tr("A resource to connect to")); | 16 | QObject::tr("A resource to connect to")); |
@@ -22,9 +21,9 @@ int main(int argc, char *argv[]) | |||
22 | } | 21 | } |
23 | 22 | ||
24 | for (const QString &resource: resources) { | 23 | for (const QString &resource: resources) { |
25 | resAccess = new ResourceAccess(resource); | 24 | Akonadi2::ResourceAccess *resAccess = new Akonadi2::ResourceAccess(resource); |
26 | QObject::connect(&app, &QCoreApplication::aboutToQuit, | 25 | QObject::connect(&app, &QCoreApplication::aboutToQuit, |
27 | resAccess, &ResourceAccess::close); | 26 | resAccess, &Akonadi2::ResourceAccess::close); |
28 | resAccess->open(); | 27 | resAccess->open(); |
29 | } | 28 | } |
30 | 29 | ||
diff --git a/client/resourceaccess.cpp b/client/resourceaccess.cpp index bbc7f8b..82490ca 100644 --- a/client/resourceaccess.cpp +++ b/client/resourceaccess.cpp | |||
@@ -8,6 +8,9 @@ | |||
8 | #include <QDebug> | 8 | #include <QDebug> |
9 | #include <QProcess> | 9 | #include <QProcess> |
10 | 10 | ||
11 | namespace Akonadi2 | ||
12 | { | ||
13 | |||
11 | ResourceAccess::ResourceAccess(const QString &resourceName, QObject *parent) | 14 | ResourceAccess::ResourceAccess(const QString &resourceName, QObject *parent) |
12 | : QObject(parent), | 15 | : QObject(parent), |
13 | m_resourceName(resourceName), | 16 | m_resourceName(resourceName), |
@@ -154,3 +157,5 @@ void ResourceAccess::log(const QString &message) | |||
154 | { | 157 | { |
155 | Console::main()->log(m_resourceName + ": " + message); | 158 | Console::main()->log(m_resourceName + ": " + message); |
156 | } | 159 | } |
160 | |||
161 | } | ||
diff --git a/client/resourceaccess.h b/client/resourceaccess.h index a77fe48..5877b1d 100644 --- a/client/resourceaccess.h +++ b/client/resourceaccess.h | |||
@@ -6,6 +6,9 @@ | |||
6 | 6 | ||
7 | #include <flatbuffers/flatbuffers.h> | 7 | #include <flatbuffers/flatbuffers.h> |
8 | 8 | ||
9 | namespace Akonadi2 | ||
10 | { | ||
11 | |||
9 | class ResourceAccess : public QObject | 12 | class ResourceAccess : public QObject |
10 | { | 13 | { |
11 | Q_OBJECT | 14 | Q_OBJECT |
@@ -41,3 +44,5 @@ private: | |||
41 | QByteArray m_partialMessageBuffer; | 44 | QByteArray m_partialMessageBuffer; |
42 | flatbuffers::FlatBufferBuilder m_fbb; | 45 | flatbuffers::FlatBufferBuilder m_fbb; |
43 | }; | 46 | }; |
47 | |||
48 | } | ||
diff --git a/common/commands.cpp b/common/commands.cpp index b5773e7..474b091 100644 --- a/common/commands.cpp +++ b/common/commands.cpp | |||
@@ -2,6 +2,9 @@ | |||
2 | 2 | ||
3 | #include <QIODevice> | 3 | #include <QIODevice> |
4 | 4 | ||
5 | namespace Akonadi2 | ||
6 | { | ||
7 | |||
5 | namespace Commands | 8 | namespace Commands |
6 | { | 9 | { |
7 | 10 | ||
@@ -13,4 +16,6 @@ void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb | |||
13 | device->write((const char*)fbb.GetBufferPointer(), dataSize); | 16 | device->write((const char*)fbb.GetBufferPointer(), dataSize); |
14 | } | 17 | } |
15 | 18 | ||
16 | } \ No newline at end of file | 19 | } // namespace Commands |
20 | |||
21 | } // namespace Akonadi2 | ||
diff --git a/common/commands.h b/common/commands.h index 5f2b006..3db1d3b 100644 --- a/common/commands.h +++ b/common/commands.h | |||
@@ -5,6 +5,9 @@ | |||
5 | 5 | ||
6 | class QIODevice; | 6 | class QIODevice; |
7 | 7 | ||
8 | namespace Akonadi2 | ||
9 | { | ||
10 | |||
8 | namespace Commands | 11 | namespace Commands |
9 | { | 12 | { |
10 | 13 | ||
@@ -18,3 +21,5 @@ enum CommandIds { | |||
18 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb); | 21 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb); |
19 | 22 | ||
20 | } | 23 | } |
24 | |||
25 | } // namespace Akonadi2 | ||
diff --git a/common/console.cpp b/common/console.cpp index 6fb174a..a878355 100644 --- a/common/console.cpp +++ b/common/console.cpp | |||
@@ -5,6 +5,9 @@ | |||
5 | #include <QTextBrowser> | 5 | #include <QTextBrowser> |
6 | #include <QVBoxLayout> | 6 | #include <QVBoxLayout> |
7 | 7 | ||
8 | namespace Akonadi2 | ||
9 | { | ||
10 | |||
8 | static Console *s_console = 0; | 11 | static Console *s_console = 0; |
9 | 12 | ||
10 | Console *Console::main() | 13 | Console *Console::main() |
@@ -53,3 +56,5 @@ void Console::log(const QString &message) | |||
53 | { | 56 | { |
54 | m_textDisplay->append(QString::number(m_timestamper.elapsed()).rightJustified(6) + ": " + message); | 57 | m_textDisplay->append(QString::number(m_timestamper.elapsed()).rightJustified(6) + ": " + message); |
55 | } | 58 | } |
59 | |||
60 | } // namespace Akonadi2 | ||
diff --git a/common/console.h b/common/console.h index 0df5c38..e0b803c 100644 --- a/common/console.h +++ b/common/console.h | |||
@@ -7,6 +7,9 @@ | |||
7 | 7 | ||
8 | class QTextBrowser; | 8 | class QTextBrowser; |
9 | 9 | ||
10 | namespace Akonadi2 | ||
11 | { | ||
12 | |||
10 | class AKONADI2COMMON_EXPORT Console : public QWidget | 13 | class AKONADI2COMMON_EXPORT Console : public QWidget |
11 | { | 14 | { |
12 | Q_OBJECT | 15 | Q_OBJECT |
@@ -22,3 +25,5 @@ private: | |||
22 | QTime m_timestamper; | 25 | QTime m_timestamper; |
23 | static Console *s_output; | 26 | static Console *s_output; |
24 | }; | 27 | }; |
28 | |||
29 | } // namespace Akonadi2 | ||
diff --git a/common/storage.h b/common/storage.h index 2fac068..b6d6a07 100644 --- a/common/storage.h +++ b/common/storage.h | |||
@@ -5,6 +5,9 @@ | |||
5 | #include <functional> | 5 | #include <functional> |
6 | #include <QString> | 6 | #include <QString> |
7 | 7 | ||
8 | namespace Akonadi2 | ||
9 | { | ||
10 | |||
8 | class AKONADI2COMMON_EXPORT Storage { | 11 | class AKONADI2COMMON_EXPORT Storage { |
9 | public: | 12 | public: |
10 | enum AccessMode { ReadOnly, ReadWrite }; | 13 | enum AccessMode { ReadOnly, ReadWrite }; |
@@ -52,3 +55,5 @@ private: | |||
52 | Private * const d; | 55 | Private * const d; |
53 | }; | 56 | }; |
54 | 57 | ||
58 | } // namespace Akonadi2 | ||
59 | |||
diff --git a/common/storage_common.cpp b/common/storage_common.cpp index 6263bf2..099eb36 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp | |||
@@ -2,6 +2,9 @@ | |||
2 | 2 | ||
3 | #include <iostream> | 3 | #include <iostream> |
4 | 4 | ||
5 | namespace Akonadi2 | ||
6 | { | ||
7 | |||
5 | void errorHandler(const Storage::Error &error) | 8 | void errorHandler(const Storage::Error &error) |
6 | { | 9 | { |
7 | //TODO: allow this to be turned on / off globally | 10 | //TODO: allow this to be turned on / off globally |
@@ -29,3 +32,4 @@ void Storage::scan(const std::string &sKey, const std::function<bool(void *keyPt | |||
29 | scan(sKey.data(), sKey.size(), resultHandler, &errorHandler); | 32 | scan(sKey.data(), sKey.size(), resultHandler, &errorHandler); |
30 | } | 33 | } |
31 | 34 | ||
35 | } // namespace Akonadi2 | ||
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index ce77bbb..7c5c95a 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp | |||
@@ -12,6 +12,9 @@ | |||
12 | 12 | ||
13 | #include <lmdb.h> | 13 | #include <lmdb.h> |
14 | 14 | ||
15 | namespace Akonadi2 | ||
16 | { | ||
17 | |||
15 | class Storage::Private | 18 | class Storage::Private |
16 | { | 19 | { |
17 | public: | 20 | public: |
@@ -309,3 +312,5 @@ void Storage::removeFromDisk() const | |||
309 | dir.remove("data.mdb"); | 312 | dir.remove("data.mdb"); |
310 | dir.remove("lock.mdb"); | 313 | dir.remove("lock.mdb"); |
311 | } | 314 | } |
315 | |||
316 | } // namespace Akonadi2 | ||
diff --git a/common/storage_unqlite.cpp b/common/storage_unqlite.cpp index 67f910b..69dc288 100644 --- a/common/storage_unqlite.cpp +++ b/common/storage_unqlite.cpp | |||
@@ -13,6 +13,9 @@ extern "C" { | |||
13 | #include "unqlite/unqlite.h" | 13 | #include "unqlite/unqlite.h" |
14 | } | 14 | } |
15 | 15 | ||
16 | namespace Akonadi2 | ||
17 | { | ||
18 | |||
16 | static const char *s_unqliteDir = "/unqlite/"; | 19 | static const char *s_unqliteDir = "/unqlite/"; |
17 | 20 | ||
18 | class Storage::Private | 21 | class Storage::Private |
@@ -289,3 +292,4 @@ void Storage::removeFromDisk() const | |||
289 | QFile::remove(d->storageRoot + s_unqliteDir + d->name); | 292 | QFile::remove(d->storageRoot + s_unqliteDir + d->name); |
290 | } | 293 | } |
291 | 294 | ||
295 | } // namespace Akonadi2 | ||
diff --git a/dummyresource/facade.cpp b/dummyresource/facade.cpp index 44056f8..668749e 100644 --- a/dummyresource/facade.cpp +++ b/dummyresource/facade.cpp | |||
@@ -44,7 +44,8 @@ void DummyResourceFacade::remove(const Akonadi2::Domain::Event &domainObject) | |||
44 | //-how do we free/munmap the data if we don't know when no one references it any longer? => no munmap needed, but read transaction to keep pointer alive | 44 | //-how do we free/munmap the data if we don't know when no one references it any longer? => no munmap needed, but read transaction to keep pointer alive |
45 | //-we could bind the lifetime to the query | 45 | //-we could bind the lifetime to the query |
46 | //=> perhaps do heap allocate and use smart pointer? | 46 | //=> perhaps do heap allocate and use smart pointer? |
47 | class DummyEventAdaptor : public Akonadi2::Domain::Event { | 47 | class DummyEventAdaptor : public Akonadi2::Domain::Event |
48 | { | ||
48 | public: | 49 | public: |
49 | DummyEventAdaptor(const QString &resource, const QString &identifier, qint64 revision) | 50 | DummyEventAdaptor(const QString &resource, const QString &identifier, qint64 revision) |
50 | :Akonadi2::Domain::Event(resource, identifier, revision) | 51 | :Akonadi2::Domain::Event(resource, identifier, revision) |
@@ -71,13 +72,13 @@ public: | |||
71 | DummyEvent const *buffer; | 72 | DummyEvent const *buffer; |
72 | 73 | ||
73 | //Keep query alive so values remain valid | 74 | //Keep query alive so values remain valid |
74 | QSharedPointer<Storage> storage; | 75 | QSharedPointer<Akonadi2::Storage> storage; |
75 | }; | 76 | }; |
76 | 77 | ||
77 | void DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback) | 78 | void DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback) |
78 | { | 79 | { |
79 | qDebug() << "load called"; | 80 | qDebug() << "load called"; |
80 | auto storage = QSharedPointer<Storage>::create(Akonadi2::Store::storageLocation(), "dummyresource"); | 81 | auto storage = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::Store::storageLocation(), "dummyresource"); |
81 | 82 | ||
82 | //Compose some functions to make query matching fast. | 83 | //Compose some functions to make query matching fast. |
83 | //This way we can process the query once, and convert all values into something that can be compared quickly | 84 | //This way we can process the query once, and convert all values into something that can be compared quickly |
diff --git a/synchronizer/listener.cpp b/synchronizer/listener.cpp index 01daf5d..7905038 100644 --- a/synchronizer/listener.cpp +++ b/synchronizer/listener.cpp | |||
@@ -15,18 +15,18 @@ Listener::Listener(const QString &resource, QObject *parent) | |||
15 | { | 15 | { |
16 | connect(m_server, &QLocalServer::newConnection, | 16 | connect(m_server, &QLocalServer::newConnection, |
17 | this, &Listener::acceptConnection); | 17 | this, &Listener::acceptConnection); |
18 | Console::main()->log(QString("Trying to open %1").arg(resource)); | 18 | Akonadi2::Console::main()->log(QString("Trying to open %1").arg(resource)); |
19 | if (!m_server->listen(resource)) { | 19 | if (!m_server->listen(resource)) { |
20 | // FIXME: multiple starts need to be handled here | 20 | // FIXME: multiple starts need to be handled here |
21 | m_server->removeServer(resource); | 21 | m_server->removeServer(resource); |
22 | if (!m_server->listen(resource)) { | 22 | if (!m_server->listen(resource)) { |
23 | Console::main()->log("Utter failure to start server"); | 23 | Akonadi2::Console::main()->log("Utter failure to start server"); |
24 | exit(-1); | 24 | exit(-1); |
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | if (m_server->isListening()) { | 28 | if (m_server->isListening()) { |
29 | Console::main()->log(QString("Listening on %1").arg(m_server->serverName())); | 29 | Akonadi2::Console::main()->log(QString("Listening on %1").arg(m_server->serverName())); |
30 | } | 30 | } |
31 | 31 | ||
32 | QTimer::singleShot(2000, this, SLOT(checkConnections())); | 32 | QTimer::singleShot(2000, this, SLOT(checkConnections())); |
@@ -63,14 +63,14 @@ void Listener::closeAllConnections() | |||
63 | 63 | ||
64 | void Listener::acceptConnection() | 64 | void Listener::acceptConnection() |
65 | { | 65 | { |
66 | Console::main()->log(QString("Accepting connection")); | 66 | Akonadi2::Console::main()->log(QString("Accepting connection")); |
67 | QLocalSocket *socket = m_server->nextPendingConnection(); | 67 | QLocalSocket *socket = m_server->nextPendingConnection(); |
68 | 68 | ||
69 | if (!socket) { | 69 | if (!socket) { |
70 | return; | 70 | return; |
71 | } | 71 | } |
72 | 72 | ||
73 | Console::main()->log("Got a connection"); | 73 | Akonadi2::Console::main()->log("Got a connection"); |
74 | Client client("Unknown Client" /*fixme: actual names!*/, socket); | 74 | Client client("Unknown Client" /*fixme: actual names!*/, socket); |
75 | connect(socket, &QIODevice::readyRead, | 75 | connect(socket, &QIODevice::readyRead, |
76 | this, &Listener::readFromSocket); | 76 | this, &Listener::readFromSocket); |
@@ -87,12 +87,12 @@ void Listener::clientDropped() | |||
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | 89 | ||
90 | Console::main()->log("Dropping connection..."); | 90 | Akonadi2::Console::main()->log("Dropping connection..."); |
91 | QMutableVectorIterator<Client> it(m_connections); | 91 | QMutableVectorIterator<Client> it(m_connections); |
92 | while (it.hasNext()) { | 92 | while (it.hasNext()) { |
93 | const Client &client = it.next(); | 93 | const Client &client = it.next(); |
94 | if (client.socket == socket) { | 94 | if (client.socket == socket) { |
95 | Console::main()->log(QString(" dropped... %1").arg(client.name)); | 95 | Akonadi2::Console::main()->log(QString(" dropped... %1").arg(client.name)); |
96 | it.remove(); | 96 | it.remove(); |
97 | break; | 97 | break; |
98 | } | 98 | } |
@@ -116,10 +116,10 @@ void Listener::readFromSocket() | |||
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | 118 | ||
119 | Console::main()->log("Reading from socket..."); | 119 | Akonadi2::Console::main()->log("Reading from socket..."); |
120 | for (Client &client: m_connections) { | 120 | for (Client &client: m_connections) { |
121 | if (client.socket == socket) { | 121 | if (client.socket == socket) { |
122 | Console::main()->log(QString(" Client: %1").arg(client.name)); | 122 | Akonadi2::Console::main()->log(QString(" Client: %1").arg(client.name)); |
123 | client.commandBuffer += socket->readAll(); | 123 | client.commandBuffer += socket->readAll(); |
124 | // FIXME: schedule these rather than process them all at once | 124 | // FIXME: schedule these rather than process them all at once |
125 | // right now this can lead to starvation of clients due to | 125 | // right now this can lead to starvation of clients due to |
@@ -133,7 +133,7 @@ void Listener::readFromSocket() | |||
133 | bool Listener::processClientBuffer(Client &client) | 133 | bool Listener::processClientBuffer(Client &client) |
134 | { | 134 | { |
135 | static const int headerSize = (sizeof(int) * 2); | 135 | static const int headerSize = (sizeof(int) * 2); |
136 | Console::main()->log(QString("processing %1").arg(client.commandBuffer.size())); | 136 | Akonadi2::Console::main()->log(QString("processing %1").arg(client.commandBuffer.size())); |
137 | if (client.commandBuffer.size() < headerSize) { | 137 | if (client.commandBuffer.size() < headerSize) { |
138 | return false; | 138 | return false; |
139 | } | 139 | } |
@@ -147,9 +147,9 @@ bool Listener::processClientBuffer(Client &client) | |||
147 | client.commandBuffer.remove(0, headerSize + size); | 147 | client.commandBuffer.remove(0, headerSize + size); |
148 | 148 | ||
149 | switch (commandId) { | 149 | switch (commandId) { |
150 | case Commands::HandshakeCommand: { | 150 | case Akonadi2::Commands::HandshakeCommand: { |
151 | auto buffer = Akonadi2::GetHandshake(data.constData()); | 151 | auto buffer = Akonadi2::GetHandshake(data.constData()); |
152 | Console::main()->log(QString(" Handshake from %1").arg(buffer->name()->c_str())); | 152 | Akonadi2::Console::main()->log(QString(" Handshake from %1").arg(buffer->name()->c_str())); |
153 | sendCurrentRevision(client); | 153 | sendCurrentRevision(client); |
154 | break; | 154 | break; |
155 | } | 155 | } |
@@ -172,7 +172,7 @@ void Listener::sendCurrentRevision(Client &client) | |||
172 | 172 | ||
173 | auto command = Akonadi2::CreateRevisionUpdate(m_fbb, m_revision); | 173 | auto command = Akonadi2::CreateRevisionUpdate(m_fbb, m_revision); |
174 | Akonadi2::FinishRevisionUpdateBuffer(m_fbb, command); | 174 | Akonadi2::FinishRevisionUpdateBuffer(m_fbb, command); |
175 | Commands::write(client.socket, Commands::RevisionUpdateCommand, m_fbb); | 175 | Akonadi2::Commands::write(client.socket, Akonadi2::Commands::RevisionUpdateCommand, m_fbb); |
176 | m_fbb.Clear(); | 176 | m_fbb.Clear(); |
177 | } | 177 | } |
178 | 178 | ||
@@ -186,7 +186,7 @@ void Listener::updateClientsWithRevision() | |||
186 | continue; | 186 | continue; |
187 | } | 187 | } |
188 | 188 | ||
189 | Commands::write(client.socket, Commands::RevisionUpdateCommand, m_fbb); | 189 | Akonadi2::Commands::write(client.socket, Akonadi2::Commands::RevisionUpdateCommand, m_fbb); |
190 | } | 190 | } |
191 | m_fbb.Clear(); | 191 | m_fbb.Clear(); |
192 | } | 192 | } |
diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp index f4091df..fbb3c00 100644 --- a/synchronizer/main.cpp +++ b/synchronizer/main.cpp | |||
@@ -9,12 +9,12 @@ int main(int argc, char *argv[]) | |||
9 | QApplication app(argc, argv); | 9 | QApplication app(argc, argv); |
10 | 10 | ||
11 | if (argc < 2) { | 11 | if (argc < 2) { |
12 | new Console(QString("Resource: ???")); | 12 | new Akonadi2::Console(QString("Resource: ???")); |
13 | Console::main()->log("Not enough args passed, no resource loaded."); | 13 | Akonadi2::Console::main()->log("Not enough args passed, no resource loaded."); |
14 | return app.exec(); | 14 | return app.exec(); |
15 | } | 15 | } |
16 | 16 | ||
17 | new Console(QString("Resource: %1").arg(argv[1])); | 17 | new Akonadi2::Console(QString("Resource: %1").arg(argv[1])); |
18 | Listener *listener = new Listener(argv[1]); | 18 | Listener *listener = new Listener(argv[1]); |
19 | 19 | ||
20 | QObject::connect(&app, &QCoreApplication::aboutToQuit, | 20 | QObject::connect(&app, &QCoreApplication::aboutToQuit, |
diff --git a/tests/dummyresourcefacadetest.cpp b/tests/dummyresourcefacadetest.cpp index 26daa23..d815e9b 100644 --- a/tests/dummyresourcefacadetest.cpp +++ b/tests/dummyresourcefacadetest.cpp | |||
@@ -19,7 +19,7 @@ private: | |||
19 | 19 | ||
20 | void populate(int count) | 20 | void populate(int count) |
21 | { | 21 | { |
22 | Storage storage(testDataPath, dbName, Storage::ReadWrite); | 22 | Akonadi2::Storage storage(testDataPath, dbName, Akonadi2::Storage::ReadWrite); |
23 | for (int i = 0; i < count; i++) { | 23 | for (int i = 0; i < count; i++) { |
24 | storage.write(keyPrefix + std::to_string(i), keyPrefix + std::to_string(i)); | 24 | storage.write(keyPrefix + std::to_string(i), keyPrefix + std::to_string(i)); |
25 | } | 25 | } |
@@ -38,7 +38,7 @@ private Q_SLOTS: | |||
38 | 38 | ||
39 | void cleanupTestCase() | 39 | void cleanupTestCase() |
40 | { | 40 | { |
41 | Storage storage(testDataPath, dbName); | 41 | Akonadi2::Storage storage(testDataPath, dbName); |
42 | storage.removeFromDisk(); | 42 | storage.removeFromDisk(); |
43 | } | 43 | } |
44 | 44 | ||
@@ -63,7 +63,7 @@ private Q_SLOTS: | |||
63 | QTRY_VERIFY(complete); | 63 | QTRY_VERIFY(complete); |
64 | QCOMPARE(results.size(), 1); | 64 | QCOMPARE(results.size(), 1); |
65 | 65 | ||
66 | Storage storage(testDataPath, dbName); | 66 | Akonadi2::Storage storage(testDataPath, dbName); |
67 | storage.removeFromDisk(); | 67 | storage.removeFromDisk(); |
68 | } | 68 | } |
69 | 69 | ||
diff --git a/tests/hawd/dataset.cpp b/tests/hawd/dataset.cpp index a5328e4..6e73c5c 100644 --- a/tests/hawd/dataset.cpp +++ b/tests/hawd/dataset.cpp | |||
@@ -207,7 +207,7 @@ QString Dataset::Row::toString(const QStringList &cols, int standardCols, const | |||
207 | 207 | ||
208 | Dataset::Dataset(const QString &name, const State &state) | 208 | Dataset::Dataset(const QString &name, const State &state) |
209 | : m_definition(state.datasetDefinition(name)), | 209 | : m_definition(state.datasetDefinition(name)), |
210 | m_storage(state.resultsPath(), name, Storage::ReadWrite), | 210 | m_storage(state.resultsPath(), name, Akonadi2::Storage::ReadWrite), |
211 | m_commitHash(state.commitHash()) | 211 | m_commitHash(state.commitHash()) |
212 | { | 212 | { |
213 | m_storage.startTransaction(); | 213 | m_storage.startTransaction(); |
@@ -264,7 +264,7 @@ void Dataset::eachRow(const std::function<void(const Row &row)> &resultHandler) | |||
264 | resultHandler(row); | 264 | resultHandler(row); |
265 | return true; | 265 | return true; |
266 | }, | 266 | }, |
267 | Storage::basicErrorHandler()); | 267 | Akonadi2::Storage::basicErrorHandler()); |
268 | } | 268 | } |
269 | 269 | ||
270 | Dataset::Row Dataset::row(qint64 key) | 270 | Dataset::Row Dataset::row(qint64 key) |
@@ -282,7 +282,7 @@ Dataset::Row Dataset::row(qint64 key) | |||
282 | row.fromBinary(array); | 282 | row.fromBinary(array); |
283 | return true; | 283 | return true; |
284 | }, | 284 | }, |
285 | Storage::basicErrorHandler() | 285 | Akonadi2::Storage::basicErrorHandler() |
286 | ); | 286 | ); |
287 | return row; | 287 | return row; |
288 | } | 288 | } |
diff --git a/tests/hawd/dataset.h b/tests/hawd/dataset.h index 09a5828..dd1d6f2 100644 --- a/tests/hawd/dataset.h +++ b/tests/hawd/dataset.h | |||
@@ -83,7 +83,7 @@ public: | |||
83 | 83 | ||
84 | private: | 84 | private: |
85 | DatasetDefinition m_definition; | 85 | DatasetDefinition m_definition; |
86 | Storage m_storage; | 86 | Akonadi2::Storage m_storage; |
87 | QString m_commitHash; | 87 | QString m_commitHash; |
88 | }; | 88 | }; |
89 | 89 | ||
diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp index 130753f..9cf9a71 100644 --- a/tests/storagebenchmark.cpp +++ b/tests/storagebenchmark.cpp | |||
@@ -62,7 +62,7 @@ private Q_SLOTS: | |||
62 | 62 | ||
63 | void cleanupTestCase() | 63 | void cleanupTestCase() |
64 | { | 64 | { |
65 | Storage store(testDataPath, dbName); | 65 | Akonadi2::Storage store(testDataPath, dbName); |
66 | store.removeFromDisk(); | 66 | store.removeFromDisk(); |
67 | } | 67 | } |
68 | 68 | ||
@@ -80,9 +80,9 @@ private Q_SLOTS: | |||
80 | QFETCH(bool, useDb); | 80 | QFETCH(bool, useDb); |
81 | QFETCH(int, count); | 81 | QFETCH(int, count); |
82 | 82 | ||
83 | QScopedPointer<Storage> store; | 83 | QScopedPointer<Akonadi2::Storage> store; |
84 | if (useDb) { | 84 | if (useDb) { |
85 | store.reset(new Storage(testDataPath, dbName, Storage::ReadWrite)); | 85 | store.reset(new Akonadi2::Storage(testDataPath, dbName, Akonadi2::Storage::ReadWrite)); |
86 | } | 86 | } |
87 | 87 | ||
88 | std::ofstream myfile; | 88 | std::ofstream myfile; |
@@ -143,10 +143,10 @@ private Q_SLOTS: | |||
143 | qDebug() << "File reading is not implemented."; | 143 | qDebug() << "File reading is not implemented."; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | void testScan() | 147 | void testScan() |
148 | { | 148 | { |
149 | QScopedPointer<Storage> store(new Storage(testDataPath, dbName, Storage::ReadOnly)); | 149 | QScopedPointer<Akonadi2::Storage> store(new Akonadi2::Storage(testDataPath, dbName, Akonadi2::Storage::ReadOnly)); |
150 | 150 | ||
151 | QBENCHMARK { | 151 | QBENCHMARK { |
152 | int hit = 0; | 152 | int hit = 0; |
@@ -163,7 +163,7 @@ private Q_SLOTS: | |||
163 | 163 | ||
164 | void testKeyLookup() | 164 | void testKeyLookup() |
165 | { | 165 | { |
166 | QScopedPointer<Storage> store(new Storage(testDataPath, dbName, Storage::ReadOnly)); | 166 | QScopedPointer<Akonadi2::Storage> store(new Akonadi2::Storage(testDataPath, dbName, Akonadi2::Storage::ReadOnly)); |
167 | 167 | ||
168 | QBENCHMARK { | 168 | QBENCHMARK { |
169 | int hit = 0; | 169 | int hit = 0; |
@@ -203,7 +203,7 @@ private Q_SLOTS: | |||
203 | 203 | ||
204 | void testSizes() | 204 | void testSizes() |
205 | { | 205 | { |
206 | Storage store(testDataPath, dbName); | 206 | Akonadi2::Storage store(testDataPath, dbName); |
207 | qDebug() << "Database size [kb]: " << store.diskUsage()/1024; | 207 | qDebug() << "Database size [kb]: " << store.diskUsage()/1024; |
208 | 208 | ||
209 | QFileInfo fileInfo(filePath); | 209 | QFileInfo fileInfo(filePath); |
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp index 3c20135..a771042 100644 --- a/tests/storagetest.cpp +++ b/tests/storagetest.cpp | |||
@@ -19,7 +19,7 @@ private: | |||
19 | 19 | ||
20 | void populate(int count) | 20 | void populate(int count) |
21 | { | 21 | { |
22 | Storage storage(testDataPath, dbName, Storage::ReadWrite); | 22 | Akonadi2::Storage storage(testDataPath, dbName, Akonadi2::Storage::ReadWrite); |
23 | for (int i = 0; i < count; i++) { | 23 | for (int i = 0; i < count; i++) { |
24 | //This should perhaps become an implementation detail of the db? | 24 | //This should perhaps become an implementation detail of the db? |
25 | if (i % 10000 == 0) { | 25 | if (i % 10000 == 0) { |
@@ -33,7 +33,7 @@ private: | |||
33 | storage.commitTransaction(); | 33 | storage.commitTransaction(); |
34 | } | 34 | } |
35 | 35 | ||
36 | bool verify(Storage &storage, int i) | 36 | bool verify(Akonadi2::Storage &storage, int i) |
37 | { | 37 | { |
38 | bool success = true; | 38 | bool success = true; |
39 | bool keyMatch = true; | 39 | bool keyMatch = true; |
@@ -46,7 +46,7 @@ private: | |||
46 | } | 46 | } |
47 | return keyMatch; | 47 | return keyMatch; |
48 | }, | 48 | }, |
49 | [&success](const Storage::Error &) { success = false; } | 49 | [&success](const Akonadi2::Storage::Error &) { success = false; } |
50 | ); | 50 | ); |
51 | return success && keyMatch; | 51 | return success && keyMatch; |
52 | } | 52 | } |
@@ -60,7 +60,7 @@ private Q_SLOTS: | |||
60 | 60 | ||
61 | void cleanupTestCase() | 61 | void cleanupTestCase() |
62 | { | 62 | { |
63 | Storage storage(testDataPath, dbName); | 63 | Akonadi2::Storage storage(testDataPath, dbName); |
64 | storage.removeFromDisk(); | 64 | storage.removeFromDisk(); |
65 | } | 65 | } |
66 | 66 | ||
@@ -72,13 +72,13 @@ private Q_SLOTS: | |||
72 | 72 | ||
73 | //ensure we can read everything back correctly | 73 | //ensure we can read everything back correctly |
74 | { | 74 | { |
75 | Storage storage(testDataPath, dbName); | 75 | Akonadi2::Storage storage(testDataPath, dbName); |
76 | for (int i = 0; i < count; i++) { | 76 | for (int i = 0; i < count; i++) { |
77 | QVERIFY(verify(storage, i)); | 77 | QVERIFY(verify(storage, i)); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | Storage storage(testDataPath, dbName); | 81 | Akonadi2::Storage storage(testDataPath, dbName); |
82 | storage.removeFromDisk(); | 82 | storage.removeFromDisk(); |
83 | } | 83 | } |
84 | 84 | ||
@@ -90,7 +90,7 @@ private Q_SLOTS: | |||
90 | //ensure we can scan for values | 90 | //ensure we can scan for values |
91 | { | 91 | { |
92 | int hit = 0; | 92 | int hit = 0; |
93 | Storage store(testDataPath, dbName); | 93 | Akonadi2::Storage store(testDataPath, dbName); |
94 | store.scan("", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { | 94 | store.scan("", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { |
95 | if (std::string(static_cast<char*>(keyValue), keySize) == "key50") { | 95 | if (std::string(static_cast<char*>(keyValue), keySize) == "key50") { |
96 | hit++; | 96 | hit++; |
@@ -104,7 +104,7 @@ private Q_SLOTS: | |||
104 | { | 104 | { |
105 | int hit = 0; | 105 | int hit = 0; |
106 | bool foundInvalidValue = false; | 106 | bool foundInvalidValue = false; |
107 | Storage store(testDataPath, dbName); | 107 | Akonadi2::Storage store(testDataPath, dbName); |
108 | store.scan("key50", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { | 108 | store.scan("key50", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { |
109 | if (std::string(static_cast<char*>(keyValue), keySize) != "key50") { | 109 | if (std::string(static_cast<char*>(keyValue), keySize) != "key50") { |
110 | foundInvalidValue = true; | 110 | foundInvalidValue = true; |
@@ -116,7 +116,7 @@ private Q_SLOTS: | |||
116 | QCOMPARE(hit, 1); | 116 | QCOMPARE(hit, 1); |
117 | } | 117 | } |
118 | 118 | ||
119 | Storage storage(testDataPath, dbName); | 119 | Akonadi2::Storage storage(testDataPath, dbName); |
120 | storage.removeFromDisk(); | 120 | storage.removeFromDisk(); |
121 | } | 121 | } |
122 | 122 | ||
@@ -132,7 +132,7 @@ private Q_SLOTS: | |||
132 | const int concurrencyLevel = 10; | 132 | const int concurrencyLevel = 10; |
133 | for (int num = 0; num < concurrencyLevel; num++) { | 133 | for (int num = 0; num < concurrencyLevel; num++) { |
134 | futures << QtConcurrent::run([this, count, &error](){ | 134 | futures << QtConcurrent::run([this, count, &error](){ |
135 | Storage storage(testDataPath, dbName); | 135 | Akonadi2::Storage storage(testDataPath, dbName); |
136 | for (int i = 0; i < count; i++) { | 136 | for (int i = 0; i < count; i++) { |
137 | if (!verify(storage, i)) { | 137 | if (!verify(storage, i)) { |
138 | error = true; | 138 | error = true; |
@@ -146,7 +146,7 @@ private Q_SLOTS: | |||
146 | } | 146 | } |
147 | QVERIFY(!error); | 147 | QVERIFY(!error); |
148 | 148 | ||
149 | Storage storage(testDataPath, dbName); | 149 | Akonadi2::Storage storage(testDataPath, dbName); |
150 | storage.removeFromDisk(); | 150 | storage.removeFromDisk(); |
151 | } | 151 | } |
152 | }; | 152 | }; |