[Rock-dev] typelib and std::vector
Sylvain Joyeux
sylvain.joyeux at dfki.de
Thu Feb 3 15:41:52 CET 2011
On 01/26/2011 07:16 PM, Alexander Duda wrote:
> Hi
>
> how does typelib handle std::vectors when they are accessed from ruby?
> Are the following assumptions right?
>
> for std::vector<uint8_t> or similar:
> my_vector.to_a ---> copies the vector into a ruby array
> my_vector[i] --> not defined
> my_vector.each do |v| -->iterates over all fields without copying them
> my_vector.push s --> pushes the sample to the back of the vector
> --> How can I access a specific index without converting it to a ruby
> array?
I just pushed stuff to typelib master that implements random access on
std::vector. That should work now.
> for std::vector<CompoundType>
> my_vector is converted automatically to a ruby array
It happens only if there is a conversion registered for a field of
CompoundType, or for CompoundType itself.
For instance, if CompoundType was
struct CompoundType
{
double a;
double b;
};
then no conversion to array would occur. Now, if CompoundType is
struct CompoundType
{
base::Vector3d a;
base::Vector3d b;
};
then the conversion would occur, as base::Vector3d is represented in
Ruby by Eigen::Vector3 (from base/ruby_types)
--
Sylvain Joyeux (Dr.Ing.)
Space & Security Robotics
!!! Achtung, neue Telefonnummer!!!
Standort Bremen:
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany
Phone: +49 (0)421 178-454136
Fax: +49 (0)421 218-454150
E-Mail: robotik 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