# Tai Sakuma <tai.sakuma@cern.ch>
from EventLoop import EventLoop

##__________________________________________________________________||
class AllEvents(object):
    def __call__(self, event): return True

##__________________________________________________________________||
class EventReaderBundle(object):
    """A bundle of event readers

    """
    def __init__(self, eventBuilder, eventLoopRunner, readerCollectorAssociator, eventSelection = None):
        self.eventBuilder = eventBuilder
        self.eventLoopRunner = eventLoopRunner
        self.readerCollectorAssociator = readerCollectorAssociator
        self.eventSelection = eventSelection if eventSelection is not None else AllEvents()

        self.EventLoop = EventLoop

    def begin(self):
        self.eventLoopRunner.begin()

    def read(self, component):
        reader = self.readerCollectorAssociator.make(component.name)
        eventLoop = self.EventLoop(self.eventBuilder, self.eventSelection, component, reader)
        self.eventLoopRunner.run(eventLoop)

    def end(self):
        self.eventLoopRunner.end()
        return self.readerCollectorAssociator.collector.collect()

##__________________________________________________________________||

@@ -327,21 +327,88 @@
  of 
-event readers
+copies of an event reader.%0A%0A%0A    Each copy reads events in a different data set.
 %0A%0A  
@@ -880,24 +880,22 @@
 d(self, 
-componen
+datase
 t):%0A    
@@ -943,24 +943,22 @@
 or.make(
-componen
+datase
 t.name)%0A
@@ -1036,16 +1036,14 @@
 on, 
-componen
+datase
 t, r

change an argument name and update docstring in EventReaderBundle