Class: Roby::AndTaskMatcher

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 AND 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) ⇒ AndTaskMatcher

Create a new AndTaskMatcher object combining the given predicates.



441
442
443
444
# File 'lib/roby/query.rb', line 441

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

Instance Method Details

#<<(op) ⇒ Object

Add a new predicate to the combination



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

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

#===(task) ⇒ Object

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



459
460
461
462
# File 'lib/roby/query.rb', line 459

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

#droby_dump(dest) ⇒ Object

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



231
232
233
234
235
# File 'lib/roby/distributed/protocol.rb', line 231

def droby_dump(dest)
    m = super(dest, AndTaskMatcher::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



448
449
450
451
452
453
454
# File 'lib/roby/query.rb', line 448

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