PSXtcInput/include/IDatagramSource.h

Go to the documentation of this file.
00001 #ifndef PSXTCINPUT_IDATAGRAMSOURCE_H
00002 #define PSXTCINPUT_IDATAGRAMSOURCE_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: IDatagramSource.h 10730 2015-09-23 22:06:21Z davidsch@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Class IDatagramSource.
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 
00017 //----------------------
00018 // Base Class Headers --
00019 //----------------------
00020 #include <vector>
00021 
00022 //-------------------------------
00023 // Collaborating Class Headers --
00024 //-------------------------------
00025 #include "XtcInput/Dgram.h"
00026 
00027 //------------------------------------
00028 // Collaborating Class Declarations --
00029 //------------------------------------
00030 
00031 //              ---------------------
00032 //              -- Class Interface --
00033 //              ---------------------
00034 
00035 namespace PSXtcInput {
00036 
00037 /// @addtogroup PSXtcInput
00038 
00039 /**
00040  *  @ingroup PSXtcInput
00041  *
00042  *  @brief Declaration of interface for datagram source classes.
00043  *
00044  *  Datagram source is an abstraction of a  sequence of datagrams that can be iterated 
00045  *  over. Instance method next() is called repeatedly to obtain next available datagram
00046  *  until this method returns empty instance. 
00047  *  
00048  *  In the future this interface could be extended to support direct access based on 
00049  *  some index (e.g. time-based).
00050  *
00051  *  @note This software was developed for the LCLS project.  If you use all or 
00052  *  part of it, please give an appropriate acknowledgment.
00053  *
00054  *  @version $Id: IDatagramSource.h 10730 2015-09-23 22:06:21Z davidsch@SLAC.STANFORD.EDU $
00055  *
00056  *  @author Andy Salnikov
00057  */
00058 
00059 class IDatagramSource {
00060 public:
00061 
00062   // Destructor
00063   virtual ~IDatagramSource() {}
00064 
00065   /**
00066    *   Initialization method for datagram source, this is typically called
00067    *   in beginJob() method and it may contain initialization code which 
00068    *   cannot be executed during construction of an instance.
00069    */ 
00070   virtual void init() = 0;
00071 
00072   /**
00073    *  @brief Return next datagram(s) from the source.
00074    *
00075    *  This method returns two sets of datagrams - eventDg is the set of histograms
00076    *  belonging to the next event, nonEventDg is the set of datagrams which has some
00077    *  other data (like EPICS) which is needed for correct interpretation of current
00078    *  event. Currently eventDg should contain one datagram but potentially in the
00079    *  future we may start event building in offline and that list can grow longer.
00080    *  It nonEventDg is non-empty then it has to be processed first as those datagram
00081    *  should come from earlier time than eventDg and eventDg may contain data that
00082    *  overrides data in nonEventDg (e.g. some EPICS PV data may be contained in both
00083    *  nonEventDg and eventDg).
00084    *
00085    *  This method will called repeatedly until it returns false.
00086    *
00087    *  @param[out] eventDg    returned set of datagrams for current event
00088    *  @param[out] nonEventDg returned set of datagrams containing other information.
00089    *  @return false if there are no more events, both eventDg and nonEventDg will be empty in this case.
00090    */
00091   virtual bool next(std::vector<XtcInput::Dgram>& eventDg, std::vector<XtcInput::Dgram>& nonEventDg) = 0;
00092 
00093 
00094 
00095   /**
00096    * Returns true if live mode and the available events on disk is > the argument numEvents
00097    */
00098   virtual bool liveAvail(int numEvents) { return false; }
00099 
00100 protected:
00101 
00102   // Default constructor
00103   IDatagramSource()  {}
00104 
00105 private:
00106 
00107   // disable copy
00108   IDatagramSource(const IDatagramSource&);
00109   IDatagramSource& operator=(const IDatagramSource&);
00110   
00111 };
00112 
00113 } // namespace PSXtcInput
00114 
00115 #endif // PSXTCINPUT_IDATAGRAMSOURCE_H

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7