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