class Syskit::NetworkGeneration::DataFlowComputation::Trigger

Stores propagation information for the algorithm

This class stores a list of ports on which changes will should cause a call to propagate_task. It is used as values in Syskit::NetworkGeneration::DataFlowComputation#triggering_connections

Constants

USE_ALL
USE_ANY
USE_PARTIAL

Attributes

mode[R]

The propagation mode, as one of USE_ALL, USE_ANY and USE_PARTIAL constants. See constant documentation for more details.

ports[R]

The list of triggering ports, as [task, port_name] pairs

Public Class Methods

new(ports, mode) click to toggle source
# File lib/syskit/network_generation/dataflow_computation.rb, line 96
def initialize(ports, mode)
    @ports, @mode = ports, mode
end

Public Instance Methods

ports_to_propagate(state) click to toggle source

Called by the algorithm to determine which ports should be propagated given a certain algorithm state state.

state is a DataFlowComputation object. Only the has_information_for_port? and has_final_information_for_port? methods are used.

# File lib/syskit/network_generation/dataflow_computation.rb, line 106
def ports_to_propagate(state)
    if ports.empty?
        return [], false 
    end

    complete = false
    candidates = []
    ports.each do |args|
        if state.has_final_information_for_port?(*args)
            complete = true
            candidates << args
        elsif mode == USE_ALL
            return [], false
        elsif state.has_information_for_port?(*args)
            complete = false
            if mode == USE_PARTIAL
                candidates << args
            end
        end
    end

    if mode == USE_ALL
        if !complete
            return []
        end
        return ports, true
    else
        return candidates, complete
    end
end
pretty_print(pp) click to toggle source
# File lib/syskit/network_generation/dataflow_computation.rb, line 142
def pretty_print(pp)
    mode = %w{ALL ANY PARTIAL}[self.mode]
    pp.text mode
    pp.breakable
    pp.seplist(ports) do |portdef|
        task, port = *portdef
        pp.text "#{task}.#{port}"
    end
end
to_s() click to toggle source
# File lib/syskit/network_generation/dataflow_computation.rb, line 137
def to_s
    modes = %w{ALL ANY PARTIAL}
    "#<Trigger: mode=#{modes[mode]} ports=#{ports.map { |t, p| "#{t}.#{p}" }.sort.join(",")}>"
end