Class: Roby::Coordination::Models::TaskWithDependencies
- Defined in:
- lib/roby/coordination/models/task_with_dependencies.rb
Overview
Generic representation of an execution context task that can be instanciated
Direct Known Subclasses
TaskFromAction, TaskFromAsPlan, TaskFromInstanciationObject, TaskFromVariable
Instance Attribute Summary collapse
-
#dependencies ⇒ Set<(Task,String)>
readonly
Set of dependencies needed for this task, as a (task,role) pair.
Attributes inherited from Task
Instance Method Summary collapse
- #depends_on(action, role: nil) ⇒ Object
- #find_child_model(name) ⇒ Object
-
#initialize(model) ⇒ TaskWithDependencies
constructor
Creates this model-level coordination task to represent a given Roby task model.
- #initialize_copy(old) ⇒ Object
-
#map_tasks(mapping) ⇒ Object
Modify this task’s internal structure to change relationships between tasks.
Methods inherited from Task
#can_resolve_child_models?, #find_child, #find_event, #find_through_method_missing, #has_child?, #has_event?, #has_through_method_missing?, #instanciate, #new, #rebind, #setup_instanciated_task, #to_coordination_task
Constructor Details
#initialize(model) ⇒ TaskWithDependencies
Creates this model-level coordination task to represent a given Roby task model
14 15 16 17 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 14 def initialize(model) super @dependencies = Set.new end |
Instance Attribute Details
Instance Method Details
#depends_on(action, role: nil) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 41 def depends_on(action, role: nil) unless action.kind_of?(Coordination::Models::Task) raise ArgumentError, "expected a task, got #{action}. You probably forgot to convert it using #task or #state" end dependencies << [action, role] self end |
#find_child_model(name) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 33 def find_child_model(name) if d = dependencies.find { |_, role| role == name } d[0].model else super end end |
#initialize_copy(old) ⇒ Object
19 20 21 22 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 19 def initialize_copy(old) super @dependencies = @dependencies.dup end |
#map_tasks(mapping) ⇒ Object
Modify this task’s internal structure to change relationships between tasks
26 27 28 29 30 31 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 26 def map_tasks(mapping) super @dependencies = dependencies.map do |task, role| [mapping[task] || task, role] end end |