00001 #ifndef ARTDAQ_DAQDATA_GLOBALS_HH
00002 #define ARTDAQ_DAQDATA_GLOBALS_HH
00003
00004 #include <sstream>
00005 #include "artdaq-utilities/Plugins/MetricManager.hh"
00006
00007 #define my_rank artdaq::Globals::my_rank_
00008 #define app_name artdaq::Globals::app_name_
00009 #define metricMan artdaq::Globals::metricMan_
00010 #define seedAndRandom() artdaq::Globals::seedAndRandom_()
00011
00012
00013 #include <fcntl.h>
00014 #include <unistd.h>
00015 #include <stdlib.h>
00016
00017
00021 namespace artdaq
00022 {
00026 class Globals
00027 {
00028 public:
00029 static int my_rank_;
00030 static MetricManager* metricMan_;
00031 static std::string app_name_;
00032
00037 static uint32_t seedAndRandom_()
00038 {
00039 static bool initialized_ = false;
00040 if (!initialized_) {
00041 int fp = open("/dev/random", O_RDONLY);
00042 if (fp == -1) abort();
00043 unsigned seed;
00044 unsigned pos = 0;
00045 while (pos < sizeof(seed))
00046 {
00047 int amt = read(fp, (char *)&seed + pos, sizeof(seed) - pos);
00048 if (amt <= 0) abort();
00049 pos += amt;
00050 }
00051 srand(seed);
00052 close(fp);
00053 initialized_ = true;
00054 }
00055 return rand();
00056 }
00057 };
00058 }
00059
00060 #include "artdaq-core/Utilities/configureMessageFacility.hh"
00061 #include "tracemf.h"
00062 #include "artdaq-core/Utilities/TimeUtils.hh"
00063 #endif // ARTDAQ_DAQDATA_GLOBALS_HH