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

component[R]

@return [Component] The component instance we are bound to

model[R]

@return [Models::BoundDataService] the data service we are an

instance of. self is basically model.bind(component)

Public Class Methods

new(component, model) click to toggle source
# 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

==(other) click to toggle source
# File lib/syskit/bound_data_service.rb, line 39
def ==(other)
    eql?(other)
end
as(service) click to toggle source
# 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
as_plan() click to toggle source
# File lib/syskit/bound_data_service.rb, line 109
def as_plan
    component
end
connect_to(port_or_component, policy = Hash.new) click to toggle source

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
data_reader(*names) click to toggle source
# 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
data_writer(*names) click to toggle source
# 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
droby_dump(peer) click to toggle source
# File lib/syskit/bound_data_service.rb, line 156
def droby_dump(peer)
    DRoby.new(peer.dump(component), peer.dump(model))
end
each_fullfilled_model(&block) click to toggle source
# File lib/syskit/bound_data_service.rb, line 93
def each_fullfilled_model(&block)
    model.each_fullfilled_model(&block)
end
each_slave_data_service() { |bind| ... } click to toggle source
# 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
eql?(other) click to toggle source
# File lib/syskit/bound_data_service.rb, line 33
def eql?(other)
    other.kind_of?(self.class) &&
        other.component == component &&
        other.model == model
end
find_data_service(name) click to toggle source

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
find_through_method_missing(m, args) click to toggle source
# 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
fullfills?(*args) click to toggle source
# File lib/syskit/bound_data_service.rb, line 97
def fullfills?(*args)
    model.fullfills?(*args)
end
has_data_service?(name) click to toggle source
# 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
has_through_method_missing?(m) click to toggle source
# 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
hash() click to toggle source
# File lib/syskit/bound_data_service.rb, line 29
def hash
    [self.class, component, model].hash
end
inspect() click to toggle source
# File lib/syskit/bound_data_service.rb, line 127
def inspect; to_s end
name() click to toggle source

The data service name

@return [String]

# File lib/syskit/bound_data_service.rb, line 25
def name;
    model.name
end
self_port_to_component_port(port) click to toggle source

(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
short_name() click to toggle source
# File lib/syskit/bound_data_service.rb, line 66
def short_name
    "#{component}:#{model.short_name}"
end
to_instance_requirements() click to toggle source

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
to_s() click to toggle source
# File lib/syskit/bound_data_service.rb, line 123
def to_s
    "#<BoundDataService: #{component.name}.#{model.name}>"
end
to_task() click to toggle source
# File lib/syskit/bound_data_service.rb, line 113
def to_task
    component
end