LibMultiSense
LibMultiSense Documentation
Loading...
Searching...
No Matches
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
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
97namespace crl {
98namespace multisense {
99namespace details {
100namespace utility {
101
102#if defined (_MSC_VER)
103#pragma warning (push)
104#pragma warning (disable: 4251)
105#pragma warning (disable: 4275)
106#endif
107
108class MULTISENSE_API Exception : public std::exception
109{
110private:
111
112 std::string reason;
113
114public:
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 */
#define MULTISENSE_API
Macros and symbols to help portability between different compiler versions.
The timestamp class gives some type-safety and helper routines for managing time stamps.