Class: Roby::EventConstraints::UnboundTaskPredicate::Or

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

Overview

Representation of UnboundPredicateSupport#or and UnboundTaskPredicate#or

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

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

Constructor Details

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

Instance Method Details

#codeObject



594
595
596
# File 'lib/roby/event_constraints.rb', line 594

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

#explain_static(task) ⇒ Object



624
625
626
627
628
629
630
631
632
633
634
# File 'lib/roby/event_constraints.rb', line 624

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

#or(pred) ⇒ Object



598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# File 'lib/roby/event_constraints.rb', line 598

def or(pred)
    pred = pred.to_unbound_task_predicate
    if pred.kind_of?(Or)
        # Only add predicates in +pred+ that are not already in
        # +self+
        result = self
        pred.each_atomic_predicate do |predicate|
            result = result.or(predicate)
        end
        result
    elsif has_atomic_predicate?(pred)
        # Do not add +pred+ if it is already included in +self+
        self
    else
        super
    end
end

#static?(task) ⇒ Boolean

Returns:

  • (Boolean)


616
617
618
619
620
621
622
# File 'lib/roby/event_constraints.rb', line 616

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



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

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