Module: Roby::EventConstraints::UnboundPredicateSupport

Defined in:
lib/roby/event_constraints.rb

Overview

Module that defines the unbound task predicate methods that are added to the Symbol class

Instance Method Summary collapse

Instance Method Details

#and(other) ⇒ Object

Returns an UnboundTaskPredicate that will be true if the generator represented by this symbol has emitted at least once, and the predicate represented by other is true at the same time.

In its simplest form,

:blocked.and(:updated)

it will be true if the task on which it is applied has both emitted :blocked and :updated at least once.



93
94
95
96
# File 'lib/roby/event_constraints.rb', line 93

def and(other)
    to_unbound_task_predicate.
        and(other.to_unbound_task_predicate)
end

#emitted?Boolean

Returns an UnboundTaskPredicate that will be true if the generator represented by this symbol has emitted at least once.

In its simplest form,

:blocked.emitted?

will be true when evaluated on a task whose blocked event has emitted at least once

Returns:

  • (Boolean)


54
55
56
# File 'lib/roby/event_constraints.rb', line 54

def emitted?
    to_unbound_task_predicate
end

#followed_by(other) ⇒ Object

Returns an UnboundTaskPredicate that will be true if the generator represented by this symbol and the generator represented by other (as a symbol) have emitted in sequence, i.e. if both self and other have emitted at least once, and if the last event e0 emitted by self and the last event e1 emitted by other match

e0.time < e1.time

Unlike and, or and negate, this only works on single events (i.e. it cannot be applied on other predicates)



124
125
126
127
# File 'lib/roby/event_constraints.rb', line 124

def followed_by(other)
    to_unbound_task_predicate.
        followed_by(other.to_unbound_task_predicate)
end

#happened?Boolean

Deprecated.

use #emitted? instead

Returns:

  • (Boolean)


59
60
61
62
# File 'lib/roby/event_constraints.rb', line 59

def happened?
    Roby.warn_deprecated "#happened? is deprecated, use #emitted? instead"
    emitted?
end

#negateObject

Returns an UnboundTaskPredicate that will be true if the generator represented by self has never emitted



147
148
149
# File 'lib/roby/event_constraints.rb', line 147

def negate
    to_unbound_task_predicate.negate
end

#neverObject

Returns an UnboundTaskPredicate that will be true if the generator represented by this symbol will never be emitted.

In its simplest form,

:blocked.never

will be true when evaluated on a task whose blocked event has not yet been emitted, and has been declared as unreachable



79
80
81
# File 'lib/roby/event_constraints.rb', line 79

def never
    to_unbound_task_predicate.never
end

#not_followed_by(other) ⇒ Object

Returns an UnboundTaskPredicate that will be true if the generator represented by this symbol and the generator represented by other (as a symbol) have not emitted in sequence, i.e. if self has emitted at least once, and either other has not emitted or other has emitted and the last event e0 emitted by self and the last event e1 emitted by other do not match

e0.time < e1.time

Unlike and, or and negate, this only works on single events (i.e. it cannot be applied on other predicates)



140
141
142
143
# File 'lib/roby/event_constraints.rb', line 140

def not_followed_by(other)
    to_unbound_task_predicate.
        not_followed_by(other.to_unbound_task_predicate)
end

#or(other) ⇒ Object

Returns an UnboundTaskPredicate that will be true if the generator represented by this symbol has emitted at least once, or the predicate represented by other is true.

In its simplest form,

:blocked.or(:updated)

it will be true if the task on which it is applied has either emitted :blocked, or emitted :updated, or both.



108
109
110
111
# File 'lib/roby/event_constraints.rb', line 108

def or(other)
    to_unbound_task_predicate.
        or(other.to_unbound_task_predicate)
end

#to_unbound_task_predicateObject

Protocol method. The unbound task predicate call always calls #to_unbound_task_predicate on the arguments given to it.



66
67
68
# File 'lib/roby/event_constraints.rb', line 66

def to_unbound_task_predicate
    UnboundTaskPredicate::SingleEvent.new(self)
end