]> Creatis software - gdcm.git/commitdiff
* Add Command and CommandManager to have possible callback
authorregrain <regrain>
Mon, 28 Nov 2005 15:20:29 +0000 (15:20 +0000)
committerregrain <regrain>
Mon, 28 Nov 2005 15:20:29 +0000 (15:20 +0000)
     on Error/Warning/Debug and too on Progression.
     So more callback types can be added
   * Change the gdcm::Debug macros to have the Command call
   * Change the method names in gdcm::Debug to be more correct of their
     goal
   -- BeNours

42 files changed:
Testing/CMakeLists.txt
Testing/TestCommand.cxx [new file with mode: 0644]
Testing/TestMakeDicomDir.cxx
Testing/TestUtil.cxx
src/CMakeLists.txt
src/gdcmCallbackCommand.cxx [new file with mode: 0644]
src/gdcmCallbackCommand.h [new file with mode: 0644]
src/gdcmCommand.cxx [new file with mode: 0644]
src/gdcmCommand.h [new file with mode: 0644]
src/gdcmCommandManager.cxx [new file with mode: 0644]
src/gdcmCommandManager.h [new file with mode: 0644]
src/gdcmDebug.cxx
src/gdcmDebug.h
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDicomDirElement.h
src/gdcmDicomEntry.h
src/gdcmDict.h
src/gdcmDictGroupName.h
src/gdcmDictSet.cxx
src/gdcmDictSet.h
src/gdcmDirList.cxx
src/gdcmDirList.h
src/gdcmDocEntry.h
src/gdcmDocEntrySet.h
src/gdcmFileHelper.h
src/gdcmGlobal.cxx
src/gdcmJPEGFragment.cxx
src/gdcmJPEGFragmentsInfo.cxx
src/gdcmJpeg.cxx
src/gdcmJpeg2000.cxx
src/gdcmMacro.h
src/gdcmOrientation.h
src/gdcmPixelReadConvert.cxx
src/gdcmRLEFrame.cxx
src/gdcmRLEFramesInfo.cxx
src/gdcmRefCounter.h
src/gdcmSerieHelper.h
src/gdcmTS.h
src/gdcmUtil.cxx
src/gdcmVR.h
src/gdcmValidator.h

