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
12 13 14 15 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 12 def initialize(model) super @dependencies = Set.new end |
Instance Attribute Details
Instance Method Details
#depends_on(action, role: nil) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 38 def depends_on(action, role: nil) if !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
31 32 33 34 35 36 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 31 def find_child_model(name) if d = dependencies.find { |_, role| role == name } d[0].model else super end end |
#initialize_copy(old) ⇒ Object
17 18 19 20 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 17 def initialize_copy(old) super @dependencies = @dependencies.dup end |
#map_tasks(mapping) ⇒ Object
Modify this task’s internal structure to change relationships between tasks
24 25 26 27 28 29 |
# File 'lib/roby/coordination/models/task_with_dependencies.rb', line 24 def map_tasks(mapping) super @dependencies = dependencies.map do |task, role| [mapping[task] || task, role] end end |