]> Creatis software - crea.git/commitdiff
*** empty log message ***
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Wed, 16 Sep 2009 12:28:57 +0000 (12:28 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Wed, 16 Sep 2009 12:28:57 +0000 (12:28 +0000)
src/creaMessageManager.h
src/creaSystem.cxx
src/creaVtk.h
src/creaVtk.txx

index 37fe5bf1e65a0acdf678b97b1c9a73a0de4dfe22..87fb5f887c9773b5120c2ec75cb8f213de3ef58e 100644 (file)
-\r
-/*! \file\r
\r
-  \brief Class creaMessageManager and Macros for outputing messages in crea\r
-\r
-  There are 4 kinds of messages :\r
-  - Messages (normal messages)\r
-  - Debug messages (not compiled in release)\r
-  - Warnings \r
-  - Errors\r
-  There are also "types" of messages which are strings which identify the nature of the message \r
-  (for example : "Kernel" messages are generated by the core classes of the library, there can be a type of \r
-  message for each type of Node, and so on...)\r
-  A type of message must be declared by registering it into the MessageManager. This is done by a line like :\r
-  crea::MessageManager::RegisterMessageType("Kernel","Messages generated by the core classes of the library",5);\r
-  where : \r
-  -The first string is the type of the message (the category which will be used to generate a message of this type)\r
-  -The second string is help string\r
-  -The integer is the initial level for the messages of this type (see below).\r
-  \r
-  To generate a message of a known type then use one of the macros :\r
-  creaMessage, creaDebugMessage, creaWarning, creaError or their variants.\r
-\r
-  example :\r
-\r
-  creaMessage("Kernel",4,"problem with "<<GetName()<<creaendl);\r
-\r
-  will push the 3rd argument in std::cout if the message level of "Kernel" messages is greater or equal to 4.\r
-  which means that it generates a message of level 4 (0 : very important/always displayed ... 9 : deep debug message).\r
-\r
-  At run time, one is able to change the level of the messages displayed by using a command like :\r
-  \r
-  crea::MessageManager::SetMessageLevel("Kernel",5); \r
-  \r
-  which tells the manager to display all Kernel messages of level up to 5.\r
-\r
-  Variants :\r
-\r
-  crea*Cont : continues a previous creaMessage on the same line (without rewriting the type and level)\r
-  crea*Inc / Dec : displays the message and then increments/decrement the messages tabulation \r
-\r
-*/\r
-  //===========================================================\r
-  /**\r
-     \class crea::MessageManager\r
-     \brief Manages the messages displayed by crea\r
-  */\r
-\r
-\r
-#ifndef __creaMessageManager_h__\r
-#define __creaMessageManager_h__\r
-\r
-// The do { } while(0) statement in macros is made to "swallow the semicolon" \r
-// see http://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html#Swallowing-the-Semicolon\r
-\r
-#include "creaSystem.h"\r
-#include "creaRTTI.h" // for CREA_GET_CURRENT_OBJECT_NAME\r
-// Signal/slot mechanism for message events\r
-#include <boost/signal.hpp>\r
-#include <boost/bind.hpp>\r
-\r
-#include <string>\r
-#include <map>\r
-#include <iostream>\r
-#include <sstream>\r
-\r
-// Comment out these symbols to prevent compilation \r
-//#define CREA_COMPILE_MESSAGES\r
-//#define CREA_COMPILE_DEBUG_MESSAGES\r
-//#define CREA_COMPILE_WARNING_MESSAGES\r
-//#define CREA_COMPILE_ERROR_MESSAGES\r
-\r
-\r
-#define creaOnMessageLevel(key,value)                  \\r
-  int __creaOnMessageLevelVariable =                   \\r
-    crea::MessageManager::GetMessageLevel(key);                \\r
-  if ( __creaOnMessageLevelVariable<0)                 \\r
-    {                                                  \\r
-      creaWarning("message type '"<<key<<"' unknown"); \\r
-    }                                                  \\r
-  else if (value<= __creaOnMessageLevelVariable) \r
-\r
-#ifdef CREA_PREPEND_MESSAGE_WITH_CODE\r
-#define creaMessageCode                                \\r
-  key[0] << key[1] << key[2] << value << " "\r
-#else \r
-#define creaMessageCode ""\r
-#endif \r
-\r
-#ifdef CREA_PREPEND_MESSAGE_WITH_TAB\r
-#define creaMessageTab                         \\r
-  crea::MessageManager::GetTab()\r
-#else \r
-#define creaMessageTab ""\r
-#endif\r
-\r
-//#define CREA_PREPEND_MESSAGE_WITH_SPACE\r
-#ifdef CREA_PREPEND_MESSAGE_WITH_SPACE\r
-#define creaMessageSpace(value)                        \\r
-  crea::MessageManager::GetSpace(value)\r
-#else \r
-#define creaMessageSpace(value) ""\r
-#endif\r
\r
-\r
-//===========================================================\r
-#ifdef CREA_COMPILE_MESSAGES\r
-\r
-// Macro for messages\r
-#define creaMessage(key,value,MESSAGE)                 \\r
-  do {                                                 \\r
-    creaOnMessageLevel(key,value)                      \\r
-      {                                                        \\r
-       std::ostringstream s;                           \\r
-       s << creaMessageCode                            \\r
-         << creaMessageTab                             \\r
-         << creaMessageSpace(value)                    \\r
-         << MESSAGE;                                   \\r
-       crea::MessageManager::SendMessage(key,s.str()); \\r
-      }                                                        \\r
-  }                                                    \\r
-  while (0)\r
-\r
-// Macro for continuing a message (when one wants to split the macro\r
-// call into multiple lines)\r
-#define creaMessageCont(key,value,MESSAGE)             \\r
-  do                                                   \\r
-    {                                                  \\r
-      creaOnMessageLevel(key,value)                    \\r
-       {                                               \\r
-       std::ostringstream s;                           \\r
-       s << MESSAGE;                                   \\r
-       crea::MessageManager::SendMessage(key,s.str()); \\r
-       }                                               \\r
-    }                                                  \\r
-  while (0)\r
-\r
-#define creaMessageInc(key,value,MESSAGE)              \\r
-  do                                                   \\r
-    {                                                  \\r
-       std::ostringstream s;                           \\r
-       s << creaMessageCode                            \\r
-         << creaMessageTab                             \\r
-         << creaMessageSpace(value)                    \\r
-         << MESSAGE;                                   \\r
-       crea::MessageManager::SendMessage(key,s.str()); \\r
-       crea::MessageManager::IncTab();                 \\r
-       }                                               \\r
-    }                                                  \\r
-  while (0)\r
-\r
-#define creaMessageDec(key,value,MESSAGE)                      \\r
-  do                                                           \\r
-    {                                                          \\r
-      creaOnMessageLevel(key,value)                            \\r
-       {                                                       \\r
-         crea::MessageManager::DecTab();                       \\r
-         std::ostringstream s;                                 \\r
-         s << creaMessageCode                                  \\r
-           << creaMessageTab                                   \\r
-           << creaMessageSpace(value)                          \\r
-           << MESSAGE;                                         \\r
-         crea::MessageManager::SendMessage(key,s.str());       \\r
-       }                                                       \\r
-    }                                                          \\r
-  while (0)\r
-\r
-#define creaDecTab(key,value)                  \\r
-  do                                           \\r
-    {                                          \\r
-      creaOnMessageLevel(key,value)            \\r
-       {                                       \\r
-         crea::MessageManager::DecTab();       \\r
-       }                                       \\r
-    }                                          \\r
-  while (0)\r
-\r
-#define creaIncTab(key,value)                  \\r
-  do                                           \\r
-    {                                          \\r
-      creaOnMessageLevel(key,value)            \\r
-       {                                       \\r
-         crea::MessageManager::IncTab();       \\r
-       }                                       \\r
-    }                                          \\r
-  while (0)\r
-\r
-#define creaResetTab()                         \\r
-  do                                           \\r
-    {                                          \\r
-      crea::MessageManager::ResetTab();                \\r
-    }                                          \\r
-  while (0)\r
-\r
-#else\r
-#define creaMessage(key,value,MESSAGE)\r
-#define creaMessageInc(key,value,MESSAGE)\r
-#define creaMessageDec(key,value,MESSAGE)\r
-#define creaMessageCont(key,value,MESSAGE)\r
-#define creaDecTab(key,value)\r
-#define creaIncTab(key,value)\r
-#define creaResetTab()\r
-#endif\r
-//===========================================================\r
-\r
-\r
-\r
-//===========================================================\r
-// Macros for debug messages\r
-#ifdef CREA_COMPILE_DEBUG_MESSAGES\r
-#define creaDebugMessage(key,value,MESSAGE) creaMessage(key,value,MESSAGE)\r
-#define creaDebugMessageCont(key,value,MESSAGE)        creaMessageCont(key,value,MESSAGE)\r
-#define creaDebugMessageInc(key,value,MESSAGE) creaMessageInc(key,value,MESSAGE)  \r
-#define creaDebugMessageDec(key,value,MESSAGE) creaMessageDec(key,value,MESSAGE)\r
-#define creaDebugDecTab(key,value) creaDecTab(key,value)\r
-#define creaDebugIncTab(key,value) creaIncTab(key,value)\r
-#define creaDebugResetTab() creaResetTab()\r
-#else\r
-#define creaDebugMessage(key,value,MESSAGE) \r
-#define creaDebugMessageCont(key,value,MESSAGE) \r
-#define creaDebugMessageInc(key,value,MESSAGE)\r
-#define creaDebugMessageDec(key,value,MESSAGE) \r
-#define creaDebugDecTab(key,value)\r
-#define creaDebugIncTab(key,value)\r
-#endif\r
-//===========================================================\r
-\r
-//===========================================================\r
-#ifdef CREA_COMPILE_WARNING_MESSAGES\r
-#define creaWarning(MESSAGE)                                           \\r
-  do                                                                   \\r
-    {                                                                  \\r
-      int lev = crea::MessageManager::GetMessageLevel("warning");      \\r
-      if (lev >0)                                                      \\r
-       {                                                               \\r
-         std::cerr << "!! WARNING !! " << MESSAGE << std::endl;        \\r
-         if (lev >1)                                                   \\r
-           {                                                           \\r
-             std::cerr << "!! WARNING !! In file '"<<__FILE__          \\r
-                       <<"' ; Line "<<__LINE__<<std::endl;             \\r
-           }                                                           \\r
-       }                                                               \\r
-    }                                                                  \\r
-  while (0) \r
-\r
-#else\r
-#define creaWarning(MESSAGE) \r
-#endif\r
-//===========================================================\r
-\r
-\r
-//===========================================================\r
-#ifdef CREA_COMPILE_ERROR_MESSAGES\r
-//#include "creaWx.h"\r
-#define creaError(MESSAGE)                             \\r
-  do                                                   \\r
-    {                                                  \\r
-      std::ostringstream s;                            \\r
-      s << MESSAGE;                                    \\r
-      std::ostringstream f;                            \\r
-      f << __FILE__ << " (l."<<__LINE__<<")";          \\r
-      crea::Exception e( CREA_GET_CURRENT_OBJECT_NAME, \\r
-                       f.str(),                        \\r
-                       s.str());                       \\r
-      throw e;                                         \\r
-    }                                                  \\r
-  while (0) \r
-\r
-#define creaGlobalError(MESSAGE)                               \\r
-  do                                                   \\r
-    {                                                  \\r
-      std::ostringstream s;                            \\r
-      s << MESSAGE;                                    \\r
-      std::ostringstream f;                            \\r
-      f << __FILE__ << " (l."<<__LINE__<<")";          \\r
-      crea::Exception e( "global scope",               \\r
-                       f.str(),                        \\r
-                       s.str());                       \\r
-      throw e;                                         \\r
-    }                                                  \\r
-  while (0) \r
-\r
-#define CREA_INTERNAL_ERROR_MESSAGE \\r
-  "\n\n***********************************************\n**** THIS IS AN INTERNAL ERROR TO crea     ****\n**** Please send a full bug report to :    ****\n****  creatools@creatis.insa-lyon.fr ****\n***********************************************\n\n"\r
-\r
-#define creaInternalError(MESSAGE)                     \\r
-  do                                                   \\r
-    {                                                  \\r
-      std::ostringstream s;                            \\r
-      s << MESSAGE << CREA_INTERNAL_ERROR_MESSAGE;     \\r
-      std::ostringstream f;                            \\r
-      f << __FILE__ << " (l."<<__LINE__<<")";          \\r
-      crea::Exception e( CREA_GET_CURRENT_OBJECT_NAME, \\r
-                        f.str(),                       \\r
-                        s.str());                      \\r
-      throw e;                                         \\r
-    }                                                  \\r
-  while (0) \r
-\r
-#else\r
-#define creaError(MESSAGE)\r
-#define creaGlobalError(MESSAGE)\r
-#define creaInternalError(MESSAGE)\r
-#endif\r
-//===========================================================\r
-\r
-//===========================================================\r
-#define creaendl std::endl\r
-//===========================================================\r
-\r
-\r
-namespace crea \r
-{\r
-  \r
-  class CREA_EXPORT MessageManager\r
-  {\r
-  public:\r
-    //=============================================\r
-    typedef boost::signal<void (const std::string&)>  MessageSignalType;\r
-    typedef MessageSignalType::slot_function_type MessageCallbackType;\r
-    //=============================================\r
-    ///\r
-    MessageManager();\r
-    ///\r
-    ~MessageManager();\r
-    ///\r
-    static MessageManager* GetInstance();\r
-    ///\r
-    static void RegisterMessageType(const std::string& key, \r
-                                    const std::string& help,\r
-                                    unsigned char default_level = 9);\r
-    ///\r
-    static void SetMessageLevel(const std::string& key, unsigned char level);\r
-    ///\r
-    static int GetMessageLevel(const std::string& key);\r
-    ///  \r
-    static void SendMessage(const std::string& key, const std::string& mess);\r
-    ///\r
-    static void AddMessageObserver(const std::string& key, MessageCallbackType callback );\r
-    ///\r
-    static void SendMessagesToCout(bool v = true);\r
-    ///\r
-    static std::string& GetTab() { static std::string s; return s; }\r
-    ///\r
-    static std::string GetSpace(int n) { \r
-      std::string s; s.insert(0,"                ",n); return s; }\r
-    ///\r
-    static void IncTab() { GetTab() += std::string(" "); }\r
-    ///\r
-    static void DecTab() { GetTab() = GetTab().substr(0,GetTab().length()-1); }\r
-    ///\r
-    static void ResetTab() { GetTab() = std::string(""); }\r
-    ///\r
-    static void PrintInfo();\r
-    /// \r
-    \r
-  private:\r
-    struct MessageType\r
-    {\r
-      MessageType(int l, const std::string& h) : Level(l), Help(h) {}\r
-      int Level;\r
-      std::string Help;\r
-      MessageSignalType Signal;\r
-    };\r
-    typedef std::map<std::string,MessageType*> MessageMapType;\r
-    MessageMapType mMessageMap;\r
-    unsigned int mMaxMessageLength;\r
-    bool mSendToCout;\r
-  };\r
-  //===========================================================\r
-  \r
-}\r
-\r
-#include "creaException.h"\r
-\r
-#endif\r
+
+
+/*! \file
+
+
+  \brief Class creaMessageManager and Macros for outputing messages in crea
+
+
+
+  There are 4 kinds of messages :
+
+  - Messages (normal messages)
+
+  - Debug messages (not compiled in release)
+
+  - Warnings 
+
+  - Errors
+
+  There are also "types" of messages which are strings which identify the nature of the message 
+
+  (for example : "Kernel" messages are generated by the core classes of the library, there can be a type of 
+
+  message for each type of Node, and so on...)
+
+  A type of message must be declared by registering it into the MessageManager. This is done by a line like :
+
+  crea::MessageManager::RegisterMessageType("Kernel","Messages generated by the core classes of the library",5);
+
+  where : 
+
+  -The first string is the type of the message (the category which will be used to generate a message of this type)
+
+  -The second string is help string
+
+  -The integer is the initial level for the messages of this type (see below).
+
+  
+
+  To generate a message of a known type then use one of the macros :
+
+  creaMessage, creaDebugMessage, creaWarning, creaError or their variants.
+
+
+
+  example :
+
+
+
+  creaMessage("Kernel",4,"problem with "<<GetName()<<creaendl);
+
+
+
+  will push the 3rd argument in std::cout if the message level of "Kernel" messages is greater or equal to 4.
+
+  which means that it generates a message of level 4 (0 : very important/always displayed ... 9 : deep debug message).
+
+
+
+  At run time, one is able to change the level of the messages displayed by using a command like :
+
+  
+
+  crea::MessageManager::SetMessageLevel("Kernel",5); 
+
+  
+
+  which tells the manager to display all Kernel messages of level up to 5.
+
+
+
+  Variants :
+
+
+
+  crea*Cont : continues a previous creaMessage on the same line (without rewriting the type and level)
+
+  crea*Inc / Dec : displays the message and then increments/decrement the messages tabulation 
+
+
+
+*/
+
+  //===========================================================
+
+  /**
+
+     \class crea::MessageManager
+
+     \brief Manages the messages displayed by crea
+
+  */
+
+
+
+
+
+#ifndef __creaMessageManager_h__
+
+#define __creaMessageManager_h__
+
+
+
+// The do { } while(0) statement in macros is made to "swallow the semicolon" 
+
+// see http://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html#Swallowing-the-Semicolon
+
+
+
+#include "creaSystem.h"
+
+#include "creaRTTI.h" // for CREA_GET_CURRENT_OBJECT_NAME
+
+// Signal/slot mechanism for message events
+
+#include <boost/signal.hpp>
+
+#include <boost/bind.hpp>
+
+
+
+#include <string>
+
+#include <map>
+
+#include <iostream>
+
+#include <sstream>
+
+
+
+// Comment out these symbols to prevent compilation 
+
+//#define CREA_COMPILE_MESSAGES
+
+//#define CREA_COMPILE_DEBUG_MESSAGES
+
+//#define CREA_COMPILE_WARNING_MESSAGES
+
+//#define CREA_COMPILE_ERROR_MESSAGES
+
+
+
+
+
+#define creaOnMessageLevel(key,value)                  \
+  int __creaOnMessageLevelVariable =                   \
+    crea::MessageManager::GetMessageLevel(key);                \
+  if ( __creaOnMessageLevelVariable<0)                 \
+    {                                                  \
+      creaWarning("message type '"<<key<<"' unknown"); \
+    }                                                  \
+  else if (value<= __creaOnMessageLevelVariable) 
+
+
+
+#ifdef CREA_PREPEND_MESSAGE_WITH_CODE
+#define creaMessageCode                                \
+  key[0] << key[1] << key[2] << value << " "
+#else 
+#define creaMessageCode ""
+#endif 
+
+
+
+#ifdef CREA_PREPEND_MESSAGE_WITH_TAB
+#define creaMessageTab                         \
+  crea::MessageManager::GetTab()
+#else 
+#define creaMessageTab ""
+#endif
+
+
+
+//#define CREA_PREPEND_MESSAGE_WITH_SPACE
+#ifdef CREA_PREPEND_MESSAGE_WITH_SPACE
+#define creaMessageSpace(value)                        \
+  crea::MessageManager::GetSpace(value)
+#else 
+#define creaMessageSpace(value) ""
+#endif
+
+
+
+
+//===========================================================
+
+#ifdef CREA_COMPILE_MESSAGES
+
+// Macro for messages
+#define creaMessage(key,value,MESSAGE)                 \
+  do {                                                 \
+    creaOnMessageLevel(key,value)                      \
+      {                                                        \
+       std::ostringstream s;                           \
+       s << creaMessageCode                            \
+         << creaMessageTab                             \
+         << creaMessageSpace(value)                    \
+         << MESSAGE;                                   \
+       crea::MessageManager::SendMessage(key,s.str()); \
+      }                                                        \
+  }                                                    \
+  while (0)
+
+
+
+// Macro for continuing a message (when one wants to split the macro
+// call into multiple lines)
+#define creaMessageCont(key,value,MESSAGE)             \
+  do                                                   \
+    {                                                  \
+      creaOnMessageLevel(key,value)                    \
+       {                                               \
+       std::ostringstream s;                           \
+       s << MESSAGE;                                   \
+       crea::MessageManager::SendMessage(key,s.str()); \
+       }                                               \
+    }                                                  \
+  while (0)
+
+
+#define creaMessageInc(key,value,MESSAGE)              \
+  do                                                   \
+    {                                                  \
+       std::ostringstream s;                           \
+       s << creaMessageCode                            \
+         << creaMessageTab                             \
+         << creaMessageSpace(value)                    \
+         << MESSAGE;                                   \
+       crea::MessageManager::SendMessage(key,s.str()); \
+       crea::MessageManager::IncTab();                 \
+       }                                               \
+    }                                                  \
+  while (0)
+
+
+#define creaMessageDec(key,value,MESSAGE)                      \
+  do                                                           \
+    {                                                          \
+      creaOnMessageLevel(key,value)                            \
+       {                                                       \
+         crea::MessageManager::DecTab();                       \
+         std::ostringstream s;                                 \
+         s << creaMessageCode                                  \
+           << creaMessageTab                                   \
+           << creaMessageSpace(value)                          \
+           << MESSAGE;                                         \
+         crea::MessageManager::SendMessage(key,s.str());       \
+       }                                                       \
+    }                                                          \
+  while (0)
+
+
+#define creaDecTab(key,value)                  \
+  do                                           \
+    {                                          \
+      creaOnMessageLevel(key,value)            \
+       {                                       \
+         crea::MessageManager::DecTab();       \
+       }                                       \
+    }                                          \
+  while (0)
+
+
+#define creaIncTab(key,value)                  \
+  do                                           \
+    {                                          \
+      creaOnMessageLevel(key,value)            \
+       {                                       \
+         crea::MessageManager::IncTab();       \
+       }                                       \
+    }                                          \
+  while (0)
+
+
+#define creaResetTab()                         \
+  do                                           \
+    {                                          \
+      crea::MessageManager::ResetTab();                \
+    }                                          \
+  while (0)
+
+#else
+#define creaMessage(key,value,MESSAGE)
+#define creaMessageInc(key,value,MESSAGE)
+#define creaMessageDec(key,value,MESSAGE)
+#define creaMessageCont(key,value,MESSAGE)
+#define creaDecTab(key,value)
+#define creaIncTab(key,value)
+#define creaResetTab()
+#endif
+
+//===========================================================
+
+
+
+
+
+
+
+//===========================================================
+
+// Macros for debug messages
+
+#ifdef CREA_COMPILE_DEBUG_MESSAGES
+
+#define creaDebugMessage(key,value,MESSAGE) creaMessage(key,value,MESSAGE)
+
+#define creaDebugMessageCont(key,value,MESSAGE)        creaMessageCont(key,value,MESSAGE)
+
+#define creaDebugMessageInc(key,value,MESSAGE) creaMessageInc(key,value,MESSAGE)  
+
+#define creaDebugMessageDec(key,value,MESSAGE) creaMessageDec(key,value,MESSAGE)
+
+#define creaDebugDecTab(key,value) creaDecTab(key,value)
+
+#define creaDebugIncTab(key,value) creaIncTab(key,value)
+
+#define creaDebugResetTab() creaResetTab()
+
+#else
+
+#define creaDebugMessage(key,value,MESSAGE) 
+
+#define creaDebugMessageCont(key,value,MESSAGE) 
+
+#define creaDebugMessageInc(key,value,MESSAGE)
+
+#define creaDebugMessageDec(key,value,MESSAGE) 
+
+#define creaDebugDecTab(key,value)
+
+#define creaDebugIncTab(key,value)
+
+#endif
+
+//===========================================================
+
+
+
+//===========================================================
+
+#ifdef CREA_COMPILE_WARNING_MESSAGES
+#define creaWarning(MESSAGE)                                           \
+  do                                                                   \
+    {                                                                  \
+      int lev = crea::MessageManager::GetMessageLevel("warning");      \
+      if (lev >0)                                                      \
+       {                                                               \
+         std::cerr << "!! WARNING !! " << MESSAGE << std::endl;        \
+         if (lev >1)                                                   \
+           {                                                           \
+             std::cerr << "!! WARNING !! In file '"<<__FILE__          \
+                       <<"' ; Line "<<__LINE__<<std::endl;             \
+           }                                                           \
+       }                                                               \
+    }                                                                  \
+  while (0) 
+
+#else
+#define creaWarning(MESSAGE) 
+#endif
+
+//===========================================================
+
+
+
+
+
+//===========================================================
+
+#ifdef CREA_COMPILE_ERROR_MESSAGES
+//#include "creaWx.h"
+#define creaError(MESSAGE)                             \
+  do                                                   \
+    {                                                  \
+      std::ostringstream s;                            \
+      s << MESSAGE;                                    \
+      std::ostringstream f;                            \
+      f << __FILE__ << " (l."<<__LINE__<<")";          \
+      crea::Exception e( CREA_GET_CURRENT_OBJECT_NAME, \
+                       f.str(),                        \
+                       s.str());                       \
+      throw e;                                         \
+    }                                                  \
+  while (0) 
+
+
+
+#define creaGlobalError(MESSAGE)                               \
+  do                                                   \
+    {                                                  \
+      std::ostringstream s;                            \
+      s << MESSAGE;                                    \
+      std::ostringstream f;                            \
+      f << __FILE__ << " (l."<<__LINE__<<")";          \
+      crea::Exception e( "global scope",               \
+                       f.str(),                        \
+                       s.str());                       \
+      throw e;                                         \
+    }                                                  \
+  while (0) 
+
+
+
+#define CREA_INTERNAL_ERROR_MESSAGE \
+  "\n\n***********************************************\n**** THIS IS AN INTERNAL ERROR TO crea     ****\n**** Please send a full bug report to :    ****\n****  creatools@creatis.insa-lyon.fr ****\n***********************************************\n\n"
+
+#define creaInternalError(MESSAGE)                     \
+  do                                                   \
+    {                                                  \
+      std::ostringstream s;                            \
+      s << MESSAGE << CREA_INTERNAL_ERROR_MESSAGE;     \
+      std::ostringstream f;                            \
+      f << __FILE__ << " (l."<<__LINE__<<")";          \
+      crea::Exception e( CREA_GET_CURRENT_OBJECT_NAME, \
+                        f.str(),                       \
+                        s.str());                      \
+      throw e;                                         \
+    }                                                  \
+  while (0) 
+
+
+
+#else
+#define creaError(MESSAGE)
+#define creaGlobalError(MESSAGE)
+#define creaInternalError(MESSAGE)
+#endif
+
+//===========================================================
+
+
+
+//===========================================================
+
+#define creaendl std::endl
+
+//===========================================================
+
+
+
+
+
+namespace crea 
+
+{
+
+  
+
+  class CREA_EXPORT MessageManager
+
+  {
+
+  public:
+
+    //=============================================
+
+    typedef boost::signal<void (const std::string&)>  MessageSignalType;
+
+    typedef MessageSignalType::slot_function_type MessageCallbackType;
+
+    //=============================================
+
+    ///
+
+    MessageManager();
+
+    ///
+
+    ~MessageManager();
+
+    ///
+
+    static MessageManager* GetInstance();
+
+    ///
+
+    static void RegisterMessageType(const std::string& key, 
+
+                                    const std::string& help,
+
+                                    unsigned char default_level = 9);
+
+    ///
+
+    static void SetMessageLevel(const std::string& key, unsigned char level);
+
+    ///
+
+    static int GetMessageLevel(const std::string& key);
+
+    ///  
+
+    static void SendMessage(const std::string& key, const std::string& mess);
+
+    ///
+
+    static void AddMessageObserver(const std::string& key, MessageCallbackType callback );
+
+    ///
+
+    static void SendMessagesToCout(bool v = true);
+
+    ///
+
+    static std::string& GetTab() { static std::string s; return s; }
+
+    ///
+
+    static std::string GetSpace(int n) { 
+
+      std::string s; s.insert(0,"                ",n); return s; }
+
+    ///
+
+    static void IncTab() { GetTab() += std::string(" "); }
+
+    ///
+
+    static void DecTab() { GetTab() = GetTab().substr(0,GetTab().length()-1); }
+
+    ///
+
+    static void ResetTab() { GetTab() = std::string(""); }
+
+    ///
+
+    static void PrintInfo();
+
+    /// 
+
+    
+
+  private:
+
+    struct MessageType
+
+    {
+
+      MessageType(int l, const std::string& h) : Level(l), Help(h) {}
+
+      int Level;
+
+      std::string Help;
+
+      MessageSignalType Signal;
+
+    };
+
+    typedef std::map<std::string,MessageType*> MessageMapType;
+
+    MessageMapType mMessageMap;
+
+    unsigned int mMaxMessageLength;
+
+    bool mSendToCout;
+
+  };
+
+  //===========================================================
+
+  
+
+}
+
+
+
+#include "creaException.h"
+
+
+
+#endif
+
index 460bb7fb53c5756fbb966d11d4f912dc982c9d9e..7225884dd445252b2f44d9c45a0727eb4a4c24ed 100644 (file)
@@ -43,12 +43,9 @@ namespace crea
      return isatty(fileno(stdin));
    }
 #endif
