Image Utilities (IU)
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Groups Pages
coredefs.h
1 #pragma once
2 
3 #include <stdio.h>
4 #include <assert.h>
5 #include <iostream>
6 #include <sstream>
7 
15 #ifdef DEBUG
16 #define IU_ASSERT(C) \
17  do { \
18  if (!(C)) \
19  { \
20  fprintf(stderr, "%s(%d) : assertion '%s' failed!\n", \
21  __FILE__, __LINE__, #C ); \
22  abort(); \
23  } \
24  } while(false)
25 #else //DEBUG
26 #define IU_ASSERT(C)
27 #endif //DEBUG
28 
32 class IuException : public std::exception
33 {
34 public:
35  IuException(const std::string& msg, const char* file=NULL, const char* function=NULL, int line=0) throw():
36  msg_(msg),
37  file_(file),
38  function_(function),
39  line_(line)
40  {
41  std::ostringstream out_msg;
42 
43  out_msg << "IuException: ";
44  out_msg << (msg_.empty() ? "unknown error" : msg_) << "\n";
45  out_msg << " where: ";
46  out_msg << (file_.empty() ? "no filename available" : file_) << " | ";
47  out_msg << (function_.empty() ? "unknown function" : function_) << ":" << line_;
48  msg_ = out_msg.str();
49  }
50 
51  virtual ~IuException() throw()
52  { }
53 
54  virtual const char* what() const throw()
55  {
56  return msg_.c_str();
57  }
58 
59  std::string msg_;
60  std::string file_;
61  std::string function_;
62  int line_;
63 }; // class
64 
66 typedef enum
67 {
68  IU_INTERPOLATE_NEAREST,
69  IU_INTERPOLATE_LINEAR
70 } IuInterpolationType;
71 
72 namespace iu {
78 static inline /*__device__ __host__*/ unsigned int divUp(unsigned int a, unsigned int b)
79 {
80  return (a % b != 0) ? (a / b + 1) : (a / b);
81 }
82 
83 } // namespace iu
84 
85 
86 
Exceptions with additional error information.
Definition: coredefs.h:32