Class: Roby::Coordination::TaskBase
- Includes:
- MetaRuby::DSLs::FindThroughMethodMissing
- 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
- #find_through_method_missing(m, args) ⇒ Object
- #has_through_method_missing?(m) ⇒ Boolean
-
#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 |
#find_through_method_missing(m, args) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/roby/coordination/task_base.rb', line 49 def find_through_method_missing(m, args) MetaRuby::DSLs.find_through_method_missing( self, m, args, "_child" => :find_child, "_port" => :find_port, "_event" => :find_event) || super end |
#has_through_method_missing?(m) ⇒ Boolean
57 58 59 60 61 62 63 |
# File 'lib/roby/coordination/task_base.rb', line 57 def has_through_method_missing?(m) MetaRuby::DSLs.has_through_method_missing?( self, m, "_child" => :has_child?, "_port" => :has_port?, "_event" => :has_event?) || super 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
67 68 69 |
# File 'lib/roby/coordination/task_base.rb', line 67 def to_coordination_task(task_model) model.to_coordination_task(task_model) end |