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.
13 14 15 16 |
# File 'lib/roby/coordination/task_base.rb', line 13 def initialize(execution_context, model) @execution_context = execution_context @model = model end |
Instance Attribute Details
#execution_context ⇒ Base (readonly)
Returns the underlying execution context.
9 10 11 |
# File 'lib/roby/coordination/task_base.rb', line 9 def execution_context @execution_context end |
#model ⇒ Coordination::Models::Task (readonly)
11 12 13 |
# File 'lib/roby/coordination/task_base.rb', line 11 def model @model end |
Instance Method Details
#find_child(role, child_model = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/roby/coordination/task_base.rb', line 24 def find_child(role, child_model = nil) child_model ||= model.find_child_model(role) if !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
41 42 43 44 45 |
# File 'lib/roby/coordination/task_base.rb', line 41 def find_event(symbol) if event = model.find_event(symbol) execution_context.instance_for(event) end end |
#find_through_method_missing(m, args) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/roby/coordination/task_base.rb', line 47 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
54 55 56 57 58 59 60 |
# File 'lib/roby/coordination/task_base.rb', line 54 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
20 21 22 |
# File 'lib/roby/coordination/task_base.rb', line 20 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
64 |
# File 'lib/roby/coordination/task_base.rb', line 64 def to_coordination_task(task_model); model.to_coordination_task(task_model) end |