source: fact/drsdaq/VME/atlas/include/DFDebug/GlobalDebugSettings.h@ 18340

Last change on this file since 18340 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
  • Property svn:executable set to *
File size: 1.6 KB
Line 
1// -*- c++ -*-
2/************************************************/
3/* file: GlobalDebugSettings.h */
4/* description: Class GlobalDebugSettings */
5/* maintainer: Markus Joos, CERN/PH-ESS */
6/************************************************/
7
8#ifndef DFGLOBALDEBUGSETTINGS_H
9#define DFGLOBALDEBUGSETTINGS_H
10
11#include <pthread.h>
12
13namespace DF
14{
15 class GlobalDebugSettings
16 {
17 public:
18 static unsigned int traceLevel();
19 static unsigned int packageId();
20 static void lock();
21 static void unlock();
22 static void setup(unsigned int traceLevel,unsigned int packageId = 0);
23 private:
24 static unsigned int s_traceLevel;
25 static unsigned int s_packageId;
26 static int s_mutexLocked;
27 static pthread_mutex_t debug_mutex;
28 static pthread_t s_mutexOwner;
29 };
30
31 inline unsigned int GlobalDebugSettings::traceLevel()
32 {
33 return(s_traceLevel);
34 }
35
36 inline unsigned int GlobalDebugSettings::packageId()
37 {
38 return(s_packageId);
39 }
40
41 inline void GlobalDebugSettings::lock()
42 {
43 if ((s_mutexLocked == 0) || (pthread_equal(s_mutexOwner, pthread_self()) == 0))
44 {
45 pthread_mutex_lock(&debug_mutex);
46 s_mutexOwner = pthread_self();
47 }
48 s_mutexLocked++;
49 }
50
51 inline void GlobalDebugSettings::unlock()
52 {
53 s_mutexLocked--;
54 if (s_mutexLocked == 0)
55 pthread_mutex_unlock(&debug_mutex);
56 }
57
58 inline void GlobalDebugSettings::setup(unsigned int traceLevel, unsigned int packageId)
59 {
60 s_traceLevel = traceLevel;
61 s_packageId = packageId;
62 }
63
64} // end of namespace DF
65#endif //DFGLOBALDEBUGSETTINGS_H
66
Note: See TracBrowser for help on using the repository browser.