Class: Roby::OrTaskMatcher

Inherits:
TaskMatcher show all
Defined in:
lib/roby/query.rb,
lib/roby/distributed/protocol.rb

Overview

This task combines multiple task matching predicates through a OR boolean operator.

Defined Under Namespace

Classes: DRoby

Constant Summary

Constants inherited from TaskMatcher

TaskMatcher::STATE_PREDICATES

Instance Attribute Summary

Attributes inherited from TaskMatcher

#arguments, #improved_information, #model, #needed_information, #neg_predicates, #owners, #predicates

Instance Method Summary collapse

Methods inherited from TaskMatcher

#&, declare_class_methods, #each, match_predicates, #negate, #owned_by, #self_owned, #which_fullfills, #which_improves, #which_needs, #with_arguments, #with_model, #with_model_arguments, #|

Constructor Details

#initialize(*ops) ⇒ OrTaskMatcher

Create a new OrTaskMatcher object combining the given predicates.



387
388
389
390
# File 'lib/roby/query.rb', line 387

def initialize(*ops)
    @ops = ops 
    super()
end

Instance Method Details

#<<(op) ⇒ Object

Add a new predicate to the combination



403
# File 'lib/roby/query.rb', line 403

def <<(op); @ops << op end

#===(task) ⇒ Object

True if the task matches at least one of the underlying predicates



405
406
407
408
# File 'lib/roby/query.rb', line 405

def ===(task)
    return unless @ops.any? { |op| op === task }
    super
end

#droby_dump(dest) ⇒ Object

Returns an intermediate representation of self suitable to be sent to the dest peer.



212
213
214
215
216
# File 'lib/roby/distributed/protocol.rb', line 212

def droby_dump(dest)
    m = super(dest, OrTaskMatcher::DRoby)
    m.args << @ops
    m
end

#filter(task_set, task_index) ⇒ Object

Filters as much as non-matching tasks as possible out of task_set, based on the information in task_index



394
395
396
397
398
399
400
# File 'lib/roby/query.rb', line 394

def filter(task_set, task_index)
    result = ValueSet.new
    for child in @ops
  result.merge child.filter(task_set, task_index)
    end
    result
end