Class: Roby::OrGenerator

Inherits:
EventGenerator show all
Defined in:
lib/roby/event.rb

Overview

Event generator which fires when the first of its source events fires. All event generators which signal this one are considered as sources.

See also EventGenerator#| and #<<

Constant Summary

Constants included from Log::EventGeneratorHooks

Log::EventGeneratorHooks::HOOKS

Constants included from Log::BasicObjectHooks

Log::BasicObjectHooks::HOOKS

Instance Attribute Summary

Attributes inherited from EventGenerator

#command, #executable, #pending, #unreachable_handlers

Attributes inherited from PlanObject

#executable, #plan, #removed_at

Attributes inherited from BasicObject

#distribute

Instance Method Summary collapse

Methods inherited from EventGenerator

#&, #_dump, _load, #achieve_with, #add_child_object, #call, #call_handlers, #call_without_propagation, #called, #calling, #cancel, #controlable?, #default_command, #delay, #droby_dump, #each_precondition, #emit, #emit_failed, #emit_on, #emit_without_propagation, #emitting, event_gathering, #executable?, #filter, #fired, #forward, #forward_once, #forwarding, gather_events, #if_unreachable, #initialize_copy, #last, #model, #name, #new, #on, #once, #pending?, #postpone, #postponed, #precondition, #pretty_print, #realize_with, #related_events, #related_tasks, remove_event_gathering, #signal, #signal_once, #signalling, #to_event, #unreachable!, #until, #when_unreachable, #|

Methods included from Distributed::DRobyModel::Dump

#droby_dump

Methods included from Distributed::EventNotifications

#fired, #forwarding, #signalling

Methods included from Propagation::EventPrecedenceChanged

#added_child_object, #removed_child_object

Methods included from Log::EventGeneratorHooks

#added_child_object, #called, #calling, #emitting, #fired, #forwarding, #postponed, #removed_child_object, #signalling

Methods inherited from PlanObject

#add_child_object, #apply_relation_changes, child_plan_object, #each_plan_child, #executable?, #finalized?, #forget_peer, #read_write?, #remotely_useful?, #removing_child_object, #replace_by, #replace_subplan_by, #root_object, #root_object?, #subscribed?, #update_on?, #updated_by?

Methods included from Distributed::RelationModificationHooks

#added_child_object, #removed_child_object

Methods included from Transactions::PlanObjectUpdates

#adding_child_object, #removing_child_object

Methods included from DirectedRelationSupport

#add_child_object, #add_parent_object, #check_is_relation, #related_objects, #relations, #remove_child_object, #remove_children, #remove_parent_object, #remove_parents, #remove_relations

Methods inherited from BasicObject

#add_sibling_for, #distribute?, distribute?, #finalized?, #forget_peer, #has_sibling_on?, #initialize_copy, local_only, #read_write?, #remotely_useful?, #remove_sibling_for, #self_owned?, #sibling_of, #sibling_on, #subscribe, #subscribed?, #update_on?, #updated?, #updated_by?, #updated_peers

Methods included from Log::BasicObjectHooks

#added_owner, #removed_owner

Constructor Details

#initializeOrGenerator

Creates a new OrGenerator without any sources.



858
859
860
861
862
863
# File 'lib/roby/event.rb', line 858

def initialize
    super do |context|
  emit_if_first(context)
    end
    @active = true
end

Instance Method Details

#<<(generator) ⇒ Object

Adds generator to the sources of this event



897
898
899
900
# File 'lib/roby/event.rb', line 897

def << (generator)
    generator.add_signal self
    self
end

#added_parent_object(parent, relations, info) ⇒ Object

:nodoc:



885
886
887
888
889
890
891
892
893
894
# File 'lib/roby/event.rb', line 885

def added_parent_object(parent, relations, info) # :nodoc:
    super if defined? super
    return unless relations.include?(EventStructure::Signal)

    parent.if_unreachable(true) do |reason|
  if !happened? && parent_objects(EventStructure::Signal).all? { |ev| ev.unreachable? }
      unreachable!(reason || parent)
  end
    end
end

#emit_if_first(context) ⇒ Object

:nodoc:



879
880
881
882
883
# File 'lib/roby/event.rb', line 879

def emit_if_first(context) # :nodoc:
    return unless @active
    @active = false
    emit(context)
end

#empty?Boolean

True if there is no source event for this combinator.

Returns:

  • (Boolean)


866
# File 'lib/roby/event.rb', line 866

def empty?; parent_objects(EventStructure::Signal).empty? end

#resetObject

Reset its state, so as to behave as if no source has ever been emitted.



870
871
872
873
874
875
876
877
# File 'lib/roby/event.rb', line 870

def reset
    @active = true
    each_parent_object(EventStructure::Signal) do |source|
  if source.respond_to?(:reset)
      source.reset
  end
    end
end