summaryrefslogtreecommitdiffstats
path: root/common/resourceaccess.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-03 09:01:05 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-03 09:01:05 +0100
commit4d9746c828558c9f872e0aed52442863affb25d5 (patch)
tree507d7c2ba67f47d3cbbcf01a722236ff1b48426b /common/resourceaccess.h
parent9cea920b7dd51867a0be0fed2f461b6be73c103e (diff)
downloadsink-4d9746c828558c9f872e0aed52442863affb25d5.tar.gz
sink-4d9746c828558c9f872e0aed52442863affb25d5.zip
Fromatted the whole codebase with clang-format.
clang-format -i */**{.cpp,.h}
Diffstat (limited to 'common/resourceaccess.h')
-rw-r--r--common/resourceaccess.h60
1 files changed, 40 insertions, 20 deletions
diff --git a/common/resourceaccess.h b/common/resourceaccess.h
index ce7e174..bd9af65 100644
--- a/common/resourceaccess.h
+++ b/common/resourceaccess.h
@@ -30,8 +30,7 @@
30#include <flatbuffers/flatbuffers.h> 30#include <flatbuffers/flatbuffers.h>
31#include "notification.h" 31#include "notification.h"
32 32
33namespace Sink 33namespace Sink {
34{
35 34
36struct QueuedCommand; 35struct QueuedCommand;
37 36
@@ -41,17 +40,37 @@ class SINK_EXPORT ResourceAccessInterface : public QObject
41public: 40public:
42 typedef QSharedPointer<ResourceAccessInterface> Ptr; 41 typedef QSharedPointer<ResourceAccessInterface> Ptr;
43 42
44 ResourceAccessInterface() {} 43 ResourceAccessInterface()
45 virtual ~ResourceAccessInterface() {} 44 {
45 }
46 virtual ~ResourceAccessInterface()
47 {
48 }
46 virtual KAsync::Job<void> sendCommand(int commandId) = 0; 49 virtual KAsync::Job<void> sendCommand(int commandId) = 0;
47 virtual KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) = 0; 50 virtual KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) = 0;
48 virtual KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) = 0; 51 virtual KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) = 0;
49 52
50 virtual KAsync::Job<void> sendCreateCommand(const QByteArray &resourceBufferType, const QByteArray &buffer) { return KAsync::null<void>(); }; 53 virtual KAsync::Job<void> sendCreateCommand(const QByteArray &resourceBufferType, const QByteArray &buffer)
51 virtual KAsync::Job<void> sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer) { return KAsync::null<void>(); }; 54 {
52 virtual KAsync::Job<void> sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) { return KAsync::null<void>(); }; 55 return KAsync::null<void>();
53 virtual KAsync::Job<void> sendRevisionReplayedCommand(qint64 revision) {return KAsync::null<void>(); }; 56 };
54 virtual KAsync::Job<void> sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expecedValue) {return KAsync::null<void>(); }; 57 virtual KAsync::Job<void> sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer)
58 {
59 return KAsync::null<void>();
60 };
61 virtual KAsync::Job<void> sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType)
62 {
63 return KAsync::null<void>();
64 };
65 virtual KAsync::Job<void> sendRevisionReplayedCommand(qint64 revision)
66 {
67 return KAsync::null<void>();
68 };
69 virtual KAsync::Job<void>
70 sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expecedValue)
71 {
72 return KAsync::null<void>();
73 };
55 74
56signals: 75signals:
57 void ready(bool isReady); 76 void ready(bool isReady);
@@ -79,21 +98,23 @@ public:
79 KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) Q_DECL_OVERRIDE; 98 KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) Q_DECL_OVERRIDE;
80 KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) Q_DECL_OVERRIDE; 99 KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) Q_DECL_OVERRIDE;
81 KAsync::Job<void> sendCreateCommand(const QByteArray &resourceBufferType, const QByteArray &buffer) Q_DECL_OVERRIDE; 100 KAsync::Job<void> sendCreateCommand(const QByteArray &resourceBufferType, const QByteArray &buffer) Q_DECL_OVERRIDE;
82 KAsync::Job<void> sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer) Q_DECL_OVERRIDE; 101 KAsync::Job<void>
102 sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer) Q_DECL_OVERRIDE;
83 KAsync::Job<void> sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) Q_DECL_OVERRIDE; 103 KAsync::Job<void> sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) Q_DECL_OVERRIDE;
84 KAsync::Job<void> sendRevisionReplayedCommand(qint64 revision) Q_DECL_OVERRIDE; 104 KAsync::Job<void> sendRevisionReplayedCommand(qint64 revision) Q_DECL_OVERRIDE;
85 KAsync::Job<void> sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expecedValue) Q_DECL_OVERRIDE; 105 KAsync::Job<void>
106 sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expecedValue) Q_DECL_OVERRIDE;
86 /** 107 /**
87 * Tries to connect to server, and returns a connected socket on success. 108 * Tries to connect to server, and returns a connected socket on success.
88 */ 109 */
89 static KAsync::Job<QSharedPointer<QLocalSocket> > connectToServer(const QByteArray &identifier); 110 static KAsync::Job<QSharedPointer<QLocalSocket>> connectToServer(const QByteArray &identifier);
90 111
91public slots: 112public slots:
92 void open() Q_DECL_OVERRIDE; 113 void open() Q_DECL_OVERRIDE;
93 void close() Q_DECL_OVERRIDE; 114 void close() Q_DECL_OVERRIDE;
94 115
95private slots: 116private slots:
96 //TODO: move these to the Private class 117 // TODO: move these to the Private class
97 void disconnected(); 118 void disconnected();
98 void connectionError(QLocalSocket::LocalSocketError error); 119 void connectionError(QLocalSocket::LocalSocketError error);
99 void readResourceMessage(); 120 void readResourceMessage();
@@ -108,23 +129,22 @@ private:
108 void processPendingCommandQueue(); 129 void processPendingCommandQueue();
109 130
110 class Private; 131 class Private;
111 Private * const d; 132 Private *const d;
112}; 133};
113 134
114/** 135/**
115 * A factory for resource access instances that caches the instance for some time. 136 * A factory for resource access instances that caches the instance for some time.
116 * 137 *
117 * This avoids constantly recreating connections, and should allow a single process to have one connection per resource. 138 * This avoids constantly recreating connections, and should allow a single process to have one connection per resource.
118 */ 139 */
119class ResourceAccessFactory { 140class ResourceAccessFactory
141{
120public: 142public:
121 static ResourceAccessFactory &instance(); 143 static ResourceAccessFactory &instance();
122 Sink::ResourceAccess::Ptr getAccess(const QByteArray &instanceIdentifier); 144 Sink::ResourceAccess::Ptr getAccess(const QByteArray &instanceIdentifier);
123 145
124 QHash<QByteArray, QWeakPointer<Sink::ResourceAccess> > mWeakCache; 146 QHash<QByteArray, QWeakPointer<Sink::ResourceAccess>> mWeakCache;
125 QHash<QByteArray, Sink::ResourceAccess::Ptr> mCache; 147 QHash<QByteArray, Sink::ResourceAccess::Ptr> mCache;
126 QHash<QByteArray, QTimer*> mTimer; 148 QHash<QByteArray, QTimer *> mTimer;
127}; 149};
128
129
130} 150}