summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-08 17:43:07 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-08 17:43:07 +0100
commit9c8e4612403fc2accc26ac2b49670394972f1293 (patch)
treea0f09d24cb1c9cec3e9778a06deb0da154f02078
parent5255876dde678aa7d5af8020d5836b1fc6c58fc7 (diff)
downloadsink-9c8e4612403fc2accc26ac2b49670394972f1293.tar.gz
sink-9c8e4612403fc2accc26ac2b49670394972f1293.zip
One copy algorithm is enough.
-rw-r--r--common/bufferadaptor.h13
-rw-r--r--common/domain/applicationdomaintype.h5
-rw-r--r--common/pipeline.cpp3
3 files changed, 5 insertions, 16 deletions
diff --git a/common/bufferadaptor.h b/common/bufferadaptor.h
index 8787d39..f6994d7 100644
--- a/common/bufferadaptor.h
+++ b/common/bufferadaptor.h
@@ -59,19 +59,6 @@ public:
59 { 59 {
60 } 60 }
61 61
62 MemoryBufferAdaptor(const BufferAdaptor &buffer, const QList<QByteArray> &properties) : BufferAdaptor()
63 {
64 if (properties.isEmpty()) {
65 for (const auto &property : buffer.availableProperties()) {
66 mValues.insert(property, buffer.getProperty(property));
67 }
68 } else {
69 for (const auto &property : properties) {
70 mValues.insert(property, buffer.getProperty(property));
71 }
72 }
73 }
74
75 virtual ~MemoryBufferAdaptor() 62 virtual ~MemoryBufferAdaptor()
76 { 63 {
77 } 64 }
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h
index be14513..7c3800d 100644
--- a/common/domain/applicationdomaintype.h
+++ b/common/domain/applicationdomaintype.h
@@ -122,7 +122,7 @@ struct Reference {
122 QByteArray value; 122 QByteArray value;
123}; 123};
124 124
125void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList<QByteArray> &properties, bool copyBlobs, bool pruneReferences); 125void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList<QByteArray> &properties = QList<QByteArray>(), bool copyBlobs = false, bool pruneReferences = false);
126 126
127/** 127/**
128 * The domain type interface has two purposes: 128 * The domain type interface has two purposes:
@@ -155,7 +155,8 @@ public:
155 template <typename DomainType> 155 template <typename DomainType>
156 static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType, const QList<QByteArray> properties = QList<QByteArray>()) 156 static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType, const QList<QByteArray> properties = QList<QByteArray>())
157 { 157 {
158 auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(*(domainType.mAdaptor), properties); 158 auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create();
159 copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, false, false);
159 //mIdentifier internally still refers to the memory-mapped memory, we need to copy the memory or it will become invalid 160 //mIdentifier internally still refers to the memory-mapped memory, we need to copy the memory or it will become invalid
160 return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); 161 return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor);
161 } 162 }
diff --git a/common/pipeline.cpp b/common/pipeline.cpp
index 7ee4b91..0eb6df5 100644
--- a/common/pipeline.cpp
+++ b/common/pipeline.cpp
@@ -168,7 +168,8 @@ KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size)
168 } 168 }
169 169
170 auto adaptor = adaptorFactory->createAdaptor(*entity); 170 auto adaptor = adaptorFactory->createAdaptor(*entity);
171 auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(*(adaptor), adaptor->availableProperties()); 171 auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create();
172 Sink::ApplicationDomain::copyBuffer(*adaptor, *memoryAdaptor);
172 173
173 d->revisionChanged = true; 174 d->revisionChanged = true;
174 auto revision = d->entityStore.maxRevision(); 175 auto revision = d->entityStore.maxRevision();