Class: Roby::EventConstraints::UnboundTaskPredicate::And

Inherits:
BinaryCommutativePredicate show all
Defined in:
lib/roby/event_constraints.rb

Overview

Representation of UnboundPredicateSupport#and and UnboundTaskPredicate#and

See documentation from UnboundTaskPredicate

Instance Attribute Summary

Attributes inherited from BinaryCommutativePredicate

#predicates

Instance Method Summary collapse

Methods inherited from BinaryCommutativePredicate

#==, #each_atomic_predicate, #explain_false, #explain_true, #has_atomic_predicate?, #initialize, #required_events

Methods inherited from Roby::EventConstraints::UnboundTaskPredicate

#compile, #evaluate, #explain_false, #explain_true, #negate, #or, #pretty_print, #to_unbound_task_predicate

Constructor Details

This class inherits a constructor from Roby::EventConstraints::UnboundTaskPredicate::BinaryCommutativePredicate

Instance Method Details

#and(pred) ⇒ Object



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/roby/event_constraints.rb', line 550

def and(pred)
    pred = pred.to_unbound_task_predicate
    if pred.kind_of?(And)
        # Only add predicates in +pred+ that are not already in
        # +self+
        result = self
        pred.each_atomic_predicate do |predicate|
            result = result.and(predicate)
        end
    elsif has_atomic_predicate?(pred)
        self
    else
        super
    end
end

#codeObject



546
547
548
# File 'lib/roby/event_constraints.rb', line 546

def code
    "(#{predicates[0].code}) && (#{predicates[1].code})"
end

#explain_static(task) ⇒ Object



574
575
576
577
578
579
580
581
582
583
584
# File 'lib/roby/event_constraints.rb', line 574

def explain_static(task)
    static0 = predicates[0].static?(task)
    static1 = predicates[1].static?(task)
    if static0 && static1
        super(task)
    elsif static0 && !predicates[0].evaluate(task)
        predicates[0].explain_static(task)
    elsif static1 && !predicates[1].evaluate(task)
        predicates[1].explain_static(task)
    end
end

#static?(task) ⇒ Boolean

Returns:

  • (Boolean)


566
567
568
569
570
571
572
# File 'lib/roby/event_constraints.rb', line 566

def static?(task)
    static0 = predicates[0].static?(task)
    static1 = predicates[1].static?(task)
    static0 && static1 ||
        (static0 && !predicates[0].evaluate(task) ||
         static1 && !predicates[1].evaluate(task))
end

#to_sObject



586
# File 'lib/roby/event_constraints.rb', line 586

def to_s; "(#{predicates[0]}) && (#{predicates[1]})" end