Class: Rclrb::Fields::AtomicField
- Inherits:
-
Object
- Object
- Rclrb::Fields::AtomicField
- Defined in:
- lib/rclrb/fields.rb
Instance Attribute Summary collapse
-
#ffi_type ⇒ Object
readonly
Returns the value of attribute ffi_type.
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#init_value ⇒ Object
readonly
Returns the value of attribute init_value.
Instance Method Summary collapse
- #array_field ⇒ Object
- #create_from_dict(v) ⇒ Object
- #destroy_ros_message(data) ⇒ Object
- #ffi_size ⇒ Object
- #fill_ros_message(data, index, value) ⇒ Object
- #fill_ros_message_array(array_pointer, value) ⇒ Object
-
#initialize(init_value, field_name, ffi_type, array_reader, array_writter) ⇒ AtomicField
constructor
A new instance of AtomicField.
- #is_atomic ⇒ Object
- #parse_ros_message(data) ⇒ Object
- #parse_ros_message_array(data, length) ⇒ Object
Constructor Details
#initialize(init_value, field_name, ffi_type, array_reader, array_writter) ⇒ AtomicField
Returns a new instance of AtomicField.
26 27 28 29 30 31 32 33 |
# File 'lib/rclrb/fields.rb', line 26 def initialize(init_value, field_name, ffi_type, array_reader, array_writter) @init_value = init_value @field_name = "Rclrb::Fields::#{field_name}" @ffi_type = ffi_type @memory_size = FFI::type_size @ffi_type @array_reader = array_reader @array_writter = array_writter end |
Instance Attribute Details
#ffi_type ⇒ Object (readonly)
Returns the value of attribute ffi_type.
25 26 27 |
# File 'lib/rclrb/fields.rb', line 25 def ffi_type @ffi_type end |
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
25 26 27 |
# File 'lib/rclrb/fields.rb', line 25 def field_name @field_name end |
#init_value ⇒ Object (readonly)
Returns the value of attribute init_value.
25 26 27 |
# File 'lib/rclrb/fields.rb', line 25 def init_value @init_value end |
Instance Method Details
#array_field ⇒ Object
37 38 39 40 |
# File 'lib/rclrb/fields.rb', line 37 def array_field() @array_field = ArrayField.new(self) unless defined?(@array_field) return @array_field end |
#create_from_dict(v) ⇒ Object
34 35 36 |
# File 'lib/rclrb/fields.rb', line 34 def create_from_dict v return v end |
#destroy_ros_message(data) ⇒ Object
61 62 |
# File 'lib/rclrb/fields.rb', line 61 def (data) end |
#ffi_size ⇒ Object
63 64 65 |
# File 'lib/rclrb/fields.rb', line 63 def ffi_size() return @memory_size end |
#fill_ros_message(data, index, value) ⇒ Object
51 52 53 |
# File 'lib/rclrb/fields.rb', line 51 def (data, index, value) data[index] = value end |
#fill_ros_message_array(array_pointer, value) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/rclrb/fields.rb', line 54 def (array_pointer, value) if @array_writter return array_pointer.send @array_writter, 0, value else Fields.(array_pointer, value, self.ffi_size) { |ptr, value| ptr.put @ffi_type, 0, value } end end |
#is_atomic ⇒ Object
66 67 68 |
# File 'lib/rclrb/fields.rb', line 66 def is_atomic return true end |
#parse_ros_message(data) ⇒ Object
41 42 43 |
# File 'lib/rclrb/fields.rb', line 41 def (data) return data end |
#parse_ros_message_array(data, length) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rclrb/fields.rb', line 44 def (data, length) if @array_reader return data.send @array_reader, 0, length else return Fields.__generic_parse_array(data, length, self.ffi_size) { |ptr| ptr.get(@ffi_type, 0) } end end |