00001 #ifndef PSSHMEMINPUT_SHMEMMONITORCLIENT_H 00002 #define PSSHMEMINPUT_SHMEMMONITORCLIENT_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: ShmemMonitorClient.h 6177 2013-04-29 21:55:17Z salnikov@SLAC.STANFORD.EDU $ 00007 // 00008 // Description: 00009 // Class ShmemMonitorClient. 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 #include <string> 00017 00018 //---------------------- 00019 // Base Class Headers -- 00020 //---------------------- 00021 #include "pdsdata/app/XtcMonitorClient.hh" 00022 00023 //------------------------------- 00024 // Collaborating Class Headers -- 00025 //------------------------------- 00026 #include "pdsdata/xtc/TransitionId.hh" 00027 00028 //------------------------------------ 00029 // Collaborating Class Declarations -- 00030 //------------------------------------ 00031 namespace XtcInput { 00032 class DgramQueue; 00033 } 00034 00035 // --------------------- 00036 // -- Class Interface -- 00037 // --------------------- 00038 00039 namespace PSShmemInput { 00040 00041 /// @addtogroup PSShmemInput 00042 00043 /** 00044 * @ingroup PSShmemInput 00045 * 00046 * @brief Implementation of XtcMonitorClient which pushes data into a queue. 00047 * 00048 * Instance of this class is supposed to run in a separate thread so its 00049 * interface is suitable for use with boost::thread class, for example. 00050 * It is also possible to use this class without starting new thread by 00051 * calling @c operator()() like in this example: 00052 * 00053 * @code 00054 * ShmemMonitorClient client(...); 00055 * // This will run until stop transition is met 00056 * client(); 00057 * @endcode 00058 * 00059 * @version $Id: ShmemMonitorClient.h 6177 2013-04-29 21:55:17Z salnikov@SLAC.STANFORD.EDU $ 00060 * 00061 * @author Andy Salnikov 00062 */ 00063 00064 class ShmemMonitorClient : public Pds::XtcMonitorClient { 00065 public: 00066 00067 // Default constructor 00068 ShmemMonitorClient(const std::string& tag, int index, XtcInput::DgramQueue& queue, 00069 Pds::TransitionId::Value stopTr); 00070 00071 // this is the "run" method used by the Boost.thread 00072 void operator() () ; 00073 00074 // overriding base class method 00075 virtual int processDgram(Pds::Dgram* dg); 00076 00077 protected: 00078 00079 private: 00080 00081 std::string m_tag; ///< Shared memory tag 00082 int m_index; ///< Client index 00083 XtcInput::DgramQueue& m_queue; ///< Ouput queue for datagrams 00084 Pds::TransitionId::Value m_stopTr; ///< Transition which should stop event loop 00085 00086 }; 00087 00088 } // namespace PSShmemInput 00089 00090 #endif // PSSHMEMINPUT_SHMEMMONITORCLIENT_H