From 9ae4fcadc9200f1c9cf6322b98449b0de69112ac Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 1 Jun 2015 09:26:31 +0200 Subject: Generalized creating the buffer. --- examples/dummyresource/domainadaptor.cpp | 56 ++++++++++---------------------- examples/dummyresource/domainadaptor.h | 19 ++++++++++- 2 files changed, 36 insertions(+), 39 deletions(-) (limited to 'examples') diff --git a/examples/dummyresource/domainadaptor.cpp b/examples/dummyresource/domainadaptor.cpp index 8649bc3..67595af 100644 --- a/examples/dummyresource/domainadaptor.cpp +++ b/examples/dummyresource/domainadaptor.cpp @@ -1,23 +1,29 @@ +/* + * Copyright (C) 2015 Christian Mollekopf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ #include "domainadaptor.h" -#include -#include - #include "dummycalendar_generated.h" -#include "event_generated.h" -#include "entity_generated.h" -#include "metadata_generated.h" -#include "domainadaptor.h" -#include "log.h" -#include using namespace DummyCalendar; using namespace flatbuffers; - - - DummyEventAdaptorFactory::DummyEventAdaptorFactory() : DomainTypeAdaptorFactory() { @@ -32,29 +38,3 @@ DummyEventAdaptorFactory::DummyEventAdaptorFactory() }); } - -void DummyEventAdaptorFactory::createBuffer(const Akonadi2::ApplicationDomain::Event &event, flatbuffers::FlatBufferBuilder &fbb) -{ - flatbuffers::FlatBufferBuilder localFbb; - if (mLocalWriteMapper) { - auto pos = createBufferPart(event, localFbb, *mLocalWriteMapper); - Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, pos); - flatbuffers::Verifier verifier(localFbb.GetBufferPointer(), localFbb.GetSize()); - if (!verifier.VerifyBuffer()) { - Warning() << "Created invalid local buffer"; - } - } - - flatbuffers::FlatBufferBuilder resFbb; - if (mResourceWriteMapper) { - auto pos = createBufferPart(event, resFbb, *mResourceWriteMapper); - DummyCalendar::FinishDummyEventBuffer(resFbb, pos); - flatbuffers::Verifier verifier(resFbb.GetBufferPointer(), resFbb.GetSize()); - if (!verifier.VerifyBuffer()) { - Warning() << "Created invalid resource buffer"; - } - } - - Akonadi2::EntityBuffer::assembleEntityBuffer(fbb, 0, 0, resFbb.GetBufferPointer(), resFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); -} - diff --git a/examples/dummyresource/domainadaptor.h b/examples/dummyresource/domainadaptor.h index 0490387..8b6d96b 100644 --- a/examples/dummyresource/domainadaptor.h +++ b/examples/dummyresource/domainadaptor.h @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2015 Christian Mollekopf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ #pragma once #include "common/domainadaptor.h" @@ -10,5 +28,4 @@ class DummyEventAdaptorFactory : public DomainTypeAdaptorFactory