Class: Roby::Queries::PlanQueryResult
Instance Attribute Summary
#initial_set, #plan, #result_set
Class Method Summary
collapse
Instance Method Summary
collapse
#each, #include?, #initialize
Class Method Details
.from_plan(plan, matcher) ⇒ Object
Called by TaskMatcher#result_set and Query#result_set to get the set of tasks matching matcher
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/roby/queries/plan_query_result.rb', line 62
def self.from_plan(plan, matcher) filtered = matcher.filter_tasks_sets(
plan.tasks, plan.task_index, initial_is_complete: true
)
if matcher.indexed_query?
new(plan, plan.tasks, filtered)
else
result = Set.new
result.compare_by_identity
filtered.each { |task| result << task if matcher === task }
new(plan, plan.tasks, result)
end
end
|
.root_in_query?(result_set, task, graph) ⇒ Boolean
77
78
79
80
81
82
|
# File 'lib/roby/queries/plan_query_result.rb', line 77
def self.root_in_query?(result_set, task, graph)
graph.depth_first_visit(task) do |v|
return false if v != task && result_set.include?(v)
end
true
end
|
.roots_of(from, in_relation) ⇒ Object
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/roby/queries/plan_query_result.rb', line 84
def self.roots_of(from, in_relation)
plan = from.plan
result_set = from.result_set
graph = plan.task_relation_graph_for(in_relation).reverse
new_results = result_set.find_all do |task|
root_in_query?(result_set, task, graph)
end
new(plan, from.initial_set, new_results)
end
|
Instance Method Details
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/roby/queries/plan_query_result.rb', line 39
def &(other)
if other.plan != plan
raise ArgumentError,
"cannot merge results from #{other.plan} "\
"in results from #{plan}"
elsif !other.initial_set.equal?(initial_set)
raise ArgumentError,
"cannot merge results with different initial sets"
end
result = dup
result.result_set = result_set & other.result_set
result
end
|
#each_in_plan(plan, &block) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/roby/queries/plan_query_result.rb', line 10
def each_in_plan(plan, &block)
if plan != self.plan
raise ArgumentError,
"attempting to enumerate results of a query ran "\
"in #{self.plan} from #{plan}"
end
result_set.each(&block)
end
|
#local_query_results ⇒ Object
6
7
8
|
# File 'lib/roby/queries/plan_query_result.rb', line 6
def local_query_results
[self]
end
|
54
55
56
57
58
|
# File 'lib/roby/queries/plan_query_result.rb', line 54
def negate
result = dup
result.result_set = initial_set - result_set
result
end
|
#roots(in_relation) ⇒ Object
20
21
22
|
# File 'lib/roby/queries/plan_query_result.rb', line 20
def roots(in_relation)
self.class.roots_of(self, in_relation)
end
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/roby/queries/plan_query_result.rb', line 24
def |(other)
if other.plan != plan
raise ArgumentError,
"cannot merge results from #{other.plan} "\
"in results from #{plan}"
elsif !other.initial_set.equal?(initial_set)
raise ArgumentError,
"cannot merge results with different initial sets"
end
result = dup
result.result_set = result_set | other.result_set
result
end
|