Exception.hh
Go to the documentation of this file.
1 
41 #ifndef CRL_MULTISENSE_EXCEPTION_HH
42 #define CRL_MULTISENSE_EXCEPTION_HH
43 
44 #include <stdio.h>
45 #include <string.h>
46 #include <exception>
47 #include <string>
48 
51 
52 #ifdef WIN32
53 #define CRL_FILENAME \
54  (strrchr(__FILE__,'\\') \
55  ? strrchr(__FILE__,'\\')+1 \
56  : __FILE__)
57 #else
58 #define CRL_FILENAME \
59  (strrchr(__FILE__,'/') \
60  ? strrchr(__FILE__,'/')+1 \
61  : __FILE__)
62 #endif
63 
64 #ifdef CRL_DEBUG_SYSLOG
65 #include <syslog.h>
66 #define CRL_DEBUG_REDIRECTION syslog(LOG_USER|LOG_INFO,
67 #else
68 #define CRL_DEBUG_REDIRECTION fprintf(stderr,
69 #endif // CRL_DEBUG_SYSLOG
70 
71 #define CRL_DEBUG(fmt, ...) \
72  do { \
73  double now = crl::multisense::details::utility::TimeStamp::getCurrentTime().getNanoSeconds() * 1e-9; \
74  CRL_DEBUG_REDIRECTION "[%.3f] %s(%d): %s: " fmt,now,CRL_FILENAME,__LINE__, \
75  CRL_PRETTY_FUNCTION,##__VA_ARGS__); \
76  } while(0)
77 
78 #define CRL_DEBUG_RAW(fmt) \
79  do { \
80  double now = crl::multisense::details::utility::TimeStamp::getCurrentTime().getNanoSeconds() * 1e-9; \
81  CRL_DEBUG_REDIRECTION "[%.3f] %s(%d): %s: " fmt,now,CRL_FILENAME,__LINE__, \
82  CRL_PRETTY_FUNCTION); \
83  } while(0)
84 
85 #define CRL_EXCEPTION(fmt, ...) \
86  do { \
87  throw crl::multisense::details::utility::Exception("%s(%d): %s: " fmt,CRL_FILENAME,__LINE__, \
88  CRL_PRETTY_FUNCTION,##__VA_ARGS__); \
89  } while(0)
90 
91 #define CRL_EXCEPTION_RAW(fmt) \
92  do { \
93  throw crl::multisense::details::utility::Exception("%s(%d): %s: " fmt,CRL_FILENAME,__LINE__, \
94  CRL_PRETTY_FUNCTION); \
95  } while(0)
96 
97 namespace crl {
98 namespace multisense {
99 namespace details {
100 namespace utility {
101 
102 class Exception : public std::exception
103 {
104 private:
105 
106  std::string reason;
107 
108 public:
109 
110  Exception(const char *failureReason, ...);
111  Exception(const std::string& failureReason);
112  ~Exception() throw();
113 
114  virtual const char* what() const throw();
115 };
116 
117 }}}} // namespaces
118 
119 #endif /* #ifndef CRL_MULTISENSE_EXCEPTION_HH */
virtual const char * what() const
Definition: Exception.cc:120
Definition: channel.cc:58
Exception(const char *failureReason,...)
Definition: Exception.cc:88


multisense_lib
Author(s):
autogenerated on Sat Jun 24 2023 03:01:21