$treeview $search $mathjax $extrastylesheet
00001 #ifndef artdaq_core_Core_StatisticsCollection_hh 00002 #define artdaq_core_Core_StatisticsCollection_hh 00003 00004 #include <boost/thread.hpp> 00005 #include <map> 00006 #include <memory> 00007 #include <mutex> 00008 #include "artdaq-core/Core/MonitoredQuantity.hh" 00009 00010 namespace artdaq { 00014 typedef std::shared_ptr<MonitoredQuantity> MonitoredQuantityPtr; 00015 00022 class StatisticsCollection 00023 { 00024 public: 00029 static StatisticsCollection& getInstance(); 00030 00034 virtual ~StatisticsCollection() noexcept; 00035 00041 void addMonitoredQuantity(const std::string& name, 00042 MonitoredQuantityPtr mqPtr); 00043 00049 MonitoredQuantityPtr getMonitoredQuantity(const std::string& name) const; 00050 00054 void reset(); 00055 00059 void requestStop(); 00060 00064 void run(); 00065 00066 private: 00070 explicit StatisticsCollection(); 00071 00072 // disallow any copying 00076 StatisticsCollection(StatisticsCollection const&) = delete; // not implemented 00080 void operator=(StatisticsCollection const&) = delete; // not implemented 00081 00085 double calculationInterval_; 00089 std::map<std::string, MonitoredQuantityPtr> monitoredQuantityMap_; 00090 00094 bool thread_stop_requested_; 00098 std::unique_ptr<boost::thread> calculation_thread_; 00099 00103 mutable std::mutex map_mutex_; 00104 }; 00105 } // namespace artdaq 00106 00107 #endif /* artdaq_core_Core_StatisticsCollection_hh */