index 7bbeb306b5b1f508fe1c819f958ee6ecb7f42194..207d2f2c95eda90babac198efe5e2acab764d47f 100644 (file)
@@ -11,6 +11,7 @@ SET(TEST_SOURCES
   TestUtil.cxx
   TestBug.cxx
   TestHash.cxx
+  TestCommand.cxx
   TestTS.cxx
   TestVR.cxx
   TestDictGroupName.cxx
diff --git a/Testing/TestCommand.cxx b/Testing/TestCommand.cxx
new file mode 100644 (file)
index 0000000..84de430
--- /dev/null
@@ -0,0 +1,93 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: TestCommand.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/11/28 15:20:29 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+#include "gdcmCommand.h"
+#include "gdcmCallbackCommand.h"
+#include "gdcmCommandManager.h"
+
+#include <iostream>
+#include <typeinfo.h>
+
+class CommandTest : public gdcm::Command
+{
+   gdcmTypeMacro(CommandTest);
+   gdcmNewMacro(CommandTest);
+
+public:
+   virtual void Execute()
+   {
+      std::cout << "Test class command... for "
+                << typeid(GetObject()).name()
+                << " (" << GetObject() << ")" << std::endl
+                << GetText() << std::endl;
+      Executed = true;
+   }
+
+   bool IsExecuted() {return Executed;}
+
+private:
+   CommandTest() {Executed = false;}
+
+   bool Executed;
+};
+
+static bool fctExecuted = false;
+void CallbackTest(gdcm::CallbackCommand *cmd)
+{
+   std::cout << "Test class command... for "
+             << typeid(cmd->GetObject()).name()
+             << " (" << cmd->GetObject() << ")" << std::endl
+             << cmd->GetText() << std::endl;
+
+   fctExecuted = true;
+}
+
+int TestCommand(int argc, char *argv[]) 
+{
+   int error=0;
+
+   gdcm::CommandManager *mgr = gdcm::CommandManager::New();
+   CommandTest *cmd = CommandTest::New();
+   gdcm::CallbackCommand *cbk = gdcm::CallbackCommand::New();
+   cbk->SetCallback(CallbackTest);
+
+   mgr->SetCommand(2,cmd);
+   mgr->SetCommand(1,cbk);
+
+   cbk->Delete();
+   cmd->Delete();
+
+   std::cout << "Test on callback function execution\n";
+   mgr->ExecuteCommand(1,"Test on callback function");
+   if(!fctExecuted)
+      std::cout<<"... Failed\n";
+   error+=!fctExecuted;
+   std::cout << std::endl;
+
+   std::cout << "Test on command class execution\n";
+   mgr->ExecuteCommand(2,"Test on command class");
+   if(!cmd->IsExecuted())
+      std::cout<<"... Failed\n";
+   error+=!cmd->IsExecuted();
+   std::cout << std::endl;
+
+   std::cout << "Test on unset command execution\n";
+   mgr->ExecuteCommand(3,"Test on callback function");
+   std::cout << std::endl;
+
+   return error;
+}
index 0aa1ecc91b126aeecf313d12bb64841d06bcf97e..ec4edc48b95ce4188e73188eb220f1e5ef4f3311 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestMakeDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 14:52:31 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2005/11/28 15:20:29 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmDebug.h"
 
 // ---
-void StartMethod(void *startMethod) 
+class CommandStart : public gdcm::Command
 {
-  (void)startMethod;
-   std::cout<<"Start parsing"<<std::endl;
-}
+   gdcmTypeMacro(CommandStart);
+   gdcmNewMacro(CommandStart);
+
+public :
+   virtual void Execute()
+   {
+      std::cerr << "Start parsing" << std::endl;
+   }
+
+protected :
+   CommandStart() {}
+};
+
+class CommandEnd : public gdcm::Command
+{
+   gdcmTypeMacro(CommandEnd);
+   gdcmNewMacro(CommandEnd);
+
+public :
+   virtual void Execute()
+   {
+      std::cerr << "End parsing" << std::endl;
+   }
+
+protected :
+   CommandEnd() {}
+};
+
+class CommandProgress : public gdcm::Command
+{
+   gdcmTypeMacro(CommandProgress);
+   gdcmNewMacro(CommandProgress);
+
+public :
+   virtual void Execute()
+   {
+      gdcm::DicomDir *dd=dynamic_cast<gdcm::DicomDir *>(GetObject());
+
+      if(dd)
+         std::cerr << "Progress parsing (" << dd->GetProgress() << ")" << std::endl;
+      else
+         std::cerr << "Progress parsing (NULL)" << std::endl;
+   }
+
+protected :
+   CommandProgress() {}
+};
 
 void EndMethod(void *endMethod) 
 {
@@ -64,15 +108,23 @@ int TestMakeDicomDir(int argc, char *argv[])
    // new style (user is allowed no to load Sequences an/or Shadow Groups)
    dcmdir = gdcm::DicomDir::New( );
  
+   gdcm::Command *cmd;
+   cmd = CommandStart::New();
+   dcmdir->SetCommand(gdcm::CMD_STARTPROGRESS,cmd);
+   cmd->Delete();
+   cmd = CommandProgress::New();
+   dcmdir->SetCommand(gdcm::CMD_PROGRESS,cmd);
+   cmd->Delete();
+   cmd = CommandEnd::New();
+   dcmdir->SetCommand(gdcm::CMD_ENDPROGRESS,cmd);
+   cmd->Delete();
+
    // dcmdir->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW);
    // some images have a wrong length for element 0x0000 of private groups
    dcmdir->SetLoadMode(gdcm::LD_NOSEQ);
    dcmdir->SetDirectoryName(dirName);
-   dcmdir->Load( );
+   dcmdir->Load();
 
-   dcmdir->SetStartMethod(StartMethod);
-   dcmdir->SetEndMethod(EndMethod);
-   
    if ( !dcmdir->GetFirstPatient() ) 
    {
       std::cout << "makeDicomDir: no patient found. Exiting."
index 9e884fbf7d57e030025b305f1d643a56efc28949..5eab46e869c30238657993715ad1aa845103872f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/17 18:01:59 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2005/11/28 15:20:29 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -159,7 +159,7 @@ int TestUtil(int , char *[])
 // ----------------------------------------------------------
 // Let's test gdcm::Debug, now.
     std::cout << "GetDebugFlag : " << gdcm::Debug::GetDebugFlag() <<std::endl;
-    gdcm::Debug::SetDebugFilename ("DummyFileNameToWriteTo.txt");
+    gdcm::Debug::SetOutputFileName ("DummyFileNameToWriteTo.txt");
     std::cout << "We set a Debug file"   <<std::endl;
     if ( !gdcm::Debug::GetDebugFlag() )
     {
@@ -169,7 +169,7 @@ int TestUtil(int , char *[])
     std::cout << "GetDebugFlag : " << gdcm::Debug::GetDebugFlag()<<std::endl;
     gdcm::Debug::SetDebugFlag ( false );
     std::cout << "GetDebugFlag : " << gdcm::Debug::GetDebugFlag()<<std::endl;
-    gdcm::Debug::SetDebugFilename ("DummyFileNameToWriteTo2.txt");    
+    gdcm::Debug::SetOutputFileName ("DummyFileNameToWriteTo2.txt");    
 
    return 0;
 }
index 1277bb5cf230b968a3184eac4ad89e23737f1e89..c7101a675db489ec67332c888d5ccea545e07abf 100644 (file)
@@ -21,6 +21,9 @@ INCLUDE_DIRECTORIES(
 SET(libgdcm_la_SOURCES
    gdcmArgMgr.cxx
    gdcmBase.cxx
+   gdcmCallbackCommand.cxx
+   gdcmCommand.cxx
+   gdcmCommandManager.cxx
    gdcmDataEntry.cxx
    gdcmDebug.cxx
    gdcmDicomDir.cxx
diff --git a/src/gdcmCallbackCommand.cxx b/src/gdcmCallbackCommand.cxx
new file mode 100644 (file)
index 0000000..05189aa
--- /dev/null
@@ -0,0 +1,109 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmCallbackCommand.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/11/28 15:20:35 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+// ---------------------------------------------------------------
+#include "gdcmCallbackCommand.h"
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+/**
+ * \brief Constructor used when we want to generate dicom files from scratch
+ */
+CallbackCommand::CallbackCommand()
+{
+   Callback             = NULL;
+   CallbackArgDelete    = NULL;
+   CallbackArg          = NULL;
+}
+
+
+/**
+ * \brief   Canonical destructor.
+ */
+CallbackCommand::~CallbackCommand ()
+{
+//   SetCallback(NULL,NULL,NULL);
+}
+
+//-----------------------------------------------------------------------------
+// Public
+/**
+ * \brief   Set the callback method
+ * @param   method Method to call
+ * @param   arg    Argument to pass to the method
+ * \warning In python : the arg parameter isn't considered
+ */
+/*void CallbackCommand::SetCallback( CallbackCommand::CbkMethod *callback,void *arg )
+{
+   SetCallback(callback,arg,NULL);
+}*/
+
+/**
+ * \brief   Set the callback method to delete the argument
+ *          The argument is destroyed when the callback method is changed 
+ *          or when the class is destroyed
+ * @param   method Method to call to delete the argument
+ */
+/*void CallbackCommand::SetCallbackArgDelete( CallbackCommand::CbkMethod *callback ) 
+{
+   CallbackArgDelete = callback;
+}*/
+
+/**
+ * \brief   Set the callback method
+ * @param   method Method to call
+ * @param   arg    Argument to pass to the method
+ * @param   argDelete    Argument 
+ * \warning In python : the arg parameter isn't considered
+ */
+/*void CallbackCommand::SetCallback( void(*callback)(void *),
+                                   void *arg,void(*argDelete)(void *) )
+{
+   if ( CallbackArg && CallbackArgDelete )
+   {
+      CallbackArgDelete( CallbackArg );
+   }
+
+   Callback          = callback;
+   CallbackArg       = arg;
+   CallbackArgDelete = argDelete;
+}*/
+
+void CallbackCommand::SetCallback(CallbackCommand::CbkMethod *callback)
+{
+   Callback=callback;
+}
+
+void CallbackCommand::Execute()
+{
+   if(Callback)
+      Callback(this);
+}
+
+//-----------------------------------------------------------------------------
+// Protected
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
+// Print
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm
diff --git a/src/gdcmCallbackCommand.h b/src/gdcmCallbackCommand.h
new file mode 100644 (file)
index 0000000..d47315e
--- /dev/null
@@ -0,0 +1,72 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmCallbackCommand.h,v $
+  Language:  C++
+  Date:      $Date: 2005/11/28 15:20:35 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
+#ifndef GDCMCALLBACKCOMMAND_H
+#define GDCMCALLBACKCOMMAND_H
+
+#include "gdcmDebug.h"
+#include "gdcmCommand.h"
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+/**
+ * \brief CallbackCommand base class to react on a gdcm event
+ *
+ * \remarks The execution parameter depends on the
+ */
+class GDCM_EXPORT CallbackCommand : public Command
+{
+   gdcmTypeMacro(CallbackCommand);
+   gdcmNewMacro(CallbackCommand);
+
+public:
+
+   typedef void CbkMethod(CallbackCommand *);
+
+/*   // Note: the CallbackCommand:: namespace prefix is needed by Swig in the 
+   //       following method declarations. Refer to gdcmPython/gdcm.i
+   //       for the reasons of this unnecessary notation at C++ level.
+   void SetCallback(CallbackCommand::CbkMethod *callback,void *arg = NULL );
+   void SetCallbackArgDelete(CallbackCommand::CbkMethod *callback);
+   // Note: replace CallbackCommand::Method *method to void(*method)(void *) to
+   //       avoid wrapping problems with the typemap conversions
+   void SetCallback(void(*callback)(void *), // CallbackCommand::Method *method
+                    void *arg,
+                    void(*argDelete)(void *));
+*/
+   void SetCallback(CallbackCommand::CbkMethod *callback);
+
+   virtual void Execute();
+
+protected:
+   CallbackCommand();
+   virtual ~CallbackCommand();
+
+private:
+   /// pointer to the initialisation method for any progress bar   
+   CbkMethod *Callback;
+   /// pointer to the ??? method for any progress bar   
+   CbkMethod *CallbackArgDelete;
+   /// pointer to the ??? data for any progress bar   
+   void *CallbackArg;
+};
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif
diff --git a/src/gdcmCommand.cxx b/src/gdcmCommand.cxx
new file mode 100644 (file)
index 0000000..3a3fa45
--- /dev/null
@@ -0,0 +1,128 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmCommand.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/11/28 15:20:35 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+// ---------------------------------------------------------------
+#include "gdcmCommand.h"
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+/**
+ * \brief Constructor used when we want to generate dicom files from scratch
+ */
+Command::Command()
+{
+   Cmd = CMD_UNKNOWN;
+   Object = NULL;
+   ConstObject = NULL;
+   Text = "";
+}
+
+
+/**
+ * \brief   Canonical destructor.
+ */
+Command::~Command ()
+{
+}
+
+//-----------------------------------------------------------------------------
+// Public
+void Command::SetType(unsigned int type)
+{
+   Cmd = type;
+}
+
+unsigned int Command::GetType() const
+{
+   return Cmd;
+}
+
+void Command::SetObject(CommandManager *object)
+{
+   Object = object;
+}
+
+CommandManager *Command::GetObject() const
+{
+   return Object;
+}
+
+void Command::SetConstObject(const CommandManager *object)
+{
+   ConstObject = object;
+}
+
+const CommandManager *Command::GetConstObject() const
+{
+   if(ConstObject)
+      return ConstObject;
+   else
+      return GetObject();
+}
+
+void Command::SetText(const std::string &text)
+{
+   Text = text;
+}
+
+const std::string &Command::GetText(void) const
+{
+   return Text;
+}
+
+void Command::Execute()
+{
+}
+
+const char *Command::GetCommandAsString(unsigned int command)
+{
+   switch(command)
+   {
+      case CMD_UNKNOWN:
+         return "Unknown";
+      case CMD_DEBUG:
+         return "Debug";
+      case CMD_WARNING:
+         return "Warning";
+      case CMD_ERROR:
+         return "Error";
+      case CMD_ASSERT:
+         return "Assert";
+      case CMD_STARTPROGRESS:
+         return "StartProgress";
+      case CMD_ENDPROGRESS:
+         return "EndProgress";
+      case CMD_PROGRESS:
+         return "Progress";
+      default:
+         return "Undefined !!!";
+   }
+}
+
+//-----------------------------------------------------------------------------
+// Protected
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
+// Print
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm
diff --git a/src/gdcmCommand.h b/src/gdcmCommand.h
new file mode 100644 (file)
index 0000000..2bdb54f
--- /dev/null
@@ -0,0 +1,83 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmCommand.h,v $
+  Language:  C++
+  Date:      $Date: 2005/11/28 15:20:35 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
+#ifndef GDCMCOMMAND_H
+#define GDCMCOMMAND_H
+
+#include "gdcmRefCounter.h"
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+class CommandManager;
+
+//-----------------------------------------------------------------------------
+/// Command list
+enum CommandType {
+   CMD_UNKNOWN       =0,
+   CMD_DEBUG,
+   CMD_WARNING,
+   CMD_ERROR,
+   CMD_ASSERT,
+   CMD_STARTPROGRESS,
+   CMD_ENDPROGRESS,
+   CMD_PROGRESS
+};
+
+//-----------------------------------------------------------------------------
+/**
+ * \brief Command base class to react on a gdcm event
+ *
+ * \remarks The execution parameter depends on the
+ */
+class GDCM_EXPORT Command : public RefCounter
+{
+   gdcmTypeMacro(Command);
+   gdcmNewMacro(Command);
+
+public:
+
+   void SetType(unsigned int type);
+   unsigned int GetType() const;
+
+   void SetObject(CommandManager *object);
+   CommandManager *GetObject() const;
+   void SetConstObject(const CommandManager *object);
+   const CommandManager *GetConstObject() const;
+
+   void SetText(const std::string &text);
+   const std::string &GetText() const;
+
+   virtual void Execute();
+
+   static const char *GetCommandAsString(unsigned int command);
+
+protected:
+   Command();
+   virtual ~Command();
+
+private:
+   std::string Text;
+   CommandManager *Object;
+   const CommandManager *ConstObject;
+   unsigned int Cmd;
+};
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif
diff --git a/src/gdcmCommandManager.cxx b/src/gdcmCommandManager.cxx
new file mode 100644 (file)
index 0000000..49adb41
--- /dev/null
@@ -0,0 +1,121 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmCommandManager.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/11/28 15:20:35 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+// ---------------------------------------------------------------
+#include "gdcmCommandManager.h"
+#include "gdcmCommand.h"
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+/**
+ * \brief Constructor used when we want to generate dicom files from scratch
+ */
+CommandManager::CommandManager()
+{
+}
+
+
+/**
+ * \brief   Canonical destructor.
+ */
+CommandManager::~CommandManager ()
+{
+}
+
+//-----------------------------------------------------------------------------
+// Public
+void CommandManager::SetCommand(unsigned int type,Command *command)
+{
+   Command *cmd=CommandList[type];
+   if(cmd!=command)
+   {
+      if(cmd)
+         cmd->Unregister();
+      if(command)
+      {
+         CommandList[type]=command;
+         command->Register();
+      }
+      else
+         CommandList.erase(type);
+   }
+}
+
+Command *CommandManager::GetCommand(unsigned int type) const
+{
+   try
+   {
+      return CommandList[type];
+   }
+   catch(...)
+   {
+      return NULL;
+   }
+}
+
+bool CommandManager::ExecuteCommand(unsigned int type,std::string text)
+{
+   Command *cmd = GetCommand(type);
+   if(cmd)
+   {
+      cmd->SetText(text);
+      cmd->SetObject(this);
+      cmd->SetType(type);
+      cmd->Execute();
+      return true;
+   }
+   return false;
+}
+
+bool CommandManager::ConstExecuteCommand(unsigned int type,std::string text) const
+{
+   Command *cmd = GetCommand(type);
+   if(cmd)
+   {
+      cmd->SetText(text);
+      cmd->SetConstObject(this);
+      cmd->SetType(type);
+      cmd->Execute();
+      return true;
+   }
+   return false;
+}
+
+//-----------------------------------------------------------------------------
+// Protected
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
+// Print
+void CommandManager::Print(std::ostream &os, std::string const &indent)
+{
+   os<<indent<<"Command list : \n";
+   CommandHT::iterator it;
+   for(it=CommandList.begin();it!=CommandList.end();++it)
+   {
+      os<<indent<<"   "<<Command::GetCommandAsString(it->first)
+        <<" : "<<typeid(it->second).name()
+        <<" ("<<it->second<<")"<<std::endl;
+   }
+}
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm
diff --git a/src/gdcmCommandManager.h b/src/gdcmCommandManager.h
new file mode 100644 (file)
index 0000000..55966e0
--- /dev/null
@@ -0,0 +1,64 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmCommandManager.h,v $
+  Language:  C++
+  Date:      $Date: 2005/11/28 15:20:35 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
+#ifndef GDCMCOMMANDMANAGER_H
+#define GDCMCOMMANDMANAGER_H
+
+#include "gdcmRefCounter.h"
+
+#include <map>
+#include <iostream>
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+class Command;
+typedef std::map<unsigned int,Command *> CommandHT;
+
+//-----------------------------------------------------------------------------
+/**
+ * \brief CommandManager base class to react on a gdcm event
+ *
+ * \remarks The execution parameter depends on the
+ */
+class GDCM_EXPORT CommandManager : public RefCounter
+{
+   gdcmTypeMacro(CommandManager);
+
+public:
+   /// \brief Contructs an empty Dict with a RefCounter
+   static CommandManager *New() {return new CommandManager();}
+   void Print(std::ostream &os = std::cout, std::string const &indent = "" );
+
+   void SetCommand(unsigned int type,Command *command);
+   Command *GetCommand(unsigned int type) const;
+
+   bool ExecuteCommand(unsigned int type,std::string text = "");
+   bool ConstExecuteCommand(unsigned int type,std::string text = "") const;
+
+protected:
+   CommandManager();
+   ~CommandManager();
+
+private:
+   mutable CommandHT CommandList;
+};
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif
index ba0a2fa49c9915ae31dccb0620c54c8ddabdef95..ee5f72b545fb69c44ca30eaaa5031a09b8cd2c6c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDebug.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/05 13:21:32 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2005/11/28 15:20:32 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 =========================================================================*/
 
 #include "gdcmDebug.h"
+#include "gdcmCommandManager.h"
+
 #include <iostream>
 
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
 // Warning message level to be displayed
-static bool DebugFlag     = false;
-static bool WarningFlag   = false;
-static bool DebugToFile   = false;
-static std::ofstream DebugFile;
+const int Debug::LINE_LENGTH = 79;
+
+bool Debug::DebugFlag     = false;
+bool Debug::WarningFlag   = false;
+bool Debug::OutputToFile  = false;
+
+std::ofstream Debug::OutputFileStream;
+std::ostream &Debug::StandardStream = std::cerr;
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 Debug::Debug()
 {
-
 }
 
 Debug::~Debug()
 {
-  if ( DebugFile.is_open() )
-      DebugFile.close();     
+  if ( OutputFileStream.is_open() )
+      OutputFileStream.close();     
 }
 
 //-----------------------------------------------------------------------------
@@ -55,16 +60,6 @@ void Debug::SetDebugFlag (bool flag)
    WarningFlag = flag;
 }
 
-/**
- * \brief   Gets the debug flag value
- *          (used to warn user when file contains some oddity)
- * @return debug flag value
- */ 
-bool Debug::GetDebugFlag ()
-{
-   return DebugFlag;
-}
-
 /**
  * \brief   Sets the warning flag
  * @param   flag Set the warning flag
@@ -77,29 +72,21 @@ void Debug::SetWarningFlag (bool flag)
    WarningFlag = flag;
 }
 
-/**
- * \brief   Gets the warning flag value
- * @return warning flag value
- */ 
-bool Debug::GetWarningFlag ()
-{
-   return WarningFlag;
-}
 /**
  * \brief   Accessor
  * @param   flag whether we want to redirect to file
  */ 
-void Debug::SetDebugToFile (bool flag) 
+void Debug::SetOutputToFile (bool flag) 
 {
-   DebugToFile = flag;
+   OutputToFile = flag;
 }
 
 /**
  * \brief   Accessor to know whether debug info are redirected to file
  */ 
-bool Debug::GetDebugToFile ()
+bool Debug::GetOutputToFile ()
 {
-   return DebugToFile;
+   return OutputToFile;
 }
 
 /**
@@ -109,13 +96,13 @@ bool Debug::GetDebugToFile ()
  *          Absolutely nothing is check. You have to pass in
  *          a correct filename
  */ 
-void Debug::SetDebugFilename (std::string const &filename)
+void Debug::SetOutputFileName (std::string const &filename)
 {
-   DebugToFile = true;  // Just in case ... 
+   OutputToFile = true;  // Just in case ... 
    DebugFlag   = true;  // Just in case ...
-   if ( DebugFile.is_open() )
-      DebugFile.close();
-   DebugFile.open( filename.c_str() );
+   if ( OutputFileStream.is_open() )
+      OutputFileStream.close();
+   OutputFileStream.open( filename.c_str() );
 }
 
 /**
@@ -123,9 +110,22 @@ void Debug::SetDebugFilename (std::string const &filename)
  *        in gdcm code
  * @return Debug file
  */
-std::ofstream &Debug::GetDebugFile ()
+std::ostream &Debug::GetOutput ()
 {
-  return DebugFile;
+   if(OutputToFile)
+      return OutputFileStream;
+   else
+      return StandardStream;
+}
+
+void Debug::SendToOutput(unsigned int type,std::string const &msg,const CommandManager *mgr)
+{
+   bool executed=false;
+   if(mgr)
+      executed=mgr->ConstExecuteCommand(type,msg);
+
+   if(!executed)
+      GetOutput() << Command::GetCommandAsString(type) << ": " << msg;
 }
 
 //-----------------------------------------------------------------------------
index df9e02f831f4d412b1b43a710ae4c2454e46715a..8fb72a087c02f03c2b32689dd4a960f2b09681ae 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDebug.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/05 13:21:32 $
-  Version:   $Revision: 1.47 $
+  Date:      $Date: 2005/11/28 15:20:32 $
+  Version:   $Revision: 1.48 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,6 +20,7 @@
 #define GDCMDEBUG_H
 
 #include "gdcmCommon.h"
+#include "gdcmCommand.h"
 
 #include <iostream>
 #include <sstream>
@@ -30,7 +31,9 @@
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
+class CommandManager;
 
+//-----------------------------------------------------------------------------
 /**
  * \brief Debug is an object for debugging in program.
  * It has 2 debugging modes :
@@ -53,8 +56,10 @@ public:
 
    /// \brief This is a global flag that controls whether 
    ///        both debug and warning messages are displayed. 
+   ///        (used to warn user when file contains some oddity)
    static void SetDebugFlag (bool flag);
-   static bool GetDebugFlag ();
+   /// \brief   Gets the debug flag value
+   static bool GetDebugFlag () {return DebugFlag;}
    /// \brief Sets the Debug Flag to true
    static void DebugOn  () { SetDebugFlag(true);  }
    /// \brief Sets the Debug Flag to false
@@ -63,7 +68,8 @@ public:
    /// \brief This is a global flag that controls whether 
    ///        warning messages are displayed.
    static void SetWarningFlag (bool flag);
-   static bool GetWarningFlag ();
+   /// \brief   Gets the warning flag value
+   static bool GetWarningFlag () {return WarningFlag;}
    /// \brief Sets the Warning Flag to true
    static void WarningOn  () { SetWarningFlag(true);  }
    /// \brief Sets the Warning Flag to false
@@ -71,16 +77,28 @@ public:
 
    /// \brief This is a global flag that controls if debug are redirected
    ///        to a file or not
-   static void SetDebugToFile (bool flag);
-   static bool GetDebugToFile ();
+   static void SetOutputToFile (bool flag);
+   static bool GetOutputToFile ();
    /// \brief Next debug messages will be sent in the debug file
-   static void DebugToFileOn  () { SetDebugToFile(true);  }
+   static void OutputToFileOn  () { SetOutputToFile(true);  }
    /// \brief Next debug messages will be sent in the standard output
-   static void DebugToFileOff () { SetDebugToFile(false); }
+   static void OutputToFileOff () { SetOutputToFile(false); }
+
+   static void SetOutputFileName (std::string const &filename);
+
+   static std::ostream &GetOutput ();
+
+   static void SendToOutput(unsigned int type,std::string const &msg,const CommandManager *mgr = NULL);
 
-   static void SetDebugFilename (std::string const &filename);
+private:
+   static bool DebugFlag;
+   static bool WarningFlag;
+   static bool OutputToFile;
 
-   static std::ofstream &GetDebugFile ();
+   static std::ofstream OutputFileStream;
+   static std::ostream &StandardStream;
+
+   static const int LINE_LENGTH;
 };
 
 } // end namespace gdcm
@@ -111,156 +129,95 @@ public:
  * \brief   Debug : To be used to help bug tracking developer
  * @param msg message part
  */
+#define gdcmMessageBodyMacro(type,obj,msg,adds)                \
+{                                                              \
+   std::ostringstream osmacro;                                 \
+   osmacro << "In " __FILE__ ", line " << __LINE__             \
+           << ", function " << GDCM_FUNCTION << "\n"           \
+           << adds << msg << "\n\n";                           \
+   gdcm::Debug::SendToOutput(type,osmacro.str(),obj);          \
+}
+
+/**
+ * \brief Debug : To be used to help bug tracking developer
+ * @param msg message part
+ */
 #ifdef NDEBUG
+#define gdcmDebugBodyMacro(obj,msg) {}
 #define gdcmDebugMacro(msg) {}
+#define gdcmStaticDebugMacro(msg) {}
 #else
-#define gdcmDebugMacro(msg)                                 \
-{                                                           \
-   if( Debug::GetDebugFlag() )                              \
-   {                                                        \
-   std::ostringstream osmacro;                              \
-   osmacro << "Debug: In " __FILE__ ", line " << __LINE__   \
-           << ", function " << GDCM_FUNCTION << '\n';       \
-   if( errno )                                              \
-     osmacro  << "Last system error was: " <<               \
-       strerror(errno) << '\n';                             \
-   osmacro << msg << "\n\n";                                \
-   if( Debug::GetDebugToFile() )                            \
-      Debug::GetDebugFile() << osmacro.str() << std::endl;  \
-   else                                                     \
-      std::cerr << osmacro.str() << std::endl;              \
-   }                                                        \
+#define gdcmDebugBodyMacro(obj,msg)                            \
+{                                                              \
+   if( Debug::GetDebugFlag() )                                 \
+   {                                                           \
+      std::string adds="";                                     \
+      if( errno )                                              \
+      {                                                        \
+         adds = "Last system error was: ";                     \
+         adds += strerror(errno);                              \
+         adds += "\n";                                         \
+      }                                                        \
+      gdcmMessageBodyMacro(gdcm::CMD_DEBUG,obj,msg,adds);      \
+   }                                                           \
 }
+#define gdcmDebugMacro(msg)                                    \
+   gdcmDebugBodyMacro(this,msg)
+#define gdcmStaticDebugMacro(msg)                              \
+   gdcmDebugBodyMacro(NULL,msg)
 #endif //NDEBUG
 
 /**
- * \brief   Warning : To be used to warn the user when some oddity occurs
+ * \brief Warning : To be used to warn the user when some oddity occurs
  * @param msg message part
  */
-#ifdef NDEBUG
-#define gdcmWarningMacro(msg) {}
-#else
-#define gdcmWarningMacro(msg)                               \
-{                                                           \
-   if( Debug::GetWarningFlag() )                            \
-   {                                                        \
-   std::ostringstream osmacro;                              \
-   osmacro << "Warning: In " __FILE__ ", line " << __LINE__ \
-           << ", function " << GDCM_FUNCTION << "\n"        \
-           << msg << "\n\n";                                \
-   if( Debug::GetDebugToFile() )                            \
-      Debug::GetDebugFile() << osmacro.str() << std::endl;  \
-   else                                                     \
-      std::cerr << osmacro.str() << std::endl;              \
-   }                                                        \
+// No NDEBUG test to always have a return of warnings !!!
+#define gdcmWarningBodyMacro(obj,msg)                          \
+{                                                              \
+   if( Debug::GetWarningFlag() )                               \
+      gdcmMessageBodyMacro(gdcm::CMD_WARNING,obj,msg,"");      \
 }
-#endif //NDEBUG
+#define gdcmWarningMacro(msg)                                  \
+   gdcmWarningBodyMacro(this,msg)
+#define gdcmStaticWarningMacro(msg)                            \
+   gdcmWarningBodyMacro(NULL,msg)
 
 /**
  * \brief   Error : To be used when unecoverabale error occurs
  *          at a 'deep' level. (don't use it if file is not ACR/DICOM!)
  * @param msg second message part 
  */
-#ifdef NDEBUG
-#define gdcmErrorMacro(msg) {}
-#else
-#define gdcmErrorMacro(msg)                                 \
-{                                                           \
-   std::ostringstream osmacro;                              \
-   osmacro << "Error: In " __FILE__ ", line " << __LINE__   \
-           << ", function " << GDCM_FUNCTION << '\n'        \
-           << msg << "\n\n";                                \
-   if( Debug::GetDebugToFile() )                            \
-      Debug::GetDebugFile() << osmacro.str() << std::endl;  \
-   else                                                     \
-      std::cerr << osmacro.str() << std::endl;              \
+// No NDEBUG test to always have a return of errors !!!
+#define gdcmErrorBodyMacro(obj,msg)                            \
+{                                                              \
+   gdcmMessageBodyMacro(gdcm::CMD_ERROR,obj,msg,"");           \
 }
-#endif //NDEBUG
+#define gdcmErrorMacro(msg)                                    \
+   gdcmErrorBodyMacro(this,msg)
+#define gdcmStaticErrorMacro(msg)                              \
+   gdcmErrorBodyMacro(NULL,msg)
 
 /**
- * \brief   Assert : To be used when an *absolutely* impossible error occurs
- *          No function should be allowed to stop the process instead of
- *          warning the caller!
+ * \brief Assert : To be used when an *absolutely* impossible error occurs
+ *        No function should be allowed to stop the process instead of
+ *        warning the caller!
  * @param arg argument to test
  *        An easy solution to pass also a message is to do:
  *        gdcmAssertMacro( "my message" && 2 < 3 )
  */
-#ifdef NDEBUG
-#define gdcmAssertMacro(arg) {}
-#else
-#define gdcmAssertMacro(arg)                                \
-{                                                           \
-   if( !(arg) )                                             \
-   {                                                        \
-   std::ostringstream osmacro;                              \
-   osmacro << "Assert: In " __FILE__ ", line " << __LINE__  \
-           << ", function " << GDCM_FUNCTION                \
-           << "\n\n";                                       \
-   if( Debug::GetDebugToFile() )                            \
-      Debug::GetDebugFile() << osmacro.str() << std::endl;  \
-   else                                                     \
-      std::cerr << osmacro.str() << std::endl;              \
-   assert ( arg );                                          \
-   }                                                        \
+// No NDEBUG test to always have a return of asserts !!!
+#define gdcmAssertBodyMacro(obj,arg)                           \
+{                                                              \
+   if( !(arg) )                                                \
+   {                                                           \
+      gdcmMessageBodyMacro(gdcm::CMD_ASSERT,obj,"","");        \
+      assert ( arg );                                          \
+   }                                                           \
 }
-#endif //NDEBUG
+#define gdcmAssertMacro(msg)                                   \
+   gdcmAssertBodyMacro(this,msg)
+#define gdcmStaticAssertMacro(msg)                             \
+   gdcmAssertBodyMacro(NULL,msg)
 
 //-----------------------------------------------------------------------------
-//
-// Define GDCM_LEGACY macro to mark legacy methods where they are
-// declared in their class.
-// 
-// WARNING : Don't try to use it with 'inline' methods ! 
-//
-//Example usage:
-//
-//   // @deprecated Replaced by MyOtherMethod() as of gdcm 2.0.
-//   GDCM_LEGACY(void MyMethod());
-#if defined(GDCM_LEGACY_REMOVE)
-  // Remove legacy methods completely.
-# define GDCM_LEGACY(method)
-#elif defined(GDCM_LEGACY_SILENT) || defined(SWIG)
-  // Provide legacy methods with no warnings.
-# define GDCM_LEGACY(method) method
-#else
-  // Setup compile-time warnings for uses of deprecated methods if
-  // possible on this compiler.
-# if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#if defined(__APPLE__) && (__GNUC__ == 3) && (__GNUC_MINOR__ == 3)
-// Seems like there is a bug in APPLE gcc for deprecated attribute and ctor
-// This is fixed in g++ 4.0 (Tiger)
-#  define GDCM_LEGACY(method) method
-#else
-#  define GDCM_LEGACY(method) method __attribute__((deprecated))
-#endif
-# elif defined(_MSC_VER) && _MSC_VER >= 1300
-#  define GDCM_LEGACY(method) __declspec(deprecated) method
-# else
-#  define GDCM_LEGACY(method) method
-# endif
-#endif
-
-// Macros to create runtime deprecation warning messages in function
-// bodies.  Example usage:
-//
-//   void MyClass::MyOldMethod()
-//   {
-//     GDCM_LEGACY_BODY(MyClass::MyOldMethod, 2.0);
-//   }
-//
-//   void MyClass::MyMethod()
-//   {
-//     GDCM_LEGACY_REPLACED_BODY(MyClass::MyMethod, 5.0,
-//                               MyClass::MyOtherMethod);
-//   }
-#if defined(GDCM_LEGACY_REMOVE) || defined(GDCM_LEGACY_SILENT)
-# define GDCM_LEGACY_BODY(method, version)
-# define GDCM_LEGACY_REPLACED_BODY(method, version, replace)
-#else
-# define GDCM_LEGACY_BODY(method, version) \
-  gdcmWarningMacro(#method " was deprecated for gdcm" #version " and will be removed in a future version.")
-# define GDCM_LEGACY_REPLACED_BODY(method, version, replace) \
-  gdcmWarningMacro(#method " was deprecated for gdcm" #version " and will be removed in a future version.  Use " #replace " instead.")
-#endif
-
 #endif
index 27cbd3ea38ddb25d9b2b016a9fcb3525b6cd61a0..bd5e478e621d42b714badd0ce8284a9ef4adc6a5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:25 $
-  Version:   $Revision: 1.173 $
+  Date:      $Date: 2005/11/28 15:20:32 $
+  Version:   $Revision: 1.174 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -129,10 +129,6 @@ DicomDir::DicomDir()
  */
 DicomDir::~DicomDir() 
 {
-   SetStartMethod(NULL,NULL,NULL);
-   SetProgressMethod(NULL,NULL,NULL);
-   SetEndMethod(NULL,NULL,NULL);
-
    ClearPatient();
    if ( MetaElems )
    {
@@ -345,117 +341,6 @@ void DicomDir::ParseDirectory()
    CreateDicomDir();
 }
 
-void DicomDir::SetStartMethod( DicomDir::Method *method, void *arg )
-{
-   SetStartMethod(method,arg,NULL);
-}
-
-void DicomDir::SetProgressMethod( DicomDir::Method *method, void *arg )
-{
-   SetProgressMethod(method,arg,NULL);
-}
-
-void DicomDir::SetEndMethod( DicomDir::Method *method, void *arg )
-{
-   SetEndMethod(method,arg,NULL);
-}
-
-/**
- * \brief   Set the start method to call when the parsing of the
- *          directory starts.
- * @param   method Method to call
- * @param   arg    Argument to pass to the method
- * @param   argDelete    Argument 
- * \warning In python : the arg parameter isn't considered
- */
-void DicomDir::SetStartMethod( DicomDir::Method *method, void *arg, 
-                               DicomDir::Method *argDelete )
-{
-   if ( StartArg && StartMethodArgDelete )
-   {
-      StartMethodArgDelete( StartArg );
-   }
-
-   StartMethod          = method;
-   StartArg             = arg;
-   StartMethodArgDelete = argDelete;
-}
-
-
-/**
- * \brief   Set the progress method to call when the parsing of the
- *          directory progress
- * @param   method Method to call
- * @param   arg    Argument to pass to the method
- * @param   argDelete    Argument  
- * \warning In python : the arg parameter isn't considered
- */
-void DicomDir::SetProgressMethod( DicomDir::Method *method, void *arg, 
-                                  DicomDir::Method *argDelete )
-{
-   if ( ProgressArg && ProgressMethodArgDelete )
-   {
-      ProgressMethodArgDelete( ProgressArg );
-   }
-
-   ProgressMethod          = method;
-   ProgressArg             = arg;
-   ProgressMethodArgDelete = argDelete;
-}
-
-/**
- * \brief   Set the end method to call when the parsing of the directory ends
- * @param   method Method to call
- * @param   arg    Argument to pass to the method
- * @param   argDelete    Argument 
- * \warning In python : the arg parameter isn't considered
- */
-void DicomDir::SetEndMethod( DicomDir::Method *method, void *arg, 
-                             DicomDir::Method *argDelete )
-{
-   if ( EndArg && EndMethodArgDelete )
-   {
-      EndMethodArgDelete( EndArg );
-   }
-
-   EndMethod          = method;
-   EndArg             = arg;
-   EndMethodArgDelete = argDelete;
-}
-
-/**
- * \brief   Set the method to delete the argument
- *          The argument is destroyed when the method is changed or when the
- *          class is destroyed
- * @param   method Method to call to delete the argument
- */
-void DicomDir::SetStartMethodArgDelete( DicomDir::Method *method ) 
-{
-   StartMethodArgDelete = method;
-}
-
-/**
- * \brief   Set the method to delete the argument
- *          The argument is destroyed when the method is changed or when the 
- *          class is destroyed          
- * @param   method Method to call to delete the argument
- */
-void DicomDir::SetProgressMethodArgDelete( DicomDir::Method *method )
-{
-   ProgressMethodArgDelete = method;
-}
-
-/**
- * \brief   Set the method to delete the argument
- *          The argument is destroyed when the method is changed or when
- *          the class is destroyed
- * @param   method Method to call to delete the argument
- */
-void DicomDir::SetEndMethodArgDelete( DicomDir::Method *method )
-{
-   EndMethodArgDelete = method;
-}
-
 /**
  * \brief    writes on disc a DICOMDIR
  * \ warning does NOT add the missing elements in the header :
@@ -618,10 +503,7 @@ void DicomDir::CallStartMethod()
 {
    Progress = 0.0f;
    Abort    = false;
-   if ( StartMethod )
-   {
-      StartMethod( StartArg );
-   }
+   ExecuteCommand(CMD_STARTPROGRESS);
 }
 
 /**
@@ -629,10 +511,7 @@ void DicomDir::CallStartMethod()
  */
 void DicomDir::CallProgressMethod()
 {
-   if ( ProgressMethod )
-   {
-      ProgressMethod( ProgressArg );
-   }
+   ExecuteCommand(CMD_PROGRESS);
 }
 
 /**
@@ -641,10 +520,7 @@ void DicomDir::CallProgressMethod()
 void DicomDir::CallEndMethod()
 {
    Progress = 1.0f;
-   if ( EndMethod )
-   {
-      EndMethod( EndArg );
-   }
+   ExecuteCommand(CMD_ENDPROGRESS);
 }
 
 //-----------------------------------------------------------------------------
@@ -654,16 +530,6 @@ void DicomDir::CallEndMethod()
  */
 void DicomDir::Initialize()
 {
-   StartMethod             = NULL;
-   ProgressMethod          = NULL;
-   EndMethod               = NULL;
-   StartMethodArgDelete    = NULL;
-   ProgressMethodArgDelete = NULL;
-   EndMethodArgDelete      = NULL;
-   StartArg                = NULL;
-   ProgressArg             = NULL;
-   EndArg                  = NULL;
-
    Progress = 0.0;
    Abort = false;
 
index 4c432851aa0777a5f4f4224d3844dec44a9c6595..d9ec5b339498aed6684b939b997e0653a8dadfbf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:25 $
-  Version:   $Revision: 1.70 $
+  Date:      $Date: 2005/11/28 15:20:32 $
+  Version:   $Revision: 1.71 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -56,8 +56,6 @@ public:
 /// \brief Constructs a DicomDir with a RefCounter
    static DicomDir *New() {return new DicomDir();}
 
-   typedef void Method(void*);
-
    bool Load( );
    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
    
@@ -88,32 +86,8 @@ public:
    // Parsing
    void ParseDirectory();
 
-   // Note: the DicomDir:: namespace prefix is needed by Swig in the 
-   //       following method declarations. Refer to gdcmPython/gdcm.i
-   //       for the reasons of this unnecessary notation at C++ level.
-   void SetStartMethod(    DicomDir::Method *method,
-                           void *arg = NULL );
-   void SetProgressMethod( DicomDir::Method *method,
-                           void *arg = NULL );
-   void SetEndMethod(      DicomDir::Method *method,
-                           void *arg = NULL );
-   // Note: replace DicomDir::Method *method to void(*method)(void *) to
-   //       avoid wrapping problems with the typemap conversions
-   void SetStartMethod(    void(*method)(void *), // DicomDir::Method *method
-                           void *arg,
-                           void(*argDelete)(void *));
-   void SetProgressMethod( void(*method)(void *), // DicomDir::Method *method
-                           void *arg,
-                           void(*argDelete)(void *));
-   void SetEndMethod(      void(*method)(void *), // DicomDir::Method *method
-                           void *arg, 
-                           void(*argDelete)(void *));
-   void SetStartMethodArgDelete   ( DicomDir::Method *method );
-   void SetProgressMethodArgDelete( DicomDir::Method *method );
-   void SetEndMethodArgDelete     ( DicomDir::Method *method );
-
    /// GetProgress GetProgress
-   float GetProgress()   { return Progress; }
+   float GetProgress() const { return Progress; }
    /// AbortProgress AbortProgress
    void  AbortProgress() { Abort = true; }
    /// IsAborted IsAborted
@@ -171,29 +145,12 @@ private:
    ListDicomDirPatient Patients;
    ListDicomDirPatient::iterator ItPatient;
 
-   /// pointer to the initialisation method for any progress bar   
-   Method *StartMethod;
-   /// pointer to the incrementation method for any progress bar
-   Method *ProgressMethod;
-   /// pointer to the termination method for any progress bar
-   Method *EndMethod;
-   /// pointer to the ??? method for any progress bar   
-   Method *StartMethodArgDelete;
-   /// pointer to the ??? method for any progress bar
-   Method* ProgressMethodArgDelete;
-   /// pointer to the ??? method for any progress bar
-   Method *EndMethodArgDelete;
-   /// pointer to the ??? for any progress bar   
-   void *StartArg;
-   /// pointer to the ??? for any progress bar
-   void *ProgressArg;
-   /// pointer to the ??? for any progress bar   
-   void *EndArg;
    /// value of the ??? for any progress bar
    float Progress;
    /// value of the ??? for any progress bar   
-   bool Abort;
    bool ParseDir;
+
+   mutable bool Abort;
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index 945450a675ec73fabf42c1d13c961534e2b9633b..28d0e44a4333edc0a53d22ff307a7e3400316899 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:25 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2005/11/28 15:20:32 $
+  Version:   $Revision: 1.36 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMDICOMDIRELEMENT_H
 #define GDCMDICOMDIRELEMENT_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 
 #include <list>
 
@@ -65,7 +65,7 @@ typedef std::list<DicomElement> ListDicomDirFiducialElem;
  * \brief   Represents elements contained in a DicomDir class
  *          for the chained lists from the file 'Dicts/DicomDir.dic'
  */
-class GDCM_EXPORT DicomDirElement : public RefCounter
+class GDCM_EXPORT DicomDirElement : public CommandManager
 {
    gdcmTypeMacro(DicomDirElement);
 
index dca0d81918bb6a77c4d69352d92cf47e695a3a97..b11e8c379612ecdfddcf7eac9f42310dc37e4fc7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/23 15:32:30 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2005/11/28 15:20:32 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,7 +20,7 @@
 #define GDCMDICOMENTRY_H
 
 #include "gdcmCommon.h"
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 #include "gdcmVRKey.h"
 #include "gdcmTagKey.h"
 
@@ -39,7 +39,7 @@ namespace gdcm
  *  - the VM (Value Multiplicity)
  *  - the corresponding name in english
  */
-class GDCM_EXPORT DicomEntry : public RefCounter
+class GDCM_EXPORT DicomEntry : public CommandManager
 {
    gdcmTypeMacro(DicomEntry);
 
index a1259bab06003225a4daf726be59f89a2b5ef3a1..aeda00ab3d2baf5dbfe9ef0b639910895af17242 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDict.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:25 $
-  Version:   $Revision: 1.46 $
+  Date:      $Date: 2005/11/28 15:20:32 $
+  Version:   $Revision: 1.47 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMDICT_H
 #define GDCMDICT_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 #include "gdcmDictEntry.h"
 
 #include <iostream>
@@ -44,7 +44,7 @@ typedef std::map<TagKey, DictEntry *>  TagKeyHT;
  *           combined with all software versions...
  * \see DictSet
  */
-class GDCM_EXPORT Dict : public RefCounter
+class GDCM_EXPORT Dict : public CommandManager
 {
    gdcmTypeMacro(Dict);
 
index d3aa1e9e63317b1f20cbcdb4079722fadbc3ce1c..99a956d12ccbeebbac55d015ebe7acca02836ad3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictGroupName.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:26 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2005/11/28 15:20:32 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMDICTGROUPNAME_H
 #define GDCMDICTGROUPNAME_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 
 #include <map>
 #include <string>
@@ -38,7 +38,7 @@ typedef std::map<uint16_t, TagName> DictGroupNameHT;
  *        (formerly NIH defined ACR-NEMA group name)
  * \note   This is a singleton.
  */
-class GDCM_EXPORT DictGroupName : public RefCounter
+class GDCM_EXPORT DictGroupName : public CommandManager
 {
    gdcmTypeMacro(DictGroupName);
 
index 524f0f98e76db7330d05815aa8bf882070327d97..63c03594624853c48d638dff83d64a0e4e1783ee 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 14:52:34 $
-  Version:   $Revision: 1.72 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.73 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -131,7 +131,7 @@ std::string DictSet::BuildDictPath()
    if (envPath && (strlen(envPath) != 0)) 
    {
       resultPath = envPath;
-      gdcmWarningMacro( "Dictionary path set from environnement");
+      gdcmStaticWarningMacro( "Dictionary path set from environnement");
    } 
    else
    {
index e9ed37a6e69ccee558bd10832faad97979501d4e..e9d3bcbc0676f9c0e400b11d21269c439e4e3f52 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:26 $
-  Version:   $Revision: 1.50 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.51 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMDICTSET_H
 #define GDCMDICTSET_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 #include "gdcmDict.h"
 
 #include <map>
@@ -38,7 +38,7 @@ typedef std::map<DictKey, Dict*> DictSetHT;
  *         - having many in memory representations of the same dictionary
  *        (saving memory).
  */
-class GDCM_EXPORT DictSet : public RefCounter
+class GDCM_EXPORT DictSet : public CommandManager
 {
    gdcmTypeMacro(DictSet);
 
index 9fa27c898a989b1108e51e2f8d2c9f94099a252b..64d0e077b4bf09cfa637e553991c31a0a85a4a5c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDirList.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/25 18:47:34 $
-  Version:   $Revision: 1.53 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.54 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -64,22 +64,22 @@ DirList::~DirList()
  */
 bool DirList::IsDirectory(std::string const &dirName)
 {
-  struct stat fs;
-  assert( dirName[dirName.size()-1] != '/' );
-  if ( stat(dirName.c_str(), &fs) == 0 )
-    {
+   struct stat fs;
+   assert( dirName[dirName.size()-1] != '/' );
+   if ( stat(dirName.c_str(), &fs) == 0 )
+   {
 #if _WIN32
-    return ((fs.st_mode & _S_IFDIR) != 0);
+      return ((fs.st_mode & _S_IFDIR) != 0);
 #else
-    return S_ISDIR(fs.st_mode);
+      return S_ISDIR(fs.st_mode);
 #endif
-    }
-  else
-    {
-    const char *str = strerror(errno);
-    gdcmErrorMacro( str );
-    return false;
-    }
+   }
+   else
+   {
+      const char *str = strerror(errno);
+      gdcmStaticErrorMacro( str );
+      return false;
+   }
 }
 
 //-----------------------------------------------------------------------------
@@ -124,10 +124,10 @@ int DirList::Explore(std::string const &dirpath, bool recursive)
    DWORD dwError = GetLastError();
    if (hFile != INVALID_HANDLE_VALUE) FindClose(hFile);
    if (dwError != ERROR_NO_MORE_FILES) 
-     {
-     gdcmErrorMacro("FindNextFile error. Error is " << dwError);
-     return -1;
-     }
+   {
+      gdcmErrorMacro("FindNextFile error. Error is " << dwError);
+      return -1;
+   }
 
 #else
   // Real POSIX implementation: scandir is a BSD extension only, and doesn't 
@@ -150,10 +150,10 @@ int DirList::Explore(std::string const &dirpath, bool recursive)
    {
       fileName = dirName + d->d_name;
       if( stat(fileName.c_str(), &buf) != 0 )
-        {
-        const char *str = strerror(errno);
-        gdcmErrorMacro( str );
-        }
+      {
+         const char *str = strerror(errno);
+         gdcmErrorMacro( str );
+      }
       if ( S_ISREG(buf.st_mode) )    //is it a regular file?
       {
          Filenames.push_back( fileName );
@@ -173,10 +173,10 @@ int DirList::Explore(std::string const &dirpath, bool recursive)
       }
    }
    if( closedir(dir) != 0 )
-     {
-     const char *str = strerror(errno);
-     gdcmErrorMacro( str );
-     }
+   {
+      const char *str = strerror(errno);
+      gdcmErrorMacro( str );
+   }
 #endif
 
   return numberOfFiles;
index b30bc953db5b1dab82f1332fad02219be69497ae..4fa92355a61a85492a0699564ac8eea4c92c291f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDirList.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:26 $
-  Version:   $Revision: 1.27 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.28 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,6 +20,7 @@
 #define GDCMDIRLIST_H
 
 #include "gdcmCommon.h"
+#include "gdcmCommandManager.h"
 
 #include <string>
 #include <vector>
@@ -39,7 +40,7 @@ typedef std::vector<std::string> DirListType;
  * \brief   List containing the file headers of all the 'gdcm readable' files
  *          found by exploring (possibely recursively) a root directory. 
  */
-class GDCM_EXPORT DirList
+class GDCM_EXPORT DirList : public CommandManager
 {
 public :
    DirList(std::string const &dirName, bool recursive=false);
index ff098d107c2b602457d367e8803aa1f3fb07c4ce..65dad74f0f3752b40cbab48538762c9534a3d34d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/07 09:46:36 $
-  Version:   $Revision: 1.56 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.57 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMDOCENTRY_H
 #define GDCMDOCENTRY_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 #include "gdcmDictEntry.h"
 
 #include <iostream>
@@ -35,7 +35,7 @@ class SeqEntry;
  * \brief   The dicom header of a Dicom file contains a set of such entries
  *          (when successfuly parsed against a given Dicom dictionary)
  */
-class GDCM_EXPORT DocEntry : public RefCounter
+class GDCM_EXPORT DocEntry : public CommandManager
 {
    gdcmTypeMacro(DocEntry);
 
index 98d95b533ff48ee270a7b153d177d7cdc92fea9b..b4f583e4aac3020c65953acfc249453d7bfdd7b2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:26 $
-  Version:   $Revision: 1.63 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.64 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMDOCENTRYSET_H
 #define GDCMDOCENTRYSET_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 #include "gdcmVRKey.h"
 #include "gdcmTagKey.h"
 
@@ -58,7 +58,7 @@ class DictEntry;
  *       members to this class since this class is designed as an adapter 
  *       in the form of an abstract base class.
  */
-class GDCM_EXPORT DocEntrySet : public RefCounter
+class GDCM_EXPORT DocEntrySet : public CommandManager
 {
    gdcmTypeMacro(DocEntrySet);
 
index a6a098bb2c72076fcf1e0a12d3d4bbff1f380146..5a17c28f0c3108c6fd5e7e1482149f5c1a0d1080 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/22 20:26:06 $
-  Version:   $Revision: 1.33 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.34 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,7 +20,7 @@
 #define GDCMFILEHELPER_H
 
 #include "gdcmDebug.h"
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 
 
 namespace gdcm 
@@ -40,7 +40,7 @@ typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, File *);
  * for accessing the image/volume content. One can also use it to
  * write Dicom/ACR-NEMA/RAW files.
  */
-class GDCM_EXPORT FileHelper : public RefCounter
+class GDCM_EXPORT FileHelper : public CommandManager
 {
    gdcmTypeMacro(FileHelper);
 
index 4a21aca32e87b949f204e6851c56b7c55b7cf197..6f98bbfe9ff8f6436d37f3cf6b06238f60131940 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmGlobal.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 14:52:35 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.29 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -67,7 +67,7 @@ Global::Global()
 {
    if (ValRes || TranSyn || Dicts || ddElem)
    {
-      gdcmWarningMacro( "VR or TS or Dicts already allocated");
+      gdcmStaticWarningMacro( "VR or TS or Dicts already allocated");
       return;
    }
    Dicts     = DictSet::New();
index 8c82b1d88f5d1c072e94b9b533a5c64247f6b67c..5aec9aa3a1711acf2bcb5c3422b4ad2a550a8fa5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJPEGFragment.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/04 16:51:36 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -82,7 +82,7 @@ void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp,
       //         NOT the compression method
 
       // other JPEG lossy not supported
-      gdcmErrorMacro( "Unknown jpeg lossy compression ");
+      gdcmStaticErrorMacro( "Unknown jpeg lossy compression ");
    }
 }
 
index 4660612ce6d1e542fe736d8c32c195a1a41dc6fb..212dee6ae69d40d07d8a8f75877d34beb6d2f9e8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/01 10:29:55 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.19 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -78,7 +78,7 @@ JPEGFragment *JPEGFragmentsInfo::GetFirstFragment()
 
 JPEGFragment *JPEGFragmentsInfo::GetNextFragment()
 {
-   gdcmAssertMacro (ItFragments != Fragments.end());
+   gdcmStaticAssertMacro (ItFragments != Fragments.end());
 
    ++ItFragments;
    if (ItFragments != Fragments.end())
index 7cfee75fc209001b1a585f4611f27e012f92ca5a..9b663f9f7f0bf8e184a89e5e279666a51f01bd16 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJpeg.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 19:06:30 $
-  Version:   $Revision: 1.51 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.52 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -268,7 +268,7 @@ bool JPEGFragment::ReadJPEGFile (std::ifstream *fp, void *image_buffer, int &sta
     // If we get here, the JPEG code has signaled an error.
     // We need to clean up the JPEG object, close the input file, and return.
 
-    gdcmErrorMacro( "Serious Problem !" );
+    gdcmStaticErrorMacro( "Serious Problem !" );
     jpeg_destroy_decompress(&cinfo);
     return 0;
   }
index 0064240c19a0fcaeeca7e18fe3a38cb5e4dc3b8a..5b0171075364354e69766df729268a0016474887 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJpeg2000.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/04 15:20:13 $
-  Version:   $Revision: 1.33 $
+  Date:      $Date: 2005/11/28 15:20:33 $
+  Version:   $Revision: 1.34 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -55,7 +55,7 @@ bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength)
    // Decompression
    if (!j2k_decode(src, len, &img, &cp))
    {
-      gdcmErrorMacro( "ERROR -> j2k_to_image: failed to decode image!" );
+      gdcmStaticErrorMacro( "ERROR -> j2k_to_image: failed to decode image!" );
       return false;
    }
  
index 389dbef43b6cd31cfffb5180c20598dcda5aae0c..5798178fc17494c1ee0a8e48bfea5851f4b29b75 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmMacro.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/21 15:34:56 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
       type(type &); /* Not implemented */ \
       type &operator=(type &) /* Not implemented */
 
+#define gdcmNewMacro(type) \
+   public : \
+      static type *New() {return new type(); } /* Not implemented */
+
+//-----------------------------------------------------------------------------
+//
+// Define GDCM_LEGACY macro to mark legacy methods where they are
+// declared in their class.
+// 
+// WARNING : Don't try to use it with 'inline' methods ! 
+//
+//Example usage:
+//
+//   // @deprecated Replaced by MyOtherMethod() as of gdcm 2.0.
+//   GDCM_LEGACY(void MyMethod());
+#if defined(GDCM_LEGACY_REMOVE)
+  // Remove legacy methods completely.
+# define GDCM_LEGACY(method)
+#elif defined(GDCM_LEGACY_SILENT) || defined(SWIG)
+  // Provide legacy methods with no warnings.
+# define GDCM_LEGACY(method) method
+#else
+  // Setup compile-time warnings for uses of deprecated methods if
+  // possible on this compiler.
+# if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+#if defined(__APPLE__) && (__GNUC__ == 3) && (__GNUC_MINOR__ == 3)
+// Seems like there is a bug in APPLE gcc for deprecated attribute and ctor
+// This is fixed in g++ 4.0 (Tiger)
+#  define GDCM_LEGACY(method) method
+#else
+#  define GDCM_LEGACY(method) method __attribute__((deprecated))
+#endif
+# elif defined(_MSC_VER) && _MSC_VER >= 1300
+#  define GDCM_LEGACY(method) __declspec(deprecated) method
+# else
+#  define GDCM_LEGACY(method) method
+# endif
+#endif
+
+// Macros to create runtime deprecation warning messages in function
+// bodies.  Example usage:
+//
+//   void MyClass::MyOldMethod()
+//   {
+//     GDCM_LEGACY_BODY(MyClass::MyOldMethod, 2.0);
+//   }
+//
+//   void MyClass::MyMethod()
+//   {
+//     GDCM_LEGACY_REPLACED_BODY(MyClass::MyMethod, 5.0,
+//                               MyClass::MyOtherMethod);
+//   }
+#if defined(GDCM_LEGACY_REMOVE) || defined(GDCM_LEGACY_SILENT)
+# define GDCM_LEGACY_BODY(method, version)
+# define GDCM_LEGACY_REPLACED_BODY(method, version, replace)
+#else
+# define GDCM_LEGACY_BODY(method, version) \
+  gdcmWarningMacro(#method " was deprecated for gdcm" #version " and will be removed in a future version.")
+# define GDCM_LEGACY_REPLACED_BODY(method, version, replace) \
+  gdcmWarningMacro(#method " was deprecated for gdcm" #version " and will be removed in a future version.  Use " #replace " instead.")
+#endif
+
 //-----------------------------------------------------------------------------
 #endif
index 8e1c6d1992a632eb90750e95942ec0701252ee3f..63b7a9a0f6b35ad902ebcd15a962b387d98f3140 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmOrientation.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 11:54:51 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMORIENTATION_H
 #define GDCMORIENTATION_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 #include <map>
 
 namespace gdcm 
@@ -95,7 +95,7 @@ typedef enum {
  * The values are given within the 'Patient referential', *not* within the 'Organ referential' ...
  */
 
-class GDCM_EXPORT Orientation : public RefCounter
+class GDCM_EXPORT Orientation : public CommandManager
 {
    gdcmTypeMacro(Orientation);
 public:
index 116a3a92c73987ecc71a9c2d352affeab60bbb27..a06da263d07d8d6af1e2088137008ce30c22a1a8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelReadConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 10:32:05 $
-  Version:   $Revision: 1.102 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.103 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -157,7 +157,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
             if( IsJPEG2000      = Global::GetTS()->IsJPEG2000(ts) )     break;
             if( IsMPEG          = Global::GetTS()->IsMPEG(ts) )         break;
             if( IsJPEGLS        = Global::GetTS()->IsJPEGLS(ts) )       break;
-            gdcmWarningMacro("Unexpected Transfer Syntax :[" << ts << "]");
+            gdcmStaticWarningMacro("Unexpected Transfer Syntax :[" << ts << "]");
             break;
          } 
       }
@@ -207,7 +207,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
       LutRedData = (uint8_t*)file->GetEntryBinArea( 0x0028, 0x1201 );
       if ( ! LutRedData )
       {
-         gdcmWarningMacro("Unable to read Red Palette Color Lookup Table data");
+         gdcmStaticWarningMacro("Unable to read Red Palette Color Lookup Table data");
       }
 
       // //// Green round:
@@ -215,7 +215,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
       LutGreenData = (uint8_t*)file->GetEntryBinArea(0x0028, 0x1202 );
       if ( ! LutGreenData)
       {
-         gdcmWarningMacro("Unable to read Green Palette Color Lookup Table data");
+         gdcmStaticWarningMacro("Unable to read Green Palette Color Lookup Table data");
       }
 
       // //// Blue round:
@@ -223,7 +223,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
       LutBlueData = (uint8_t*)file->GetEntryBinArea( 0x0028, 0x1203 );
       if ( ! LutBlueData )
       {
-         gdcmWarningMacro("Unable to read Blue Palette Color Lookup Table data");
+         gdcmStaticWarningMacro("Unable to read Blue Palette Color Lookup Table data");
       }
    }
    FileInternal = file;   
@@ -243,14 +243,14 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
    //// First stage: get our hands on the Pixel Data.
    if ( !fp )
    {
-      gdcmWarningMacro( "Unavailable file pointer." );
+      gdcmStaticWarningMacro( "Unavailable file pointer." );
       return false;
    }
 
    fp->seekg( PixelOffset, std::ios::beg );
    if ( fp->fail() || fp->eof() )
    {
-      gdcmWarningMacro( "Unable to find PixelOffset in file." );
+      gdcmStaticWarningMacro( "Unable to find PixelOffset in file." );
       return false;
    }
 
@@ -270,8 +270,8 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
       // variable). But RawSize is the right size of the image !
       if ( PixelDataLength != RawSize )
       {
-         gdcmWarningMacro( "Mismatch between PixelReadConvert : "
-                          << PixelDataLength << " and RawSize : " << RawSize );
+         gdcmStaticWarningMacro( "Mismatch between PixelReadConvert : "
+                              << PixelDataLength << " and RawSize : " << RawSize );
       }
       if ( PixelDataLength > RawSize )
       {
@@ -284,7 +284,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
 
       if ( fp->fail() || fp->eof())
       {
-         gdcmWarningMacro( "Reading of Raw pixel data failed." );
+         gdcmStaticWarningMacro( "Reading of Raw pixel data failed." );
          return false;
       }
    } 
@@ -293,13 +293,13 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
       if ( ! RLEInfo->DecompressRLEFile
                                ( fp, Raw, XSize, YSize, ZSize, BitsAllocated ) )
       {
-         gdcmWarningMacro( "RLE decompressor failed." );
+         gdcmStaticWarningMacro( "RLE decompressor failed." );
          return false;
       }
    }
    else if ( IsMPEG )
    {
-      //gdcmWarningMacro( "Sorry, MPEG not yet taken into account" );
+      //gdcmStaticWarningMacro( "Sorry, MPEG not yet taken into account" );
       //return false;
       // fp has already been seek to start of mpeg
       //ReadMPEGFile(fp, (char*)Raw, PixelDataLength); 
@@ -310,8 +310,8 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
       // Default case concerns JPEG family
       if ( ! ReadAndDecompressJPEGFile( fp ) )
       {
-         gdcmWarningMacro( "JPEG decompressor ( ReadAndDecompressJPEGFile()"
-                        << " method ) failed." );
+         gdcmStaticWarningMacro( "JPEG decompressor ( ReadAndDecompressJPEGFile()"
+                              << " method ) failed." );
          return false;
       }
    }
@@ -368,7 +368,7 @@ bool PixelReadConvert::BuildRGBImage()
       return false;
    }
 
-   gdcmDebugMacro( "--> BuildRGBImage" );
+   gdcmStaticDebugMacro( "--> BuildRGBImage" );
                                                                                 
    // Build RGB Pixels
    AllocateRGB();
@@ -477,7 +477,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp )
          inputlength += jpegfrag->GetLength();
          jpegfrag = JPEGInfo->GetNextFragment();
       }
-      gdcmAssertMacro( inputlength != 0);
+      gdcmStaticAssertMacro( inputlength != 0);
       uint8_t *inputdata = new uint8_t[inputlength];
       char *pinputdata = (char*)inputdata;
       jpegfrag = JPEGInfo->GetFirstFragment();
@@ -495,7 +495,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp )
          return true;
       }
       // wow what happen, must be an error
-      gdcmWarningMacro( "gdcm_read_JPEG2000_file() failed "); 
+      gdcmStaticWarningMacro( "gdcm_read_JPEG2000_file() failed "); 
       return false;
    }
    else if ( IsJPEGLS )
@@ -519,7 +519,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp )
          inputlength += jpegfrag->GetLength();
          jpegfrag = JPEGInfo->GetNextFragment();
       }
-      gdcmAssertMacro( inputlength != 0);
+      gdcmStaticAssertMacro( inputlength != 0);
       uint8_t *inputdata = new uint8_t[inputlength];
       char *pinputdata = (char*)inputdata;
       jpegfrag = JPEGInfo->GetFirstFragment();
@@ -539,7 +539,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp )
   delete[] inputdata;
 #endif
 
-      gdcmWarningMacro( "Sorry, JPEG-LS not yet taken into account" );
+      gdcmStaticWarningMacro( "Sorry, JPEG-LS not yet taken into account" );
       fp->seekg( JPEGInfo->GetFirstFragment()->GetOffset(), std::ios::beg);
 //    if ( ! gdcm_read_JPEGLS_file( fp,Raw ) )
          return false;
@@ -598,7 +598,7 @@ void PixelReadConvert::BuildLUTRGBA()
        || LutGreenDescriptor == GDCM_UNFOUND
        || LutBlueDescriptor  == GDCM_UNFOUND )
    {
-      gdcmWarningMacro( "(At least) a LUT Descriptor is missing" );
+      gdcmStaticWarningMacro( "(At least) a LUT Descriptor is missing" );
       return;
    }
 
@@ -614,7 +614,7 @@ void PixelReadConvert::BuildLUTRGBA()
                         &lengthR, &debR, &nbitsR );
    if ( nbRead != 3 )
    {
-      gdcmWarningMacro( "Wrong Red LUT descriptor" );
+      gdcmStaticWarningMacro( "Wrong Red LUT descriptor" );
    }                                                                                
    int lengthG;  // Green LUT length in Bytes
    int debG;     // Subscript of the first Lut Value
@@ -625,7 +625,7 @@ void PixelReadConvert::BuildLUTRGBA()
                     &lengthG, &debG, &nbitsG );  
    if ( nbRead != 3 )
    {
-      gdcmWarningMacro( "Wrong Green LUT descriptor" );
+      gdcmStaticWarningMacro( "Wrong Green LUT descriptor" );
    }
                                                                                 
    int lengthB;  // Blue LUT length in Bytes
@@ -636,15 +636,15 @@ void PixelReadConvert::BuildLUTRGBA()
                     &lengthB, &debB, &nbitsB );
    if ( nbRead != 3 )
    {
-      gdcmWarningMacro( "Wrong Blue LUT descriptor" );
+      gdcmStaticWarningMacro( "Wrong Blue LUT descriptor" );
    }
  
-   gdcmDebugMacro(" lengthR " << lengthR << " debR " 
-                 << debR << " nbitsR " << nbitsR);
-   gdcmDebugMacro(" lengthG " << lengthG << " debG " 
-                 << debG << " nbitsG " << nbitsG);
-   gdcmDebugMacro(" lengthB " << lengthB << " debB " 
-                 << debB << " nbitsB " << nbitsB);
+   gdcmStaticDebugMacro(" lengthR " << lengthR << " debR " 
+                      << debR << " nbitsR " << nbitsR);
+   gdcmStaticDebugMacro(" lengthG " << lengthG << " debG " 
+                      << debG << " nbitsG " << nbitsG);
+   gdcmStaticDebugMacro(" lengthB " << lengthB << " debB " 
+                      << debB << " nbitsB " << nbitsB);
 
    if ( !lengthR ) // if = 2^16, this shall be 0 see : CP-143
       lengthR=65536;
@@ -657,7 +657,7 @@ void PixelReadConvert::BuildLUTRGBA()
 
    if ( ( ! LutRedData ) || ( ! LutGreenData ) || ( ! LutBlueData ) )
    {
-      gdcmWarningMacro( "(At least) a LUT is missing" );
+      gdcmStaticWarningMacro( "(At least) a LUT is missing" );
       return;
    }
 
@@ -735,7 +735,7 @@ void PixelReadConvert::BuildLUTRGBA()
       // with 65536 entries LUT ?!?
       // Still looking for accurate info on the web :-(
 
-      gdcmWarningMacro( "Sorry Palette Color Lookup Tables not yet dealt with"
+      gdcmStaticWarningMacro( "Sorry Palette Color Lookup Tables not yet dealt with"
                          << " for 16 Bits Per Pixel images" );
 
       // forge the 4 * 16 Bits Red/Green/Blue/Alpha LUT
@@ -860,7 +860,7 @@ void PixelReadConvert::ConvertSwapZone()
             }
             break;
          default:
-            gdcmWarningMacro("SwapCode value (16 bits) not allowed." 
+            gdcmStaticWarningMacro("SwapCode value (16 bits) not allowed." 
                         << tempSwapCode);
       }
    }
@@ -906,7 +906,7 @@ void PixelReadConvert::ConvertSwapZone()
             }
             break;
          default:
-            gdcmWarningMacro("SwapCode value (32 bits) not allowed." << tempSwapCode );
+            gdcmStaticWarningMacro("SwapCode value (32 bits) not allowed." << tempSwapCode );
       }
    }
 }
@@ -1096,7 +1096,7 @@ bool PixelReadConvert::ConvertReArrangeBits() throw ( FormatError )
       }
       else
       {
-         gdcmWarningMacro("Weird image (BitsAllocated !=8, 12, 16, 32)");
+         gdcmStaticWarningMacro("Weird image (BitsAllocated !=8, 12, 16, 32)");
          throw FormatError( "Weird image !?" );
       }
    }
