00001 #ifndef PSANA_RUN_H 00002 #define PSANA_RUN_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: Run.h 8013 2014-04-17 02:29:27Z cpo@SLAC.STANFORD.EDU $ 00007 // 00008 // Description: 00009 // Class Run. 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 #include <boost/shared_ptr.hpp> 00017 00018 //---------------------- 00019 // Base Class Headers -- 00020 //---------------------- 00021 00022 //------------------------------- 00023 // Collaborating Class Headers -- 00024 //------------------------------- 00025 #include "psana/EventIter.h" 00026 #include "psana/EventLoop.h" 00027 #include "psana/StepIter.h" 00028 #include "PSEnv/Env.h" 00029 00030 //------------------------------------ 00031 // Collaborating Class Declarations -- 00032 //------------------------------------ 00033 namespace psana { 00034 class RunIter; 00035 } 00036 00037 // --------------------- 00038 // -- Class Interface -- 00039 // --------------------- 00040 00041 namespace psana { 00042 00043 /// @addtogroup psana 00044 00045 /** 00046 * @ingroup psana 00047 * 00048 * @brief Class representing a run. 00049 * 00050 * Main purpose of this class is to provide iteration over contained 00051 * events or steps. 00052 * 00053 * This software was developed for the LCLS project. If you use all or 00054 * part of it, please give an appropriate acknowledgment. 00055 * 00056 * @version $Id: Run.h 8013 2014-04-17 02:29:27Z cpo@SLAC.STANFORD.EDU $ 00057 * 00058 * @author Andy Salnikov 00059 */ 00060 00061 class Run { 00062 public: 00063 00064 /// Default constructor makes "null" run object 00065 Run(); 00066 00067 // Constructor takes event loop object 00068 Run(const boost::shared_ptr<EventLoop>& evtLoop, int run); 00069 00070 // Destructor 00071 ~Run () ; 00072 00073 /// This object is converted to true for non-null instance 00074 operator bool() const { return bool(m_evtLoop); } 00075 bool operator!() const { return not bool(m_evtLoop); } 00076 00077 /// Get environment object, cannot be called for "null" object 00078 PSEnv::Env& env() const; 00079 00080 /// Get run number, -1 returned for if unknown 00081 int run() const { return m_run; } 00082 00083 /// Returns iterator for events in this run 00084 EventIter events() { return EventIter(m_evtLoop, EventLoop::EndRun); } 00085 00086 /// Returns iterator for steps in this run 00087 StepIter steps() { return StepIter(m_evtLoop, EventLoop::EndRun); } 00088 00089 /// Returns run index for random access 00090 Index& index() { return m_evtLoop->index(); } 00091 00092 protected: 00093 00094 private: 00095 00096 // Data members 00097 boost::shared_ptr<EventLoop> m_evtLoop; 00098 int m_run; 00099 00100 }; 00101 00102 } // namespace psana 00103 00104 #endif // PSANA_RUN_H