]> Creatis software - clitk.git/blobdiff - common/clitkCommon.h
Revert "itkv4 migration use itk::ThreadIdType"
[clitk.git] / common / clitkCommon.h
index 31f28dc40637bd95e91dfec7974f23183edd43ac..769ca63f0bf4400cbb783cf53d3bd7b44b3fc293 100644 (file)
@@ -48,6 +48,24 @@ namespace clitk {
   typedef unsigned char uchar;
   typedef unsigned short ushort;
   typedef unsigned int uint;
+  
+#define CLITK_TRY_CATCH_EXIT(func) \
+  try { \
+    func; \
+  } \
+  catch (const itk::ExceptionObject& e) { \
+    e.Print(std::cout); \
+    exit(-1);\
+  } \
+  catch (const std::exception& e) { \
+    std::cout << e.what() << std::endl; \
+    exit(-2);\
+  } \
+  catch (...) { \
+    std::cout << "Unknown excpetion" << std::endl; \
+    exit(-3); \
+  }
+    
 
   //--------------------------------------------------------------------
   // when everything goes wrong
@@ -209,6 +227,13 @@ namespace clitk {
   //--------------------------------------------------------------------
   void PrintMemoryUsed();
 
+  //--------------------------------------------------------------------
+  // Convert a map to a vector
+  template <typename M, typename V> 
+  void MapToVecFirst(const M & m, V & v);
+  template <typename M, typename V> 
+  void MapToVecSecond(const M & m, V & v);
+
 #include "clitkCommon.txx"
 
 } // end namespace