@@ -1109,7 +1109,7 @@ bool PixelReadConvert::ConvertReArrangeBits() throw ( FormatError )
  */
 void PixelReadConvert::ConvertRGBPlanesToRGBPixels()
 {
-   gdcmWarningMacro("--> ConvertRGBPlanesToRGBPixels");
+   gdcmStaticWarningMacro("--> ConvertRGBPlanesToRGBPixels");
 
    uint8_t *localRaw = Raw;
    uint8_t *copyRaw = new uint8_t[ RawSize ];
@@ -1145,7 +1145,7 @@ void PixelReadConvert::ConvertYcBcRPlanesToRGBPixels()
   // On such images, RLE achieves a compression ratio that is much better 
   // than the compression ratio on an equivalent RGB image. 
  
-   gdcmWarningMacro("--> ConvertYcBcRPlanesToRGBPixels");
+   gdcmStaticWarningMacro("--> ConvertYcBcRPlanesToRGBPixels");
    
    uint8_t *localRaw = Raw;
    uint8_t *copyRaw = new uint8_t[ RawSize ];
@@ -1245,13 +1245,13 @@ void PixelReadConvert::ConvertHandleColor()
    // - [Planar 1] AND [Photo C] handled with ConvertYcBcRPlanesToRGBPixels()
    // - [Planar 2] OR  [Photo D] requires LUT intervention.
 
-   gdcmDebugMacro("--> ConvertHandleColor "
-                    << "Planar Configuration " << PlanarConfiguration );
+   gdcmStaticDebugMacro("--> ConvertHandleColor "
+                     << "Planar Configuration " << PlanarConfiguration );
 
    if ( ! IsRawRGB() )
    {
       // [Planar 2] OR  [Photo D]: LUT intervention done outside
-      gdcmDebugMacro("--> RawRGB : LUT intervention done outside");
+      gdcmStaticDebugMacro("--> RawRGB : LUT intervention done outside");
       return;
    }
                                                                                 
@@ -1260,13 +1260,13 @@ void PixelReadConvert::ConvertHandleColor()
       if ( IsYBRFull )
       {
          // [Planar 1] AND [Photo C] (remember YBR_FULL_422 acts as RGB)
-         gdcmDebugMacro("--> YBRFull");
+         gdcmStaticDebugMacro("--> YBRFull");
          ConvertYcBcRPlanesToRGBPixels();
       }
       else
       {
          // [Planar 1] AND [Photo C]
-         gdcmDebugMacro("--> YBRFull");
+         gdcmStaticDebugMacro("--> YBRFull");
          ConvertRGBPlanesToRGBPixels();
       }
       return;
@@ -1277,7 +1277,7 @@ void PixelReadConvert::ConvertHandleColor()
 
    if (IsRLELossless)
    { 
-     gdcmDebugMacro("--> RLE Lossless");
+     gdcmStaticDebugMacro("--> RLE Lossless");
      ConvertRGBPlanesToRGBPixels();
    }
 
@@ -1352,7 +1352,7 @@ void PixelReadConvert::Print( std::ostream &os, std::string const &indent )
       }
       else
       {
-         gdcmWarningMacro("Set as RLE file but NO RLEinfo present.");
+         gdcmStaticWarningMacro("Set as RLE file but NO RLEinfo present.");
       }
    }
 
