Class: Roby::Coordination::Task

Inherits:
TaskBase show all
Defined in:
lib/roby/coordination/task.rb

Overview

Representation of a toplevel task in an execution context instance

Direct Known Subclasses

Models::Root

Instance Attribute Summary collapse

Attributes inherited from TaskBase

#execution_context, #model

Instance Method Summary collapse

Methods inherited from TaskBase

#find_child, #find_event, #find_through_method_missing, #has_through_method_missing?, #to_coordination_task

Constructor Details

#initialize(execution_context, model) ⇒ Task

Returns a new instance of Task.



11
12
13
14
# File 'lib/roby/coordination/task.rb', line 11

def initialize(execution_context, model)
    super(execution_context, model)
    @task = nil
end

Instance Attribute Details

#tasknil, Roby::Task (readonly)

Returns the actual Roby task this is representing.

Returns:

  • (nil, Roby::Task)

    the actual Roby task this is representing



9
10
11
# File 'lib/roby/coordination/task.rb', line 9

def task
  @task
end

Instance Method Details

#bind(task) ⇒ Object

Associate this coordination task to the given roby task

This sets the next value returned by #resolve

Parameters:



25
26
27
# File 'lib/roby/coordination/task.rb', line 25

def bind(task)
    @task = task
end

#nameObject



42
43
44
# File 'lib/roby/coordination/task.rb', line 42

def name
    model.name
end

#resolveRoby::Task

Resolves this to the actual task object

Returns:

Raises:

  • ResolvingUnboundObject



33
34
35
36
37
38
39
40
# File 'lib/roby/coordination/task.rb', line 33

def resolve
    unless task
        raise ResolvingUnboundObject,
              "trying to resolve #{self}, which is not (yet) bound"
    end

    task
end

#root_taskObject



16
17
18
# File 'lib/roby/coordination/task.rb', line 16

def root_task
    self
end

#to_sObject



46
47
48
# File 'lib/roby/coordination/task.rb', line 46

def to_s
    "Task[#{model.model}]"
end