Module: Syskit::DataService

Included in:
Models::Component
Defined in:
lib/syskit/data_service.rb

Instance Method Summary collapse

Instance Method Details

#using_data_service?(source_name) ⇒ Boolean

Returns true if at least one port of the given service (designated by its name) is connected to something.

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/syskit/data_service.rb', line 6

def using_data_service?(source_name)
    service = model.find_data_service(source_name)
    inputs  = service.each_task_input_port.map(&:name)
    outputs = service.each_task_output_port.map(&:name)

    each_source do |output|
        description = output[self, Flows::DataFlow]
        if description.any? { |(_, to), _| inputs.include?(to) }
            return true
        end
    end
    each_sink do |input, description|
        if description.any? { |(from, _), _| outputs.include?(from) }
            return true
        end
    end
    false
end