class Syskit::BoundDataService
Representation of a data service as provided by an actual component
It is usually created from a Models::BoundDataService instance using Syskit::Models::BoundDataService#bind, or simply by calling the task's service access (i.e. the _srv helpers or {Component#find_data_service)
The model-level bound data service corresponding to self is {#model}. The data service model is therefore {#model}.{#model}. The component instance this data service is bound to is {#component}.
{#component}.{#model} is guaranteed to be {#model}.{#component}
Constants
- DRoby
Attributes
@return [Component] The component instance we are bound to
@return [Models::BoundDataService] the data service we are an
instance of. self is basically model.bind(component)
Public Class Methods
# File lib/syskit/bound_data_service.rb, line 43 def initialize(component, model) @component, @model = component, model if !component.kind_of?(Component) raise "expected a component instance, got #{component}" end if !model.kind_of?(Models::BoundDataService) raise "expected a model of a bound data service, got #{model}" end end
Public Instance Methods
# File lib/syskit/bound_data_service.rb, line 39 def ==(other) eql?(other) end
# File lib/syskit/bound_data_service.rb, line 117 def as(service) result = self.dup result.instance_variable_set(:@model, model.as(service)) result end
# File lib/syskit/bound_data_service.rb, line 109 def as_plan component end
Automatically computes connections from the output ports of self to the given port or to the input ports of the given component
(see Syskit.connect)
# File lib/syskit/bound_data_service.rb, line 62 def connect_to(port_or_component, policy = Hash.new) Syskit.connect(self, port_or_component, policy) end
# File lib/syskit/bound_data_service.rb, line 105 def data_reader(*names) component.data_reader(model.port_mappings_for_task[names.first], *names[1..-1]) end
# File lib/syskit/bound_data_service.rb, line 101 def data_writer(*names) component.data_writer(model.port_mappings_for_task[names.first], *names[1..-1]) end
# File lib/syskit/bound_data_service.rb, line 156 def droby_dump(peer) DRoby.new(peer.dump(component), peer.dump(model)) end
# File lib/syskit/bound_data_service.rb, line 93 def each_fullfilled_model(&block) model.each_fullfilled_model(&block) end
# File lib/syskit/bound_data_service.rb, line 70 def each_slave_data_service(&block) component.model.each_slave_data_service(self.model) do |slave_m| yield(slave_m.bind(component)) end end
# File lib/syskit/bound_data_service.rb, line 33 def eql?(other) other.kind_of?(self.class) && other.component == component && other.model == model end
Looks for a slave data service by name
# File lib/syskit/bound_data_service.rb, line 84 def find_data_service(name) component.model.each_slave_data_service(self.model) do |slave_m| if slave_m.name == name return slave_m.bind(component) end end nil end
# File lib/syskit/bound_data_service.rb, line 145 def find_through_method_missing(m, args) MetaRuby::DSLs.find_through_method_missing( self, m, args, '_srv'.freeze => :find_data_service) || super end
# File lib/syskit/bound_data_service.rb, line 97 def fullfills?(*args) model.fullfills?(*args) end
# File lib/syskit/bound_data_service.rb, line 76 def has_data_service?(name) component.model.each_slave_data_service(self.model) do |slave_m| return true if slave_m.name == name end false end
# File lib/syskit/bound_data_service.rb, line 139 def has_through_method_missing?(m) MetaRuby::DSLs.has_through_method_missing?( self, m, '_srv'.freeze => :has_data_service?) || super end
# File lib/syskit/bound_data_service.rb, line 29 def hash [self.class, component, model].hash end
# File lib/syskit/bound_data_service.rb, line 127 def inspect; to_s end
The data service name
@return [String]
# File lib/syskit/bound_data_service.rb, line 25 def name; model.name end
(see Syskit::Component#self_port_to_component_port)
# File lib/syskit/bound_data_service.rb, line 54 def self_port_to_component_port(port) return component.find_port(model.port_mappings_for_task[port.name]) end
# File lib/syskit/bound_data_service.rb, line 66 def short_name "#{component}:#{model.short_name}" end
Generates the InstanceRequirements
object that represents self best
@return [Syskit::InstanceRequirements]
# File lib/syskit/bound_data_service.rb, line 133 def to_instance_requirements req = component.to_instance_requirements req.select_service(model) req end
# File lib/syskit/bound_data_service.rb, line 123 def to_s "#<BoundDataService: #{component.name}.#{model.name}>" end
# File lib/syskit/bound_data_service.rb, line 113 def to_task component end