From 2cc32bf47f12f5d632abaaf75c88760f21122b54 Mon Sep 17 00:00:00 2001
From: Ramin Yaghoubzadeh <ryaghoubzadeh@uni-bielefeld.de>
Date: Fri, 30 Jan 2015 16:24:37 +0100
Subject: [PATCH] Manually merged master's 7ef6a812 into refactored code base

It is Herwin's resend fix. Test sources are present but not
enabled during library build (will have to implement test build asap).
---
 ipaacalib/cpp/include/ipaaca/ipaaca-buffers.h |  4 +-
 ipaacalib/cpp/src/ipaaca-buffers.cc           |  8 +++
 .../cpp/{ => test}/src/ipaaca-test-main.cc    |  0
 ipaacalib/cpp/test/src/ipaaca-test-resend.cc  | 63 +++++++++++++++++++
 4 files changed, 73 insertions(+), 2 deletions(-)
 rename ipaacalib/cpp/{ => test}/src/ipaaca-test-main.cc (100%)
 create mode 100644 ipaacalib/cpp/test/src/ipaaca-test-resend.cc

diff --git a/ipaacalib/cpp/include/ipaaca/ipaaca-buffers.h b/ipaacalib/cpp/include/ipaaca/ipaaca-buffers.h
index d62ee0d..2c4fe44 100644
--- a/ipaacalib/cpp/include/ipaaca/ipaaca-buffers.h
+++ b/ipaacalib/cpp/include/ipaaca/ipaaca-buffers.h
@@ -260,10 +260,10 @@ IPAACA_HEADER_EXPORT class IUEventHandler {//{{{
 			IPAACA_HEADER_EXPORT InputBuffer(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2, const std::string& category_interest3, const std::string& category_interest4);
 
 			IPAACA_MEMBER_VAR_EXPORT bool triggerResend;
-			IPAACA_HEADER_EXPORT void set_resend(bool resendActive);
-			IPAACA_HEADER_EXPORT bool get_resend();
 
 		public:
+			IPAACA_HEADER_EXPORT void set_resend(bool resendActive);
+			IPAACA_HEADER_EXPORT bool get_resend();
 			IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const BufferConfiguration& bufferconfiguration);
 			IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const std::string& basename, const std::set<std::string>& category_interests);
 			IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const std::string& basename, const std::vector<std::string>& category_interests);
diff --git a/ipaacalib/cpp/src/ipaaca-buffers.cc b/ipaacalib/cpp/src/ipaaca-buffers.cc
index dacb67f..ec39fb2 100644
--- a/ipaacalib/cpp/src/ipaaca-buffers.cc
+++ b/ipaacalib/cpp/src/ipaaca-buffers.cc
@@ -538,6 +538,8 @@ IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::s
 	_channel = "default";
 
 	_create_category_listener_if_needed(category_interest1);
+	_create_category_listener_if_needed(_uuid);
+	triggerResend = false;
 }
 IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2)
 :Buffer(basename, "IB")
@@ -546,6 +548,8 @@ IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::s
 
 	_create_category_listener_if_needed(category_interest1);
 	_create_category_listener_if_needed(category_interest2);
+	_create_category_listener_if_needed(_uuid);
+	triggerResend = false;
 }
 IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2, const std::string& category_interest3)
 :Buffer(basename, "IB")
@@ -555,6 +559,8 @@ IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::s
 	_create_category_listener_if_needed(category_interest1);
 	_create_category_listener_if_needed(category_interest2);
 	_create_category_listener_if_needed(category_interest3);
+	_create_category_listener_if_needed(_uuid);
+	triggerResend = false;
 }
 IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2, const std::string& category_interest3, const std::string& category_interest4)
 :Buffer(basename, "IB")
@@ -565,6 +571,8 @@ IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::s
 	_create_category_listener_if_needed(category_interest2);
 	_create_category_listener_if_needed(category_interest3);
 	_create_category_listener_if_needed(category_interest4);
+	_create_category_listener_if_needed(_uuid);
+	triggerResend = false;
 }
 
 IPAACA_EXPORT InputBuffer::ptr InputBuffer::create(const BufferConfiguration& bufferconfiguration)
diff --git a/ipaacalib/cpp/src/ipaaca-test-main.cc b/ipaacalib/cpp/test/src/ipaaca-test-main.cc
similarity index 100%
rename from ipaacalib/cpp/src/ipaaca-test-main.cc
rename to ipaacalib/cpp/test/src/ipaaca-test-main.cc
diff --git a/ipaacalib/cpp/test/src/ipaaca-test-resend.cc b/ipaacalib/cpp/test/src/ipaaca-test-resend.cc
new file mode 100644
index 0000000..a1af0f5
--- /dev/null
+++ b/ipaacalib/cpp/test/src/ipaaca-test-resend.cc
@@ -0,0 +1,63 @@
+/*
+ * This file is part of IPAACA, the
+ *  "Incremental Processing Architecture
+ *   for Artificial Conversational Agents".  
+ *
+ * Copyright (c) 2009-2013 Sociable Agents Group
+ *                         CITEC, Bielefeld University   
+ *
+ * http://opensource.cit-ec.de/projects/ipaaca/
+ * http://purl.org/net/ipaaca
+ *
+ * This file may be licensed under the terms of of the
+ * GNU Lesser General Public License Version 3 (the ``LGPL''),
+ * or (at your option) any later version.
+ *
+ * Software distributed under the License is distributed
+ * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the LGPL for the specific language
+ * governing rights and limitations.
+ *
+ * You should have received a copy of the LGPL along with this
+ * program. If not, go to http://www.gnu.org/licenses/lgpl.html
+ * or write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  
+ *
+ * The development of this software was supported by the
+ * Excellence Cluster EXC 277 Cognitive Interaction Technology.
+ * The Excellence Cluster EXC 277 is a grant of the Deutsche
+ * Forschungsgemeinschaft (DFG) in the context of the German
+ * Excellence Initiative.
+ */
+
+#include <../include/ipaaca/ipaaca.h>
+#include <typeinfo>
+#include <iostream>
+
+using namespace ipaaca;
+
+void my_first_iu_handler(IUInterface::ptr iu, IUEventType type, bool local)
+{
+	std::cout<<"Update!"<<std::endl;	
+}
+
+int main() {
+	try{
+		OutputBuffer::ptr output_buffer = OutputBuffer::create("Tester");
+		IU::ptr iu = IU::create("cat1");
+		output_buffer->add(iu);
+		
+		InputBuffer::ptr input_buffer = InputBuffer::create("InputTester","cat1");
+		input_buffer->set_resend(true);
+		input_buffer->register_handler(my_first_iu_handler);
+		iu->payload()["key"]="Dummy";
+		sleep(1);
+		std::cout<<"Input buffer #of ius: "<<input_buffer->get_ius().size()<<std::endl;
+		
+	} catch (ipaaca::Exception& e) {
+		std::cout << "== IPAACA EXCEPTION == " << e.what() << std::endl;
+	}
+}
+
+
+
-- 
GitLab