[Rock-dev] non linear behaviour of typelib
Alexander Duda
Alexander.Duda at dfki.de
Thu May 10 11:04:02 CEST 2012
the typelib ruby binding has some non linear behaviour if different
setter and getter are used.
sample = Types::Base::Samples::Frame::FramePair.new
time_first = Time.now-1000
sample.time = Time.now
sample.first.time = time_first
#raw access is needed to get the element type
element =
sample.first.raw_get_field("attributes").element_t.new
element.data_ = "payload"
element.name_ = "first"
sample.first.attributes << element
element.name_ = "second"
#the same element is pushed twice
sample.first.attributes << element
#a copy is pushed
sample.first.attributes << element.dup
#there are three elements in the array
sample.first.attributes.size
#here the size is 0 because typelib is returning a
different array which
#is not up-to-date
sample.first["attributes"].size
sample.first.get_field["attributes"].size
sample.first.get_raw_field["attributes"].size
If the sample is written to a port only two elements will be transferred
because someone is calling uniq on the array which leads to confusion.
Maybe there could be a warning if someone is pushing the same element twice.
Alex
--
Dipl.-Ing. Alexander Duda
Unterwasserrobotik
DFKI Bremen
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany
Phone: +49 (0)421 178-456620
Fax: +49 (0)421 178-454150
E-Mail: alexander.duda at dfki.de
Weitere Informationen: http://www.dfki.de/robotik
-----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.: DE 148646973
Steuernummer: 19/673/0060/3
More information about the Rock-dev
mailing list