@@ -1364,7 +1364,7 @@ void PixelReadConvert::Print( std::ostream &os, std::string const &indent )
       }
       else
       {
-         gdcmWarningMacro("Set as JPEG file but NO JPEGinfo present.");
+         gdcmStaticWarningMacro("Set as JPEG file but NO JPEGinfo present.");
       }
    }
 }
index 972f6a8190498c09ad9cc9eb1ecc35a3744d8224..1fa42311aed0b7303deac16744828e7fbe864842 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmRLEFrame.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/09 10:18:44 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.10 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,25 +28,25 @@ namespace gdcm
 // Public
 void RLEFrame::SetOffset(unsigned int id,long offset)
 {
-   gdcmAssertMacro(id<15);
+   gdcmStaticAssertMacro(id<15);
    Offset[id] = offset;
 }
 
 long RLEFrame::GetOffset(unsigned int id)
 {
-   gdcmAssertMacro(id<15);
+   gdcmStaticAssertMacro(id<15);
    return Offset[id];
 }
 
 void RLEFrame::SetLength(unsigned int id,long length)
 {
-   gdcmAssertMacro(id<15);
+   gdcmStaticAssertMacro(id<15);
    Length[id] = length;
 }
 
 long RLEFrame::GetLength(unsigned int id)
 {
-   gdcmAssertMacro(id<15);
+   gdcmStaticAssertMacro(id<15);
    return Length[id];
 }
 
