PSShmemInput/include/DgramSourceShmem.h

Go to the documentation of this file.
00001 #ifndef PSSHMEMINPUT_DGRAMSOURCESHMEM_H
00002 #define PSSHMEMINPUT_DGRAMSOURCESHMEM_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: DgramSourceShmem.h 7698 2014-02-27 00:47:58Z salnikov@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Class DgramSourceShmem.
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 #include <string>
00017 #include <boost/thread.hpp>
00018 #include <boost/scoped_ptr.hpp>
00019 
00020 //----------------------
00021 // Base Class Headers --
00022 //----------------------
00023 #include "PSXtcInput/IDatagramSource.h"
00024 #include "psana/Configurable.h"
00025 
00026 //-------------------------------
00027 // Collaborating Class Headers --
00028 //-------------------------------
00029 
00030 //------------------------------------
00031 // Collaborating Class Declarations --
00032 //------------------------------------
00033 namespace XtcInput {
00034   class DgramQueue;
00035 }
00036 
00037 //              ---------------------
00038 //              -- Class Interface --
00039 //              ---------------------
00040 
00041 namespace PSShmemInput {
00042 
00043 /// @addtogroup PSShmemInput
00044 
00045 /**
00046  *  @ingroup PSShmemInput
00047  *
00048  *  @brief Implementation of IDatagramSource interface which receives data from shared memory.
00049  *
00050  *  @note This software was developed for the LCLS project.  If you use all or 
00051  *  part of it, please give an appropriate acknowledgment.
00052  *
00053  *  @version $Id: DgramSourceShmem.h 7698 2014-02-27 00:47:58Z salnikov@SLAC.STANFORD.EDU $
00054  *
00055  *  @author Andy Salnikov
00056  */
00057 
00058 class DgramSourceShmem : public PSXtcInput::IDatagramSource, public psana::Configurable {
00059 public:
00060 
00061   // Constructor tagkes the name of the input module, used for accessing module 
00062   // configuration parameters. 
00063   DgramSourceShmem (const std::string& name) ;
00064 
00065   // Destructor
00066   virtual ~DgramSourceShmem () ;
00067 
00068   /**
00069    *   Initialization method for datagram source, this is typically called
00070    *   in beginJob() method and it may contain initialization code which 
00071    *   cannot be executed during construction of an instance.
00072    */ 
00073   virtual void init();
00074 
00075   /**
00076    *  @brief Return next datagram(s) from the source.
00077    *
00078    *  This method returns two sets of datagrams - eventDg is the set of histograms
00079    *  belonging to the next event, nonEventDg is the set of datagrams which has some
00080    *  other data (like EPICS) which is needed for correct interpretation of current
00081    *  event. Currently eventDg should contain one datagram but potentially in the
00082    *  future we may start event building in offline and that list can grow longer.
00083    *  It nonEventDg is non-empty then it has to be processed first as those datagram
00084    *  should come from earlier time than eventDg and eventDg may contain data that
00085    *  overrides data in nonEventDg (e.g. some EPICS PV data may be contained in both
00086    *  nonEventDg and eventDg).
00087    *
00088    *  This method will called repeatedly until it returns false.
00089    *
00090    *  @param[out] eventDg    returned set of datagrams for current event
00091    *  @param[out] nonEventDg returned set of datagrams containing other information.
00092    *  @return false if there are no more events, both eventDg and nonEventDg will be empty in this case.
00093    */
00094   virtual bool next(std::vector<XtcInput::Dgram>& eventDg, std::vector<XtcInput::Dgram>& nonEventDg);
00095 
00096 protected:
00097 
00098 private:
00099 
00100   boost::scoped_ptr<XtcInput::DgramQueue> m_dgQueue;  ///< Input datagram queue
00101   boost::scoped_ptr<boost::thread> m_readerThread;    ///< Thread which does datagram reading
00102 
00103 };
00104 
00105 } // namespace PSShmemInput
00106 
00107 #endif // PSSHMEMINPUT_DGRAMSOURCESHMEM_H

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7