From 7ef6a812b90045f3e6bd080a7f465617eb2b26d7 Mon Sep 17 00:00:00 2001 From: Herwin van Welbergen <hvanwelbergen@techfak.uni-bielefeld.de> Date: Fri, 23 Jan 2015 17:10:54 +0100 Subject: [PATCH] Bugfixes for resend+test program --- ipaacalib/cpp/CMakeLists.txt | 3 ++ ipaacalib/cpp/include/ipaaca/ipaaca.h | 5 +- ipaacalib/cpp/src/ipaaca-test-resend.cc | 63 +++++++++++++++++++++++++ ipaacalib/cpp/src/ipaaca.cc | 13 +++-- 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 ipaacalib/cpp/src/ipaaca-test-resend.cc diff --git a/ipaacalib/cpp/CMakeLists.txt b/ipaacalib/cpp/CMakeLists.txt index e19d222..ca16bb2 100644 --- a/ipaacalib/cpp/CMakeLists.txt +++ b/ipaacalib/cpp/CMakeLists.txt @@ -162,6 +162,9 @@ target_link_libraries(ipaaca ${LIBS}) #add_executable (ipaaca-test-main src/ipaaca-test-main.cc) #target_link_libraries (ipaaca-test-main ${LIBS}) +#add_executable (ipaaca-test-resend src/ipaaca-test-resend.cc) +#target_link_libraries (ipaaca-test-resend ipaaca ${LIBS}) + set(DEFAULT_BIN_SUBDIR bin) set(DEFAULT_LIB_SUBDIR lib) set(DEFAULT_DATA_SUBDIR share/data) diff --git a/ipaacalib/cpp/include/ipaaca/ipaaca.h b/ipaacalib/cpp/include/ipaaca/ipaaca.h index 7372427..85a012b 100644 --- a/ipaacalib/cpp/include/ipaaca/ipaaca.h +++ b/ipaacalib/cpp/include/ipaaca/ipaaca.h @@ -539,10 +539,11 @@ IPAACA_HEADER_EXPORT class InputBuffer: public Buffer { //, public boost::enable 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-test-resend.cc b/ipaacalib/cpp/src/ipaaca-test-resend.cc new file mode 100644 index 0000000..a1af0f5 --- /dev/null +++ b/ipaacalib/cpp/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; + } +} + + + diff --git a/ipaacalib/cpp/src/ipaaca.cc b/ipaacalib/cpp/src/ipaaca.cc index 960be78..7c4f3ef 100644 --- a/ipaacalib/cpp/src/ipaaca.cc +++ b/ipaacalib/cpp/src/ipaaca.cc @@ -505,7 +505,8 @@ IPAACA_EXPORT boost::shared_ptr<int> CallbackIUResendRequest::call(const std::st if ((update->has_hidden_scope_name() == true)&&(update->hidden_scope_name().compare("") != 0)){ //_buffer->call_iu_event_handlers(iu, true, IU_UPDATED, update->hidden_scope_name()); revision_t revision = iu->revision(); - + + iu->_publish_resend(iu, update->hidden_scope_name()); return boost::shared_ptr<int>(new int(revision)); @@ -720,35 +721,41 @@ IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::s :Buffer(basename, "IB") { _channel = "default"; - + _create_category_listener_if_needed(_uuid); _create_category_listener_if_needed(category_interest1); + triggerResend = false; } IPAACA_EXPORT InputBuffer::InputBuffer(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2) :Buffer(basename, "IB") { _channel = "default"; - + _create_category_listener_if_needed(_uuid); _create_category_listener_if_needed(category_interest1); _create_category_listener_if_needed(category_interest2); + 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") { _channel = "default"; + _create_category_listener_if_needed(_uuid); _create_category_listener_if_needed(category_interest1); _create_category_listener_if_needed(category_interest2); _create_category_listener_if_needed(category_interest3); + 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") { _channel = "default"; + _create_category_listener_if_needed(_uuid); _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(category_interest4); + triggerResend = false; } IPAACA_EXPORT InputBuffer::ptr InputBuffer::create(const BufferConfiguration& bufferconfiguration) -- GitLab