@@ -119,8 +119,9 @@ bool RLEFrame::ReadAndDecompressRLEFragment( uint8_t *subRaw,
                                                                                 
       if ( numberOfReadBytes > fragmentSize )
       {
-         gdcmWarningMacro( "Read more bytes (" << numberOfReadBytes
-              << " ) than the segment size. (" << fragmentSize << ")" );
+         gdcmStaticWarningMacro( "Read more bytes (" << numberOfReadBytes
+                              << " ) than the segment size. (" 
+                              << fragmentSize << ")" );
          return false;
       }
    }
index 4dcd5656abe9ce2d634fd71cf487fe7a5734fef7..c5ce8d88597532fa33edba6b5605ca7e1327b149 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmRLEFramesInfo.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/07 08:49:58 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -50,7 +50,7 @@ RLEFrame *RLEFramesInfo::GetFirstFrame()
 
 RLEFrame *RLEFramesInfo::GetNextFrame()
 {
-   gdcmAssertMacro (ItFrames != Frames.end());
+   gdcmStaticAssertMacro (ItFrames != Frames.end());
 
    ++ItFrames;
    if (ItFrames != Frames.end())
index ce9858acaef3bbf7c8c8715f79dfd66cb1cc1414..cafb784997905b96918f948b6a49ba5f778abc1e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmRefCounter.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/26 15:41:29 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,7 +20,6 @@
 #define GDCMREFCOUNTER_H
 
 #include "gdcmBase.h"
-#include "gdcmDebug.h"
 
 namespace gdcm 
 {
index 72fa2d3ad8db870555950308f1aabb21e081c0f8..519255c8b0592efb312d6f0ec30c81dba36ef54f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSerieHelper.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/25 13:56:32 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.31 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -22,7 +22,7 @@
 #include "gdcmCommon.h" 
 #include "gdcmTagKey.h" 
 #include "gdcmDebug.h"  // for LEGACY
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
  
 #include <vector>
 #include <iostream>
@@ -56,7 +56,7 @@ class File;
  *    into several XCoherent Filesets 
  *   XCoherent stands for 'Extra Coherent' (same orientation, or same position)
  */
-class GDCM_EXPORT SerieHelper  : public RefCounter
+class GDCM_EXPORT SerieHelper  : public CommandManager
 {
    gdcmTypeMacro(SerieHelper);
    
index 8c87c9a74ab5ec229f4d747ea71a78f06ce29775..60cdd16d85235c25fcf5cbba5fe050d388940073 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmTS.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:27 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.25 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMTS_H
 #define GDCMTS_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 
 #include <map>
 #include <string>
@@ -38,7 +38,7 @@ typedef std::map<TSKey, TSAtr> TSHT;    // Transfer Syntax Hash Table
  * \brief Container for dicom 'Transfer Syntax' Hash Table
  * \note   This is a singleton
  */
-class GDCM_EXPORT TS : public RefCounter
+class GDCM_EXPORT TS : public CommandManager
 {
    gdcmTypeMacro(TS);
 
index df94971e5654fb511429dfb73580f21d1b31c0fd..d351e406d85edccebf9b5d6249dabb08c6b94f28 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/22 20:30:46 $
-  Version:   $Revision: 1.176 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.177 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,6 +18,7 @@
 
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
+
 #include <iostream>
 #include <stdarg.h> // for va_list
 
@@ -452,7 +453,7 @@ bool Util::IsCurrentProcessorBigEndian()
 std::string Util::DicomString(const char *s, size_t l)
 {
    std::string r(s, s+l);
-   gdcmAssertMacro( !(r.size() % 2) ); // == basically 'l' is even
+   gdcmStaticAssertMacro( !(r.size() % 2) ); // == basically 'l' is even
    return r;
 }
 
@@ -475,7 +476,7 @@ std::string Util::DicomString(const char *s)
       l++;
    }
    std::string r(s, s+l);
-   gdcmAssertMacro( !(r.size() % 2) );
+   gdcmStaticAssertMacro( !(r.size() % 2) );
    return r;
 }
 
@@ -527,7 +528,7 @@ bool Util::CompareDicomString(const std::string &s1, const char *s2, int op)
      case GDCM_LESSOREQUAL :
         return s1_even <= s2_even;
      default :
-        gdcmDebugMacro(" Wrong operator : " << op);
+        gdcmStaticDebugMacro(" Wrong operator : " << op);
         return false;
   }
 }
