class Orocos::RobyPlugin::TaskAllocationFailed

Exception raised when we could not find concrete implementations for abstract tasks that are in the plan

Attributes

abstract_tasks[R]

A task to [parents, candidates] mapping for the failed allocations

Public Class Methods

new(tasks) click to toggle source

Creates a new TaskAllocationFailed exception for the given tasks.

tasks is a mapping from the abstract tasks to the possible candidate implementation for these tasks, i.e.

t => [model0, model1, ...]
# File lib/orocos/roby/exceptions.rb, line 262
def initialize(tasks)
    @abstract_tasks = Hash.new

    tasks.each do |abstract_task, candidates|
        parents = abstract_task.
            enum_for(:each_parent_object, Roby::TaskStructure::Dependency).
            map do |parent_task|
                options = parent_task[abstract_task,
                    Roby::TaskStructure::Dependency]
                [options[:roles], parent_task]
            end
        abstract_tasks[abstract_task] = [parents, candidates]
    end
end

Public Instance Methods

pretty_print(pp) click to toggle source
# File lib/orocos/roby/exceptions.rb, line 277
def pretty_print(pp)
    pp.text "cannot find a concrete implementation for #{abstract_tasks.size} task(s)"

    abstract_tasks.each do |task, (parents, candidates)|
        pp.breakable
        pp.text "#{task.to_s.gsub(/Orocos::RobyPlugin::/, '')}"
        pp.nest(2) do
            pp.breakable
            if candidates
                if candidates.empty?
                    pp.text "no candidates"
                else
                    pp.text "#{candidates.size} candidates"
                    pp.nest(2) do
                        pp.breakable
                        pp.seplist(candidates) do |c_task|
                            pp.text "#{c_task.short_name}"
                        end
                    end
                end
            end
            pp.breakable
            pp.seplist(parents) do |parent|
                role, parent = parent
                pp.text "child #{role.to_a.first} of #{parent.to_s.gsub(/Orocos::RobyPlugin::/, '')}"
            end
        end
    end
end