-std::string System::GetDllAppPath(std::string nom){
-       std::string path = ".";
-#ifdef WIN32
-#endif
-       return path;
-}
+
+
+
 int System::GetAppPath(char *pname, size_t pathsize)
    {
 #ifdef LINUX   
@@ -171,6 +168,7 @@ int System::GetAppPath(char *pname, size_t pathsize)
     return -1; /* Path Lookup Failed */
 } 
 
+
 std::string System::GetDllAppPath(std::string nomdll){
        std::string path = ".";
 #ifdef WIN32
index 417438ec74ae765460c55abac4725e71db73e962..7302e984afc0f059f310b45db8cd558e8ac74af9 100644 (file)
@@ -10,7 +10,7 @@ namespace crea
 {
 
   template <class T>
-  vtkImageData* CREA_EXPORT NewVtkImageDataFromRaw( T* data,
+  vtkImageData* /*CREA_EXPORT*/ NewVtkImageDataFromRaw( T* data,
                                                    int nx, 
                                                    int ny,
                                                    int nz,
index f0ea5be8a63e56d69591120f3cbb6f4088581cb3..7fd3539d656650176bf94d83ed150fda09785754 100644 (file)
@@ -19,7 +19,7 @@ namespace crea
 {
   
   template <class T>
-  vtkImageData* CREA_EXPORT NewVtkImageDataFromRaw( T* data,
+  vtkImageData* /*CREA_EXPORT*/ NewVtkImageDataFromRaw( T* data,
                                                    int nx, 
                                                    int ny,
                                                    int nz,