@@ -871,7 +872,7 @@ std::string Util::GetMACAddress()
    }
    else
    {
-      gdcmWarningMacro("Problem in finding the MAC Address");
+      gdcmStaticWarningMacro("Problem in finding the MAC Address");
       return "";
    }
 }
@@ -913,7 +914,7 @@ std::string Util::CreateUniqueUID(const std::string &root)
    // If append is too long we need to rehash it
    if ( (prefix + append).size() > 64 )
    {
-      gdcmErrorMacro( "Size of UID is too long." );
+      gdcmStaticErrorMacro( "Size of UID is too long." );
       // we need a hash function to truncate this number
       // if only md5 was cross plateform
       // MD5(append);
index 2fed34d18eec9b28ee3c865b9c145ee305fcf18e..745797a2b7d040929d333d841323e059b4649da8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmVR.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/26 08:04:16 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMVR_H
 #define GDCMVR_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 #include "gdcmVRKey.h"
 
 #include <map>
@@ -39,7 +39,7 @@ typedef std::map<VRKey, VRAtr> VRHT;
  * \brief Container for dicom Value Representation Hash Table
  * \note   This is a singleton
  */
-class GDCM_EXPORT VR : public RefCounter
+class GDCM_EXPORT VR : public CommandManager
 {
    gdcmTypeMacro(VR);
 
index 752e3b18c1815f07a13d7732ca02f6ee28e15b0b..618ead72ca52899aa4214230a43eeed71199f8ac 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmValidator.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:27 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/11/28 15:20:34 $
+  Version:   $Revision: 1.4 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMVALIDATOR_H
 #define GDCMVALIDATOR_H
 
-#include "gdcmRefCounter.h"
+#include "gdcmCommandManager.h"
 
 namespace gdcm 
 {
@@ -27,7 +27,7 @@ namespace gdcm
  * \brief Class to perform some verifications on a gdcm::Document
  */
 class ElementSet;
-class GDCM_EXPORT Validator : public RefCounter
+class GDCM_EXPORT Validator : public CommandManager
 {
    gdcmTypeMacro(Validator);