Module: Roby::TaskStructure::PlannedBy::Extension

Defined in:
lib/roby/task_structure/planned_by.rb

Instance Method Summary collapse

Instance Method Details

#planned_by(task, replace: false, optional: false, plan_early: true) ⇒ Object

Set task as the planning task of self



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/roby/task_structure/planned_by.rb', line 19

def planned_by(task, replace: false, optional: false, plan_early: true)
    if task.respond_to?(:as_plan)
        task = task.as_plan
    end

    if old = planning_task
        if replace
            remove_planning_task(old)
        else
            raise ArgumentError, "this task already has a planner"
        end
    end
    add_planning_task(task, optional: optional, plan_early: true)
    if !plan_early
        task.schedule_as(self)
    end

    task
end

#planned_taskObject

Returns the first child enumerated by planned_tasks. This is a convenience method that can be used if it is known that the planning task is only planning for one single task (a pretty common case)



13
14
15
# File 'lib/roby/task_structure/planned_by.rb', line 13

def planned_task
    each_in_neighbour_merged(PlannedBy, intrusive: true).first
end

#planned_tasksObject

The set of tasks which are planned by this one



17
# File 'lib/roby/task_structure/planned_by.rb', line 17

def planned_tasks; parent_objects(PlannedBy) end