summaryrefslogtreecommitdiffstats
path: root/common/domainadaptor.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/domainadaptor.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/domainadaptor.h')
-rw-r--r--common/domainadaptor.h52
1 files changed, 25 insertions, 27 deletions
diff --git a/common/domainadaptor.h b/common/domainadaptor.h
index 9ce5a8a..0159c6c 100644
--- a/common/domainadaptor.h
+++ b/common/domainadaptor.h
@@ -40,10 +40,11 @@
40 * Create a buffer from a domain object using the provided mappings 40 * Create a buffer from a domain object using the provided mappings
41 */ 41 */
42template <class Builder, class Buffer> 42template <class Builder, class Buffer>
43flatbuffers::Offset<Buffer> createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const WritePropertyMapper<Builder> &mapper) 43flatbuffers::Offset<Buffer>
44createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const WritePropertyMapper<Builder> &mapper)
44{ 45{
45 //First create a primitives such as strings using the mappings 46 // First create a primitives such as strings using the mappings
46 QList<std::function<void(Builder &)> > propertiesToAddToResource; 47 QList<std::function<void(Builder &)>> propertiesToAddToResource;
47 for (const auto &property : domainObject.changedProperties()) { 48 for (const auto &property : domainObject.changedProperties()) {
48 // Trace() << "copying property " << property; 49 // Trace() << "copying property " << property;
49 const auto value = domainObject.getProperty(property); 50 const auto value = domainObject.getProperty(property);
@@ -54,7 +55,7 @@ flatbuffers::Offset<Buffer> createBufferPart(const Sink::ApplicationDomain::Appl
54 } 55 }
55 } 56 }
56 57
57 //Then create all porperties using the above generated builderCalls 58 // Then create all porperties using the above generated builderCalls
58 Builder builder(fbb); 59 Builder builder(fbb);
59 for (auto propertyBuilder : propertiesToAddToResource) { 60 for (auto propertyBuilder : propertiesToAddToResource) {
60 propertyBuilder(builder); 61 propertyBuilder(builder);
@@ -64,7 +65,7 @@ flatbuffers::Offset<Buffer> createBufferPart(const Sink::ApplicationDomain::Appl
64 65
65/** 66/**
66 * Create the buffer and finish the FlatBufferBuilder. 67 * Create the buffer and finish the FlatBufferBuilder.
67 * 68 *
68 * After this the buffer can be extracted from the FlatBufferBuilder object. 69 * After this the buffer can be extracted from the FlatBufferBuilder object.
69 */ 70 */
70template <typename Buffer, typename BufferBuilder> 71template <typename Buffer, typename BufferBuilder>
@@ -88,10 +89,8 @@ template <class LocalBuffer, class ResourceBuffer>
88class GenericBufferAdaptor : public Sink::ApplicationDomain::BufferAdaptor 89class GenericBufferAdaptor : public Sink::ApplicationDomain::BufferAdaptor
89{ 90{
90public: 91public:
91 GenericBufferAdaptor() 92 GenericBufferAdaptor() : BufferAdaptor()
92 : BufferAdaptor()
93 { 93 {
94
95 } 94 }
96 95
97 virtual QVariant getProperty(const QByteArray &key) const 96 virtual QVariant getProperty(const QByteArray &key) const
@@ -112,8 +111,8 @@ public:
112 111
113 LocalBuffer const *mLocalBuffer; 112 LocalBuffer const *mLocalBuffer;
114 ResourceBuffer const *mResourceBuffer; 113 ResourceBuffer const *mResourceBuffer;
115 QSharedPointer<ReadPropertyMapper<LocalBuffer> > mLocalMapper; 114 QSharedPointer<ReadPropertyMapper<LocalBuffer>> mLocalMapper;
116 QSharedPointer<ReadPropertyMapper<ResourceBuffer> > mResourceMapper; 115 QSharedPointer<ReadPropertyMapper<ResourceBuffer>> mResourceMapper;
117}; 116};
118 117
119/** 118/**
@@ -121,23 +120,23 @@ public:
121 * It defines how values are split accross local and resource buffer. 120 * It defines how values are split accross local and resource buffer.
122 * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way. 121 * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way.
123 */ 122 */
124template<typename DomainType, typename ResourceBuffer, typename ResourceBuilder> 123template <typename DomainType, typename ResourceBuffer, typename ResourceBuilder>
125class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface 124class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface
126{ 125{
127 typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer; 126 typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer;
128 typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::BufferBuilder LocalBuilder; 127 typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::BufferBuilder LocalBuilder;
128
129public: 129public:
130 DomainTypeAdaptorFactory() : 130 DomainTypeAdaptorFactory()
131 mLocalMapper(Sink::ApplicationDomain::TypeImplementation<DomainType>::initializeReadPropertyMapper()), 131 : mLocalMapper(Sink::ApplicationDomain::TypeImplementation<DomainType>::initializeReadPropertyMapper()),
132 mResourceMapper(QSharedPointer<ReadPropertyMapper<ResourceBuffer> >::create()), 132 mResourceMapper(QSharedPointer<ReadPropertyMapper<ResourceBuffer>>::create()),
133 mLocalWriteMapper(Sink::ApplicationDomain::TypeImplementation<DomainType>::initializeWritePropertyMapper()), 133 mLocalWriteMapper(Sink::ApplicationDomain::TypeImplementation<DomainType>::initializeWritePropertyMapper()),
134 mResourceWriteMapper(QSharedPointer<WritePropertyMapper<ResourceBuilder> >::create()) 134 mResourceWriteMapper(QSharedPointer<WritePropertyMapper<ResourceBuilder>>::create()){};
135 {}; 135 virtual ~DomainTypeAdaptorFactory(){};
136 virtual ~DomainTypeAdaptorFactory() {};
137 136
138 /** 137 /**
139 * Creates an adaptor for the given domain and resource types. 138 * Creates an adaptor for the given domain and resource types.
140 * 139 *
141 * This returns by default a GenericBufferAdaptor initialized with the corresponding property mappers. 140 * This returns by default a GenericBufferAdaptor initialized with the corresponding property mappers.
142 */ 141 */
143 virtual QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> createAdaptor(const Sink::Entity &entity) Q_DECL_OVERRIDE 142 virtual QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> createAdaptor(const Sink::Entity &entity) Q_DECL_OVERRIDE
@@ -146,7 +145,7 @@ public:
146 const auto localBuffer = Sink::EntityBuffer::readBuffer<LocalBuffer>(entity.local()); 145 const auto localBuffer = Sink::EntityBuffer::readBuffer<LocalBuffer>(entity.local());
147 // const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); 146 // const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata());
148 147
149 auto adaptor = QSharedPointer<GenericBufferAdaptor<LocalBuffer, ResourceBuffer> >::create(); 148 auto adaptor = QSharedPointer<GenericBufferAdaptor<LocalBuffer, ResourceBuffer>>::create();
150 adaptor->mLocalBuffer = localBuffer; 149 adaptor->mLocalBuffer = localBuffer;
151 adaptor->mLocalMapper = mLocalMapper; 150 adaptor->mLocalMapper = mLocalMapper;
152 adaptor->mResourceBuffer = resourceBuffer; 151 adaptor->mResourceBuffer = resourceBuffer;
@@ -154,7 +153,8 @@ public:
154 return adaptor; 153 return adaptor;
155 } 154 }
156 155
157 virtual void createBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) Q_DECL_OVERRIDE 156 virtual void
157 createBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) Q_DECL_OVERRIDE
158 { 158 {
159 flatbuffers::FlatBufferBuilder localFbb; 159 flatbuffers::FlatBufferBuilder localFbb;
160 if (mLocalWriteMapper) { 160 if (mLocalWriteMapper) {
@@ -173,10 +173,8 @@ public:
173 173
174 174
175protected: 175protected:
176 QSharedPointer<ReadPropertyMapper<LocalBuffer> > mLocalMapper; 176 QSharedPointer<ReadPropertyMapper<LocalBuffer>> mLocalMapper;
177 QSharedPointer<ReadPropertyMapper<ResourceBuffer> > mResourceMapper; 177 QSharedPointer<ReadPropertyMapper<ResourceBuffer>> mResourceMapper;
178 QSharedPointer<WritePropertyMapper<LocalBuilder> > mLocalWriteMapper; 178 QSharedPointer<WritePropertyMapper<LocalBuilder>> mLocalWriteMapper;
179 QSharedPointer<WritePropertyMapper<ResourceBuilder> > mResourceWriteMapper; 179 QSharedPointer<WritePropertyMapper<ResourceBuilder>> mResourceWriteMapper;
180}; 180};
181
182