CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/EventFilter/StorageManager/interface/DQMEventStore.h

Go to the documentation of this file.
00001 // $Id: DQMEventStore.h,v 1.14 2012/04/20 10:48:18 mommsen Exp $
00003 
00004 #ifndef EventFilter_StorageManager_DQMEventStore_h
00005 #define EventFilter_StorageManager_DQMEventStore_h
00006 
00007 #include <map>
00008 #include <queue>
00009 
00010 #include <boost/thread/mutex.hpp>
00011 
00012 #include "TThread.h"
00013 
00014 #include "xcept/Exception.h"
00015 #include "xdaq/ApplicationDescriptor.h"
00016 
00017 #include "EventFilter/StorageManager/interface/AlarmHandler.h"
00018 #include "EventFilter/StorageManager/interface/Configuration.h"
00019 #include "EventFilter/StorageManager/interface/DataSenderMonitorCollection.h"
00020 #include "EventFilter/StorageManager/interface/DQMTopLevelFolder.h"
00021 #include "EventFilter/StorageManager/interface/DQMKey.h"
00022 #include "EventFilter/StorageManager/interface/SharedResources.h"
00023 
00024 
00025 namespace stor {
00026   
00027   class DQMEventMonitorCollection;
00028 
00029 
00041   template<class EventType, class ConnectionType, class StateMachineType>  
00042   class DQMEventStore
00043   {
00044   public:
00045     
00046     DQMEventStore
00047     (
00048       xdaq::ApplicationDescriptor*,
00049       DQMEventQueueCollectionPtr,
00050       DQMEventMonitorCollection&,
00051       ConnectionType*,
00052       size_t (ConnectionType::*getExpectedUpdatesCount)() const,
00053       StateMachineType*,
00054       void (StateMachineType::*moveToFailedState)(xcept::Exception&),
00055       AlarmHandlerPtr
00056     );
00057 
00058     ~DQMEventStore();
00059 
00064     void setParameters(DQMProcessingParams const&);
00065 
00071     void addDQMEvent(EventType const&);
00072 
00076     void purge();
00077 
00081     void clear();
00082 
00086     bool empty()
00087     { return store_.empty(); }
00088 
00089     void moveToFailedState(xcept::Exception& sentinelException)
00090     { (stateMachineType_->*moveToFailedState_)(sentinelException); }
00091 
00092     bool doProcessCompletedTopLevelFolders()
00093     { return processCompletedTopLevelFolders_; }
00094     
00095     
00096   private:
00097 
00098     //Prevent copying of the DQMEventStore
00099     DQMEventStore(DQMEventStore const&);
00100     DQMEventStore& operator=(DQMEventStore const&);
00101 
00102     void addDQMEventToStore(EventType const&);
00103     void addDQMEventToReadyToServe(EventType const&);
00104     DQMTopLevelFolderPtr makeDQMTopLevelFolder(EventType const&);
00105     DQMEventMsgView getDQMEventView(EventType const&);
00106     bool getNextReadyTopLevelFolder(DQMTopLevelFolderPtr&);
00107     static void processCompletedTopLevelFolders(void* arg);
00108     bool handleNextCompletedTopLevelFolder();
00109     void stopProcessingCompletedTopLevelFolders();
00110 
00111     xdaq::ApplicationDescriptor* appDescriptor_;
00112     DQMProcessingParams dqmParams_;
00113     DQMEventQueueCollectionPtr dqmEventQueueCollection_;
00114     DQMEventMonitorCollection& dqmEventMonColl_;
00115     ConnectionType* connectionType_;
00116     size_t (ConnectionType::*getExpectedUpdatesCount_)() const;
00117     StateMachineType* stateMachineType_;
00118     void (StateMachineType::*moveToFailedState_)(xcept::Exception&);
00119     AlarmHandlerPtr alarmHandler_;
00120 
00121     typedef std::map<DQMKey, DQMTopLevelFolderPtr> DQMTopLevelFolderMap;
00122     DQMTopLevelFolderMap store_;
00123     static boost::mutex storeMutex_;
00124 
00125     TThread* completedFolderThread_;
00126     bool processCompletedTopLevelFolders_;
00127 
00128     std::vector<unsigned char> tempEventArea_;
00129 
00130   };
00131   
00132 } // namespace stor
00133 
00134 #endif // EventFilter_StorageManager_DQMEventStore_h 
00135 
00136