Class: Roby::Sequence

Inherits:
TaskAggregator show all
Defined in:
lib/roby/task-operations.rb

Constant Summary

Constants included from Log::TaskHooks

Log::TaskHooks::HOOKS

Constants included from Log::BasicObjectHooks

Log::BasicObjectHooks::HOOKS

Instance Attribute Summary

Attributes inherited from TaskAggregator

#tasks

Attributes inherited from PlanObject

#executable, #plan, #removed_at

Attributes inherited from BasicObject

#distribute

Instance Method Summary collapse

Methods inherited from TaskAggregator

#delete, #each_task, #empty?, #initialize

Methods inherited from Task

#_dump, _load, #droby_dump, improves, #improves?, improves?, match, needs, #needs?, needs?

Methods included from TaskStructure::ModelConflicts

#conflicts_with, #conflicts_with?

Methods included from Distributed::DRobyTaskModel::Dump

#droby_dump

Methods included from Distributed::DRobyModel::Dump

#droby_dump

Methods included from Distributed::TaskNotifications

#updated_data

Methods included from TaskOperations

#+, #|

Methods included from Log::TaskHooks

#added_child_object, #removed_child_object

Methods inherited from PlanObject

#add_child_object, #apply_relation_changes, child_plan_object, #each_plan_child, #executable?, #finalized?, #forget_peer, #read_write?, #remotely_useful?, #removing_child_object, #replace_by, #replace_subplan_by, #root_object, #root_object?, #subscribed?, #update_on?, #updated_by?

Methods included from Distributed::RelationModificationHooks

#added_child_object, #removed_child_object

Methods included from Transactions::PlanObjectUpdates

#adding_child_object, #removing_child_object

Methods included from DirectedRelationSupport

#add_child_object, #add_parent_object, #check_is_relation, #related_objects, #relations, #remove_child_object, #remove_children, #remove_parent_object, #remove_parents, #remove_relations

Methods inherited from BasicObject

#add_sibling_for, #distribute?, distribute?, #finalized?, #forget_peer, #has_sibling_on?, #initialize_copy, local_only, #read_write?, #remotely_useful?, #remove_sibling_for, #self_owned?, #sibling_of, #sibling_on, #subscribe, #subscribed?, #update_on?, #updated?, #updated_by?, #updated_peers

Methods included from Log::BasicObjectHooks

#added_owner, #removed_owner

Constructor Details

This class inherits a constructor from Roby::TaskAggregator

Instance Method Details

#<<(task) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/roby/task-operations.rb', line 101

def <<(task)
	    raise "trying to do Sequence#<< on a finished sequence" if finished?
	    connect_start(task) if @tasks.empty?
	    connect_stop(task)
	    
	    @tasks << task
	    realized_by task
	    self
end

#nameObject



56
57
58
# File 'lib/roby/task-operations.rb', line 56

def name
    @name || @tasks.map { |t| t.name }.join("+")
end

#to_sequenceObject



111
# File 'lib/roby/task-operations.rb', line 111

def to_sequence; self end

#to_task(task = nil) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/roby/task-operations.rb', line 60

def to_task(task = nil)
    return super() unless task
    task = task.new unless task.kind_of?(Roby::Task)
    @tasks.each { |t| task.realized_by t }

    task.on(:start, @tasks.first, :start)
    @tasks.last.forward(:success, task, :success)

    delete

    task
end

#unshift(task) ⇒ Object



91
92
93
94
95
96
97
98
99
# File 'lib/roby/task-operations.rb', line 91

def unshift(task)
    raise "trying to do Sequence#unshift on a running or finished sequence" if (running? || finished?)
	    connect_start(task)
	    connect_stop(task) if @tasks.empty?

    @tasks.unshift(task)
	    realized_by task
	    self
end