LibMultiSense
LibMultiSense Documentation
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 
49 #include "utility/Portability.hh"
50 #include "utility/TimeStamp.hh"
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 #if defined (_MSC_VER)
103 #pragma warning (push)
104 #pragma warning (disable: 4251)
105 #pragma warning (disable: 4275)
106 #endif
107 
108 class MULTISENSE_API Exception : public std::exception
109 {
110 private:
111 
112  std::string reason;
113 
114 public:
115 
116  Exception(const char *failureReason, ...);
117  Exception(const std::string& failureReason);
118  ~Exception() throw();
119 
120  virtual const char* what() const throw();
121 };
122 
123 #if defined (_MSC_VER)
124 #pragma warning (pop)
125 #endif
126 
127 }}}} // namespaces
128 
129 #endif /* #ifndef CRL_MULTISENSE_EXCEPTION_HH */
MULTISENSE_API
#define MULTISENSE_API
Definition: MultiSenseTypes.hh:57
Portability.hh
crl::multisense::details::utility::Exception::reason
std::string reason
Definition: Exception.hh:112
crl
Definition: BufferStream.hh:51
multisense
Definition: MultiSenseChannel.hh:44
TimeStamp.hh
crl::multisense::details::utility::Exception
Definition: Exception.hh:108