From a2c082571f781f098fe4c2404ecfe03be63ff47d Mon Sep 17 00:00:00 2001 From: Ramin Yaghoubzadeh <ryaghoub@techfak.uni-bielefeld.de> Date: Thu, 9 Aug 2012 17:17:18 +0200 Subject: [PATCH] Bug fixes in C++ Implemented retraction handler. Replaced deprecated converter repository call. --- ipaacalib/cpp/build.xml | 2 +- ipaacalib/cpp/include/ipaaca/ipaaca.h | 10 ++++++++ ipaacalib/cpp/src/ipaaca.cc | 36 +++++++++++++++++++++------ ipaacalib/java/manifest.mf | 2 +- ipaacalib/python/ivy.xml | 8 +++--- resolve.sh | 2 ++ 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/ipaacalib/cpp/build.xml b/ipaacalib/cpp/build.xml index 75ed860..f205ed3 100644 --- a/ipaacalib/cpp/build.xml +++ b/ipaacalib/cpp/build.xml @@ -3,7 +3,7 @@ <import file="../../../hmibuild/build.xml" /> <target name="check-proto-files"> <echo message="Checking whether compiled protobuf files are already present..." /> - <available file="build/ipaaca.pb.h" property="pb.present"/> + <available file="build/ipaaca/ipaaca.pb.h" property="pb.present"/> </target> <target name="-proto-yes" depends="check-proto-files" if="pb.present"> <echo message="Built protobuf files found, skipping compilation" /> diff --git a/ipaacalib/cpp/include/ipaaca/ipaaca.h b/ipaacalib/cpp/include/ipaaca/ipaaca.h index 541ec59..89e8a32 100644 --- a/ipaacalib/cpp/include/ipaaca/ipaaca.h +++ b/ipaacalib/cpp/include/ipaaca/ipaaca.h @@ -241,6 +241,14 @@ class CallbackIUCommission: public rsb::patterns::Server::Callback<protobuf::IUC public: boost::shared_ptr<int> call(const std::string& methodName, boost::shared_ptr<protobuf::IUCommission> update); }; +class CallbackIURetraction: public rsb::patterns::Server::Callback<protobuf::IURetraction, int> { + protected: + Buffer* _buffer; + public: + CallbackIURetraction(Buffer* buffer); + public: + boost::shared_ptr<int> call(const std::string& methodName, boost::shared_ptr<protobuf::IURetraction> update); +}; class OutputBuffer: public Buffer { //, public boost::enable_shared_from_this<OutputBuffer> {//{{{ friend class IU; @@ -451,6 +459,7 @@ class IUInterface {//{{{ std::string _payload_type; // default is "MAP" std::string _owner_name; bool _committed; + bool _retracted; IUAccessMode _access_mode; bool _read_only; //boost::shared_ptr<Buffer> _buffer; @@ -556,6 +565,7 @@ class RemotePushIU: public IUInterface {//{{{ void _apply_update(IUPayloadUpdate::ptr update); void _apply_link_update(IULinkUpdate::ptr update); void _apply_commission(); + void _apply_retraction(); typedef boost::shared_ptr<RemotePushIU> ptr; };//}}} diff --git a/ipaacalib/cpp/src/ipaaca.cc b/ipaacalib/cpp/src/ipaaca.cc index 855acd3..f73a81a 100644 --- a/ipaacalib/cpp/src/ipaaca.cc +++ b/ipaacalib/cpp/src/ipaaca.cc @@ -22,19 +22,22 @@ void Initializer::initialize_ipaaca_rsb_if_needed() Factory::getInstance().setDefaultParticipantConfig(config); boost::shared_ptr<IUConverter> iu_converter(new IUConverter()); - stringConverterRepository()->registerConverter(iu_converter); + converterRepository<std::string>()->registerConverter(iu_converter); boost::shared_ptr<IUPayloadUpdateConverter> payload_update_converter(new IUPayloadUpdateConverter()); - stringConverterRepository()->registerConverter(payload_update_converter); + converterRepository<std::string>()->registerConverter(payload_update_converter); boost::shared_ptr<IULinkUpdateConverter> link_update_converter(new IULinkUpdateConverter()); - stringConverterRepository()->registerConverter(link_update_converter); + converterRepository<std::string>()->registerConverter(link_update_converter); boost::shared_ptr<ProtocolBufferConverter<protobuf::IUCommission> > iu_commission_converter(new ProtocolBufferConverter<protobuf::IUCommission> ()); - stringConverterRepository()->registerConverter(iu_commission_converter); - + converterRepository<std::string>()->registerConverter(iu_commission_converter); + + boost::shared_ptr<ProtocolBufferConverter<protobuf::IURetraction> > iu_retraction_converter(new ProtocolBufferConverter<protobuf::IURetraction> ()); + converterRepository<std::string>()->registerConverter(iu_retraction_converter); + boost::shared_ptr<IntConverter> int_converter(new IntConverter()); - stringConverterRepository()->registerConverter(int_converter); + converterRepository<std::string>()->registerConverter(int_converter); _initialized = true; //IPAACA_TODO("initialize all converters") @@ -666,6 +669,21 @@ void InputBuffer::_handle_iu_events(EventPtr event) call_iu_event_handlers(it->second, false, IU_COMMITTED, it->second->category() ); // // + } else if (type == "ipaaca::protobuf::IURetraction") { + boost::shared_ptr<protobuf::IURetraction> update = boost::static_pointer_cast<protobuf::IURetraction>(event->getData()); + it = _iu_store.find(update->uid()); + if (it == _iu_store.end()) { + IPAACA_INFO("Ignoring RETRACTED message for an IU that we did not fully receive before") + return; + } + // + it->second->_revision = update->revision(); + it->second->_apply_retraction(); + // remove from InputBuffer FIXME: this is a crossover between retracted and deleted behavior + _iu_store.erase(it->first); + // and call the handler. IU reference is still valid for this call, although removed from buffer. + call_iu_event_handlers(it->second, false, IU_COMMITTED, it->second->category() ); + // } else { std::cout << "(Unhandled Event type " << type << " !)" << std::endl; return; @@ -681,7 +699,7 @@ void InputBuffer::_handle_iu_events(EventPtr event) // IUInterface//{{{ IUInterface::IUInterface() -: _buffer(NULL), _committed(false) +: _buffer(NULL), _committed(false), _retracted(false) { } @@ -945,6 +963,10 @@ void RemotePushIU::_apply_commission() { _committed = true; } +void RemotePushIU::_apply_retraction() +{ + _retracted = true; +} void Payload::_remotely_enforced_wipe() { _store.clear(); diff --git a/ipaacalib/java/manifest.mf b/ipaacalib/java/manifest.mf index bd2397b..486cc6a 100644 --- a/ipaacalib/java/manifest.mf +++ b/ipaacalib/java/manifest.mf @@ -6,5 +6,5 @@ Specification-Title: IpaacaJava Specification-Version: 0.1 Specification-Vendor: ipaaca Implementation-Title: IpaacaJava -Implementation-Version: August 02 2012 01:27 PM +Implementation-Version: August 08 2012 11:03 AM Implementation-Vendor: ipaaca \ No newline at end of file diff --git a/ipaacalib/python/ivy.xml b/ipaacalib/python/ivy.xml index 9eb9889..954ee17 100644 --- a/ipaacalib/python/ivy.xml +++ b/ipaacalib/python/ivy.xml @@ -1,11 +1,11 @@ <ivy-module version="2.0"> <info organisation="ipaaca" module="IpaacaPython" /> <publications> - <artifact type="zip" ext="zip"/> + <artifact type="zip" ext="zip"/> </publications> <dependencies> - <dependency org="google" name="protobuf" rev="latest.release"/> - <dependency org="rsb" name="rsb" rev="latest.release"/> + <!-- dependency org="google" name="protobuf" rev="latest.release"/ --> + <!-- dependency org="rsb" name="rsb" rev="latest.release"/ --> </dependencies> - + </ivy-module> diff --git a/resolve.sh b/resolve.sh index 4802315..9fc0983 100755 --- a/resolve.sh +++ b/resolve.sh @@ -6,10 +6,12 @@ mkdir -p deps/bin mkdir -p deps/lib mkdir -p deps/include mkdir -p deps/scripts +mkdir -p deps/python for P in $PACKAGES; do cp -a ../$P/dist/bin/* deps/bin/ cp -a ../$P/dist/lib/* deps/lib/ cp -a ../$P/dist/include/* deps/include/ cp -a ../$P/dist/scripts/* deps/scripts/ + cp -a ../$P/dist/python/* deps/python/ done -- GitLab