CARMA C++
IoLock.h
1 #ifndef SZA_UTIL_IOLOCK_H
2 #define SZA_UTIL_IOLOCK_H
3 
11 #include "carma/szautil/Mutex.h"
12 
13 #define IOCOUT(statement) \
14 {\
15  sza::util::IoLock::lockCout(); \
16  std::cout << statement << std::endl; \
17  sza::util::IoLock::unlockCout(); \
18 }
19 
20 #define IOCTOUT(statement) \
21 {\
22  sza::util::TimeVal timeVal;\
23  timeVal.setToCurrentTime();\
24  sza::util::IoLock::lockCout(); \
25  std::cout << timeVal << ": " << statement << std::endl; \
26  sza::util::IoLock::unlockCout(); \
27 }
28 
29 #define IOCERR(statement) \
30 {\
31  sza::util::IoLock::lockCerr(); \
32  std::cerr << statement << std::endl; \
33  sza::util::IoLock::unlockCerr(); \
34 }
35 
36 namespace sza {
37  namespace util {
38 
39  class IoLock {
40  public:
41 
45  virtual ~IoLock();
46 
47  static void lockCout();
48  static void unlockCout();
49  static void lockCerr();
50  static void unlockCerr();
51 
52  private:
53 
54  static Mutex coutMutex_;
55  static Mutex cerrMutex_;
56 
60  IoLock();
61 
62  }; // End class IoLock
63 
64  } // End namespace util
65 } // End namespace sza
66 
67 
68 
69 #endif // End #ifndef SZA_UTIL_IOLOCK_H
Tagged: Sat Mar 27 16:28:13 PST 2004.