From 46afb30d2d016a9b1581c7ee4ca96d614a35203c Mon Sep 17 00:00:00 2001 From: regrain Date: Mon, 28 Nov 2005 15:20:29 +0000 Subject: [PATCH] * Add Command and CommandManager to have possible callback 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 --- Testing/CMakeLists.txt | 1 + Testing/TestCommand.cxx | 93 ++++++++++++++ Testing/TestMakeDicomDir.cxx | 72 +++++++++-- Testing/TestUtil.cxx | 8 +- src/CMakeLists.txt | 3 + src/gdcmCallbackCommand.cxx | 109 ++++++++++++++++ src/gdcmCallbackCommand.h | 72 +++++++++++ src/gdcmCommand.cxx | 128 +++++++++++++++++++ src/gdcmCommand.h | 83 ++++++++++++ src/gdcmCommandManager.cxx | 121 ++++++++++++++++++ src/gdcmCommandManager.h | 64 ++++++++++ src/gdcmDebug.cxx | 76 +++++------ src/gdcmDebug.h | 229 ++++++++++++++-------------------- src/gdcmDicomDir.cxx | 144 +-------------------- src/gdcmDicomDir.h | 53 +------- src/gdcmDicomDirElement.h | 8 +- src/gdcmDicomEntry.h | 8 +- src/gdcmDict.h | 8 +- src/gdcmDictGroupName.h | 8 +- src/gdcmDictSet.cxx | 6 +- src/gdcmDictSet.h | 8 +- src/gdcmDirList.cxx | 54 ++++---- src/gdcmDirList.h | 7 +- src/gdcmDocEntry.h | 8 +- src/gdcmDocEntrySet.h | 8 +- src/gdcmFileHelper.h | 8 +- src/gdcmGlobal.cxx | 6 +- src/gdcmJPEGFragment.cxx | 6 +- src/gdcmJPEGFragmentsInfo.cxx | 6 +- src/gdcmJpeg.cxx | 6 +- src/gdcmJpeg2000.cxx | 6 +- src/gdcmMacro.h | 66 +++++++++- src/gdcmOrientation.h | 8 +- src/gdcmPixelReadConvert.cxx | 90 ++++++------- src/gdcmRLEFrame.cxx | 17 +-- src/gdcmRLEFramesInfo.cxx | 6 +- src/gdcmRefCounter.h | 5 +- src/gdcmSerieHelper.h | 8 +- src/gdcmTS.h | 8 +- src/gdcmUtil.cxx | 15 +-- src/gdcmVR.h | 8 +- src/gdcmValidator.h | 8 +- 42 files changed, 1113 insertions(+), 543 deletions(-) create mode 100644 Testing/TestCommand.cxx create mode 100644 src/gdcmCallbackCommand.cxx create mode 100644 src/gdcmCallbackCommand.h create mode 100644 src/gdcmCommand.cxx create mode 100644 src/gdcmCommand.h create mode 100644 src/gdcmCommandManager.cxx create mode 100644 src/gdcmCommandManager.h diff --git a/Testing/CMakeLists.txt b/Testing/CMakeLists.txt index 7bbeb306..207d2f2c 100644 --- a/Testing/CMakeLists.txt +++ b/Testing/CMakeLists.txt @@ -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 index 00000000..84de4307 --- /dev/null +++ b/Testing/TestCommand.cxx @@ -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 +#include + +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; +} diff --git a/Testing/TestMakeDicomDir.cxx b/Testing/TestMakeDicomDir.cxx index 0aa1ecc9..ec4edc48 100644 --- a/Testing/TestMakeDicomDir.cxx +++ b/Testing/TestMakeDicomDir.cxx @@ -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 @@ -22,11 +22,55 @@ #include "gdcmDebug.h" // --- -void StartMethod(void *startMethod) +class CommandStart : public gdcm::Command { - (void)startMethod; - std::cout<<"Start parsing"<(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." diff --git a/Testing/TestUtil.cxx b/Testing/TestUtil.cxx index 9e884fbf..5eab46e8 100644 --- a/Testing/TestUtil.cxx +++ b/Testing/TestUtil.cxx @@ -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() <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<first) + <<" : "<second).name() + <<" ("<second<<")"< +#include + +namespace gdcm +{ +//----------------------------------------------------------------------------- +class Command; +typedef std::map 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 diff --git a/src/gdcmDebug.cxx b/src/gdcmDebug.cxx index ba0a2fa4..ee5f72b5 100644 --- a/src/gdcmDebug.cxx +++ b/src/gdcmDebug.cxx @@ -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 @@ -17,28 +17,33 @@ =========================================================================*/ #include "gdcmDebug.h" +#include "gdcmCommandManager.h" + #include 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; } //----------------------------------------------------------------------------- diff --git a/src/gdcmDebug.h b/src/gdcmDebug.h index df9e02f8..8fb72a08 100644 --- a/src/gdcmDebug.h +++ b/src/gdcmDebug.h @@ -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 #include @@ -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 diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 27cbd3ea..bd5e478e 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -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; diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 4c432851..d9ec5b33 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -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 //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDirElement.h b/src/gdcmDicomDirElement.h index 945450a6..28d0e44a 100644 --- a/src/gdcmDicomDirElement.h +++ b/src/gdcmDicomDirElement.h @@ -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 @@ -65,7 +65,7 @@ typedef std::list 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); diff --git a/src/gdcmDicomEntry.h b/src/gdcmDicomEntry.h index dca0d819..b11e8c37 100644 --- a/src/gdcmDicomEntry.h +++ b/src/gdcmDicomEntry.h @@ -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); diff --git a/src/gdcmDict.h b/src/gdcmDict.h index a1259bab..aeda00ab 100644 --- a/src/gdcmDict.h +++ b/src/gdcmDict.h @@ -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 @@ -44,7 +44,7 @@ typedef std::map TagKeyHT; * combined with all software versions... * \see DictSet */ -class GDCM_EXPORT Dict : public RefCounter +class GDCM_EXPORT Dict : public CommandManager { gdcmTypeMacro(Dict); diff --git a/src/gdcmDictGroupName.h b/src/gdcmDictGroupName.h index d3aa1e9e..99a956d1 100644 --- a/src/gdcmDictGroupName.h +++ b/src/gdcmDictGroupName.h @@ -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 #include @@ -38,7 +38,7 @@ typedef std::map 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); diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 524f0f98..63c03594 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -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 { diff --git a/src/gdcmDictSet.h b/src/gdcmDictSet.h index e9ed37a6..e9d3bcbc 100644 --- a/src/gdcmDictSet.h +++ b/src/gdcmDictSet.h @@ -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 @@ -38,7 +38,7 @@ typedef std::map 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); diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 9fa27c89..64d0e077 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -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; diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index b30bc953..4fa92355 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -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 #include @@ -39,7 +40,7 @@ typedef std::vector 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); diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index ff098d10..65dad74f 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -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 @@ -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); diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index 98d95b53..b4f583e4 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -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); diff --git a/src/gdcmFileHelper.h b/src/gdcmFileHelper.h index a6a098bb..5a17c28f 100644 --- a/src/gdcmFileHelper.h +++ b/src/gdcmFileHelper.h @@ -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); diff --git a/src/gdcmGlobal.cxx b/src/gdcmGlobal.cxx index 4a21aca3..6f98bbfe 100644 --- a/src/gdcmGlobal.cxx +++ b/src/gdcmGlobal.cxx @@ -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(); diff --git a/src/gdcmJPEGFragment.cxx b/src/gdcmJPEGFragment.cxx index 8c82b1d8..5aec9aa3 100644 --- a/src/gdcmJPEGFragment.cxx +++ b/src/gdcmJPEGFragment.cxx @@ -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 "); } } diff --git a/src/gdcmJPEGFragmentsInfo.cxx b/src/gdcmJPEGFragmentsInfo.cxx index 4660612c..212dee6a 100644 --- a/src/gdcmJPEGFragmentsInfo.cxx +++ b/src/gdcmJPEGFragmentsInfo.cxx @@ -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()) diff --git a/src/gdcmJpeg.cxx b/src/gdcmJpeg.cxx index 7cfee75f..9b663f9f 100644 --- a/src/gdcmJpeg.cxx +++ b/src/gdcmJpeg.cxx @@ -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; } diff --git a/src/gdcmJpeg2000.cxx b/src/gdcmJpeg2000.cxx index 0064240c..5b017107 100644 --- a/src/gdcmJpeg2000.cxx +++ b/src/gdcmJpeg2000.cxx @@ -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; } diff --git a/src/gdcmMacro.h b/src/gdcmMacro.h index 389dbef4..5798178f 100644 --- a/src/gdcmMacro.h +++ b/src/gdcmMacro.h @@ -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 @@ -25,5 +25,67 @@ 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 diff --git a/src/gdcmOrientation.h b/src/gdcmOrientation.h index 8e1c6d19..63b7a9a0 100644 --- a/src/gdcmOrientation.h +++ b/src/gdcmOrientation.h @@ -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 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: diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 116a3a92..a06da263 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -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."); } } } diff --git a/src/gdcmRLEFrame.cxx b/src/gdcmRLEFrame.cxx index 972f6a81..1fa42311 100644 --- a/src/gdcmRLEFrame.cxx +++ b/src/gdcmRLEFrame.cxx @@ -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; } } diff --git a/src/gdcmRLEFramesInfo.cxx b/src/gdcmRLEFramesInfo.cxx index 4dcd5656..c5ce8d88 100644 --- a/src/gdcmRLEFramesInfo.cxx +++ b/src/gdcmRLEFramesInfo.cxx @@ -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()) diff --git a/src/gdcmRefCounter.h b/src/gdcmRefCounter.h index ce9858ac..cafb7849 100644 --- a/src/gdcmRefCounter.h +++ b/src/gdcmRefCounter.h @@ -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 { diff --git a/src/gdcmSerieHelper.h b/src/gdcmSerieHelper.h index 72fa2d3a..519255c8 100644 --- a/src/gdcmSerieHelper.h +++ b/src/gdcmSerieHelper.h @@ -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 #include @@ -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); diff --git a/src/gdcmTS.h b/src/gdcmTS.h index 8c87c9a7..60cdd16d 100644 --- a/src/gdcmTS.h +++ b/src/gdcmTS.h @@ -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 #include @@ -38,7 +38,7 @@ typedef std::map 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); diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index df94971e..d351e406 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -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 #include // 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); diff --git a/src/gdcmVR.h b/src/gdcmVR.h index 2fed34d1..745797a2 100644 --- a/src/gdcmVR.h +++ b/src/gdcmVR.h @@ -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 @@ -39,7 +39,7 @@ typedef std::map 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); diff --git a/src/gdcmValidator.h b/src/gdcmValidator.h index 752e3b18..618ead72 100644 --- a/src/gdcmValidator.h +++ b/src/gdcmValidator.h @@ -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); -- 2.45.1