Class: Roby::Coordination::TaskBase
- Defined in:
- lib/roby/coordination/task_base.rb
Overview
Base functionality for task-like objects in coordination models (Task, Child)
Instance Attribute Summary collapse
-
#execution_context ⇒ Base
readonly
The underlying execution context.
- #model ⇒ Coordination::Models::Task readonly
Instance Method Summary collapse
- #find_child(role, child_model = nil) ⇒ Object
- #find_event(symbol) ⇒ Object
-
#initialize(execution_context, model) ⇒ TaskBase
constructor
A new instance of TaskBase.
-
#resolve ⇒ Object
Method that must be reimplemented in the task objects actually used in the coordination primitives.
- #to_coordination_task(task_model) ⇒ Object
Constructor Details
#initialize(execution_context, model) ⇒ TaskBase
Returns a new instance of TaskBase.
15 16 17 18 |
# File 'lib/roby/coordination/task_base.rb', line 15 def initialize(execution_context, model) @execution_context = execution_context @model = model end |
Instance Attribute Details
#execution_context ⇒ Base (readonly)
Returns the underlying execution context.
11 12 13 |
# File 'lib/roby/coordination/task_base.rb', line 11 def execution_context @execution_context end |
#model ⇒ Coordination::Models::Task (readonly)
13 14 15 |
# File 'lib/roby/coordination/task_base.rb', line 13 def model @model end |
Instance Method Details
#find_child(role, child_model = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/roby/coordination/task_base.rb', line 26 def find_child(role, child_model = nil) child_model ||= model.find_child_model(role) unless child_model begin task = self.resolve if child_task = task.find_child_from_role(role) child_model = child_task.model end rescue ResolvingUnboundObject end end if child = model.find_child(role, child_model) execution_context.instance_for(child) end end |
#find_event(symbol) ⇒ Object
43 44 45 46 47 |
# File 'lib/roby/coordination/task_base.rb', line 43 def find_event(symbol) if event = model.find_event(symbol) execution_context.instance_for(event) end end |
#resolve ⇒ Object
Method that must be reimplemented in the task objects actually used in the coordination primitives
22 23 24 |
# File 'lib/roby/coordination/task_base.rb', line 22 def resolve raise NotImplementedError, "#resolve must be reimplemented in objects meant to be used in the coordination primitives" end |
#to_coordination_task(task_model) ⇒ Object
51 52 53 |
# File 'lib/roby/coordination/task_base.rb', line 51 def to_coordination_task(task_model) model.to_coordination_task(task_model) end |