#ifndef T_EVENT_FOLDER_H #define T_EVENT_FOLDER_H #include #include class TFolder; namespace COMET { class ICOMETEvent; class IEventFolder; } /// Provide management for events read using the ICOMETInput object and kept /// in the //root/Events folder. /// /// ICOMETEvent objects are usually read from an input file using a /// ICOMETInput object (output is with a ICOMETOutput). The last event read /// will be available from IEventFolder::GetCurrentEvent() which is a static /// method. Interactive programs which want to provide a method to keep /// multiple events in memory (e.g. the event display), should get the current /// event using the IEventFolder::GetCurrentEvent() method. Events can then /// be saved automatically into a root folder by calling the /// IEventFolder::GetEventFolder() static method. class COMET::IEventFolder : public TObject { private: IEventFolder(); IEventFolder(const IEventFolder& folder) : TObject(folder) { } // no copies void operator=(const IEventFolder&) { } // no copies #ifdef INTERACTIVE_TEVENTFOLDER public: #endif /// Return a pointer to the //root/Events folder and should be only be /// used in interactive programs. Events are entered into this folder by /// the Register method (the Build method automatically calls Register). /// Any input class (eg TRootInput) should call Register for each event /// that is successfully read. This gives programs a convenient way to /// keep track of which events must be deleted, and which are available /// for processing. This is a trivial way to keep track of more than one /// event in memory. Events are saved using the event number. Note: that /// events will not be saved into the event folder unless GetEventFolder /// has been called first. This means that programs that don't want the /// folder overhead don't pay the price. The macro /// "INTERACTIVE_TEVENTFOLDER" must be defined before the /// "IEventFolder.hxx" file is included for this method to be available in /// user code. static IEventFolder* GetEventFolder(void); public: virtual ~IEventFolder(void); /// A static method to return a pointer to the current event which should /// be accessed as "COMET::IEventFolder::GetCurrentEvent()". This will work /// even if the events are not being kept in a folder since each event /// will handle the manipulation of this field as it is created or /// destroyed. This method should not be accessed through a /// COMET::IEventFolder object. /// \code /// // Do not use /// COMET::IEventFolder::GetEventFolder()->GetCurrentEvent(); /// \endcode /// Accessing GetCurrentEvent through IEventFolder will cause significant /// code slow downs. static ICOMETEvent* GetCurrentEvent(void); /// Set the pointer to the current event. The event will become the /// current event if it is saved in the event folder. If it is not in the /// event folder, then this does nothing. void SetCurrentEvent(ICOMETEvent* event); /// Register an event with event folder. This is used in the ICOMETEvent /// constructor to make sure that IEventFolder knows about the new event. static void RegisterEvent(ICOMETEvent* event); /// Delete an event from the event folder. Root will handle removing an /// event if the folder is active, but since we may be working in a /// non-interactive program, that isn't good enough. This is used in the /// ICOMETEvent distructor to tell IEventFolder when an event goes away. static void RemoveEvent(ICOMETEvent* event); /// Return the actual folder which can be NULL if //root/Events does not /// exist. virtual TFolder* GetFolder(void) const; /// The current (most recent) event. If there is no current event, this /// will return zero. virtual ICOMETEvent* GetEvent(int prev = 0) const; /// Find a particular event. virtual ICOMETEvent* FindEvent(int run, int evt) const; /// A slot to capture the event selected in the root browser. This is /// connected when the event folder is constructed. virtual void EventSelected(TObject* theObject); /// Print the object information. virtual void ls(Option_t *opt = "") const; private: static IEventFolder* fEventFolder; static ICOMETEvent* fCurrentEvent; TFolder* fFolderOfEvents; ClassDef(IEventFolder,2); }; #endif