00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00030 #ifndef __itkMacro_h
00031 #define __itkMacro_h
00032
00033 #include "itkWin32Header.h"
00034 #include "itkConfigure.h"
00035
00036 #include <string>
00037 #include <cstdlib>
00038 #ifndef NDEBUG
00039 #include <cassert>
00040 #endif
00041
00042
00043
00044 #if !defined(CMAKE_NO_ANSI_STRING_STREAM)
00045 # include <sstream>
00046 #elif !defined(CMAKE_NO_ANSI_STREAM_HEADERS)
00047 # include <strstream>
00048 # define ITK_NO_ANSI_STRING_STREAM
00049 #else
00050 # include <strstream.h>
00051 # define ITK_NO_ANSI_STRING_STREAM
00052 #endif
00053
00058 namespace itk
00059 {
00060 }
00061
00064 #define itkNotUsed(x)
00065
00080 #if defined(_MSC_VER) && (_MSC_VER <= 1300)
00081 # define ITK_NO_INCLASS_MEMBER_INITIALIZATION
00082 #endif
00083 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x540)
00084 # define ITK_NO_INCLASS_MEMBER_INITIALIZATION
00085 #endif
00086 #if defined(__SVR4) && !defined(__SUNPRO_CC)
00087 # define ITK_NO_INCLASS_MEMBER_INITIALIZATION
00088 #endif
00089
00090
00091
00092
00093
00094
00095
00096
00097 #if defined(__GNUC__)
00098 # define ITK_NO_SIZEOF_CONSTANT_LOOKUP
00099 #endif
00100
00101 #if defined(_MSC_VER) && (_MSC_VER <= 1300)
00102 #define ITK_NO_SELF_AS_TRAIT_IN_TEMPLATE_ARGUMENTS
00103 #endif
00104
00105 #if defined(ITK_NO_INCLASS_MEMBER_INITIALIZATION) || \
00106 defined(ITK_NO_SIZEOF_CONSTANT_LOOKUP)
00107 # define itkStaticConstMacro(name,type,value) enum { name = value }
00108 #else
00109 # define itkStaticConstMacro(name,type,value) static const type name = value
00110 #endif
00111
00112 #ifdef ITK_NO_SELF_AS_TRAIT_IN_TEMPLATE_ARGUMENTS
00113 # define itkGetStaticConstMacro(name) name
00114 #else
00115 # define itkGetStaticConstMacro(name) (Self::name)
00116 #endif
00117
00119 #define itkSetInputMacro(name, type, number) \
00120 virtual void Set##name##Input(const type *_arg) \
00121 { \
00122 itkDebugMacro("setting input " #name " to " << _arg); \
00123 if (_arg != static_cast<type *>(this->ProcessObject::GetInput( number ))) \
00124 { \
00125 this->ProcessObject::SetNthInput( number, const_cast<type *>(_arg) ); \
00126 this->Modified(); \
00127 } \
00128 } \
00129 virtual void SetInput##number(const type *_arg) \
00130 { \
00131 itkDebugMacro("setting input " #number " to " << _arg); \
00132 if (_arg != static_cast<type *>(this->ProcessObject::GetInput( number ))) \
00133 { \
00134 this->ProcessObject::SetNthInput( number, const_cast<type *>(_arg) ); \
00135 this->Modified(); \
00136 } \
00137 }
00138
00139
00141 #define itkSuperclassTraitMacro(traitnameType) \
00142 typedef typename Superclass::traitnameType traitnameType;
00143
00145 #define itkGetInputMacro(name, type, number) \
00146 virtual const type * Get##name##Input() const \
00147 { \
00148 itkDebugMacro("returning input " << #name " of " << static_cast<const type *>(this->ProcessObject::GetInput( number )) ); \
00149 return static_cast<const type *>(this->ProcessObject::GetInput( number )); \
00150 } \
00151 virtual const type * GetInput##number() const \
00152 { \
00153 itkDebugMacro("returning input " << #number " of " << static_cast<const type *>(this->ProcessObject::GetInput( number )) ); \
00154 return static_cast<const type *>(this->ProcessObject::GetInput( number )); \
00155 }
00156
00157
00160 #define itkSetDecoratedInputMacro(name, type, number) \
00161 itkSetInputMacro(name, SimpleDataObjectDecorator<type>, number); \
00162 itkGetInputMacro(name, SimpleDataObjectDecorator<type>, number); \
00163 virtual void Set##name(const type &_arg) \
00164 { \
00165 typedef SimpleDataObjectDecorator< type > DecoratorType; \
00166 itkDebugMacro("setting input " #name " to " << _arg); \
00167 const DecoratorType * oldInput = \
00168 static_cast< const DecoratorType * >( \
00169 this->ProcessObject::GetInput(number) ); \
00170 if( oldInput && oldInput->Get() == _arg ) \
00171 { \
00172 return; \
00173 } \
00174 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
00175 newInput->Set( _arg ); \
00176 this->Set##name##Input( newInput ); \
00177 }
00178
00179
00183 #define itkSetDecoratedObjectInputMacro(name, type, number) \
00184 itkSetInputMacro(name, DataObjectDecorator<type>, number); \
00185 itkGetInputMacro(name, DataObjectDecorator<type>, number); \
00186 virtual void Set##name(const type *_arg) \
00187 { \
00188 typedef DataObjectDecorator< type > DecoratorType; \
00189 itkDebugMacro("setting input " #name " to " << _arg); \
00190 const DecoratorType * oldInput = \
00191 static_cast< const DecoratorType * >( \
00192 this->ProcessObject::GetInput(number) ); \
00193 if( oldInput && oldInput->Get() == _arg ) \
00194 { \
00195 return; \
00196 } \
00197 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
00198 newInput->Set( _arg ); \
00199 this->Set##name##Input( newInput ); \
00200 }
00201
00202
00203
00205 #define itkSetMacro(name,type) \
00206 virtual void Set##name (const type _arg) \
00207 { \
00208 itkDebugMacro("setting " #name " to " << _arg); \
00209 if (this->m_##name != _arg) \
00210 { \
00211 this->m_##name = _arg; \
00212 this->Modified(); \
00213 } \
00214 }
00215
00216
00218 #define itkGetMacro(name,type) \
00219 virtual type Get##name () \
00220 { \
00221 itkDebugMacro("returning " << #name " of " << this->m_##name ); \
00222 return this->m_##name; \
00223 }
00224
00225
00229 #define itkGetConstMacro(name,type) \
00230 virtual type Get##name () const \
00231 { \
00232 itkDebugMacro("returning " << #name " of " << this->m_##name ); \
00233 return this->m_##name; \
00234 }
00235
00236
00241 #define itkGetConstReferenceMacro(name,type) \
00242 virtual const type & Get##name () const \
00243 { \
00244 itkDebugMacro("returning " << #name " of " << this->m_##name ); \
00245 return this->m_##name; \
00246 }
00247
00248
00253 #define itkSetEnumMacro(name,type) \
00254 virtual void Set##name (const type _arg) \
00255 { \
00256 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
00257 if (this->m_##name != _arg) \
00258 { \
00259 this->m_##name = _arg; \
00260 this->Modified(); \
00261 } \
00262 }
00263
00264
00269 #define itkGetEnumMacro(name,type) \
00270 virtual type Get##name () const \
00271 { \
00272 itkDebugMacro("returning " << #name " of " << static_cast<long>(this->m_##name) ); \
00273 return this->m_##name; \
00274 }
00275
00276
00280 #define itkSetStringMacro(name) \
00281 virtual void Set##name (const char* _arg) \
00282 { \
00283 if ( _arg && (_arg == this->m_##name) ) { return;} \
00284 if (_arg) \
00285 { \
00286 this->m_##name = _arg;\
00287 } \
00288 else \
00289 { \
00290 this->m_##name = ""; \
00291 } \
00292 this->Modified(); \
00293 } \
00294 virtual void Set##name (const std::string & _arg) \
00295 { \
00296 this->Set##name( _arg.c_str() ); \
00297 } \
00298
00299
00300
00304 #define itkGetStringMacro(name) \
00305 virtual const char* Get##name () const \
00306 { \
00307 return this->m_##name.c_str(); \
00308 }
00309
00313 #define itkSetClampMacro(name,type,min,max) \
00314 virtual void Set##name (type _arg) \
00315 { \
00316 itkDebugMacro("setting " << #name " to " << _arg ); \
00317 if (this->m_##name != (_arg<min?min:(_arg>max?max:_arg))) \
00318 { \
00319 this->m_##name = (_arg<min?min:(_arg>max?max:_arg)); \
00320 this->Modified(); \
00321 } \
00322 }
00323
00324
00329 #define itkSetObjectMacro(name,type) \
00330 virtual void Set##name (type* _arg) \
00331 { \
00332 itkDebugMacro("setting " << #name " to " << _arg ); \
00333 if (this->m_##name != _arg) \
00334 { \
00335 this->m_##name = _arg; \
00336 this->Modified(); \
00337 } \
00338 }
00339
00340
00343 #define itkGetObjectMacro(name,type) \
00344 virtual type * Get##name () \
00345 { \
00346 itkDebugMacro("returning " #name " address " << this->m_##name ); \
00347 return this->m_##name.GetPointer(); \
00348 }
00349
00350
00355 #define itkSetConstObjectMacro(name,type) \
00356 virtual void Set##name (const type* _arg) \
00357 { \
00358 itkDebugMacro("setting " << #name " to " << _arg ); \
00359 if (this->m_##name != _arg) \
00360 { \
00361 this->m_##name = _arg; \
00362 this->Modified(); \
00363 } \
00364 }
00365
00366
00367
00370 #define itkGetConstObjectMacro(name,type) \
00371 virtual const type * Get##name () const \
00372 { \
00373 itkDebugMacro("returning " #name " address " << this->m_##name ); \
00374 return this->m_##name.GetPointer(); \
00375 }
00376
00377
00380 #define itkGetConstReferenceObjectMacro(name,type) \
00381 virtual const typename type::Pointer & Get##name () const \
00382 { \
00383 itkDebugMacro("returning " #name " address " << this->m_##name ); \
00384 return this->m_##name; \
00385 }
00386
00387
00390 #define itkBooleanMacro(name) \
00391 virtual void name##On () { this->Set##name(true);} \
00392 virtual void name##Off () { this->Set##name(false);}
00393
00394
00398 #define itkSetVectorMacro(name,type,count) \
00399 virtual void Set##name(type data[]) \
00400 { \
00401 unsigned int i; \
00402 for (i=0; i<count; i++) { if ( data[i] != this->m_##name[i] ) { break; }} \
00403 if ( i < count ) \
00404 { \
00405 this->Modified(); \
00406 for (i=0; i<count; i++) { this->m_##name[i] = data[i]; }\
00407 } \
00408 }
00409
00410
00413 #define itkGetVectorMacro(name,type,count) \
00414 virtual type *Get##name () const \
00415 { \
00416 return this->m_##name; \
00417 }
00418
00435 #define itkNewMacro(x) \
00436 static Pointer New(void) \
00437 { \
00438 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
00439 if(smartPtr.GetPointer() == NULL) \
00440 { \
00441 smartPtr = new x; \
00442 } \
00443 smartPtr->UnRegister(); \
00444 return smartPtr; \
00445 } \
00446 virtual ::itk::LightObject::Pointer CreateAnother(void) const \
00447 { \
00448 ::itk::LightObject::Pointer smartPtr; \
00449 smartPtr = x::New().GetPointer(); \
00450 return smartPtr; \
00451 }
00452
00453
00454
00471 #define itkFactorylessNewMacro(x) \
00472 static Pointer New(void) \
00473 { \
00474 Pointer smartPtr; \
00475 x *rawPtr = new x; \
00476 smartPtr = rawPtr; \
00477 rawPtr->UnRegister(); \
00478 return smartPtr; \
00479 } \
00480 virtual ::itk::LightObject::Pointer CreateAnother(void) const \
00481 { \
00482 ::itk::LightObject::Pointer smartPtr; \
00483 smartPtr = x::New().GetPointer(); \
00484 return smartPtr; \
00485 }
00486
00487
00490 #define itkTypeMacro(thisClass,superclass) \
00491 virtual const char *GetNameOfClass() const \
00492 {return #thisClass;}
00493
00494
00495 namespace itk
00496 {
00503 extern ITKCommon_EXPORT void OutputWindowDisplayText(const char*);
00504 extern ITKCommon_EXPORT void OutputWindowDisplayErrorText(const char*);
00505 extern ITKCommon_EXPORT void OutputWindowDisplayWarningText(const char*);
00506 extern ITKCommon_EXPORT void OutputWindowDisplayGenericOutputText(const char*);
00507 extern ITKCommon_EXPORT void OutputWindowDisplayDebugText(const char*);
00508 }
00510
00514 #if defined(ITK_LEAN_AND_MEAN) || defined(__BORLANDC__) || defined(NDEBUG)
00515 #define itkDebugMacro(x)
00516 #else
00517 #define itkDebugMacro(x) \
00518 { if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
00519 { ::itk::OStringStream itkmsg; \
00520 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
00521 << this->GetNameOfClass() << " (" << this << "): " x \
00522 << "\n\n"; \
00523 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str());} \
00524 }
00525 #endif
00526
00527
00528
00532 #ifdef ITK_LEAN_AND_MEAN
00533 #define itkWarningMacro(x)
00534 #else
00535 #define itkWarningMacro(x) \
00536 { if (::itk::Object::GetGlobalWarningDisplay()) \
00537 { ::itk::OStringStream itkmsg; \
00538 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
00539 << this->GetNameOfClass() << " (" << this << "): " x \
00540 << "\n\n"; \
00541 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str());} \
00542 }
00543 #endif
00544
00545
00546 namespace itk
00547 {
00548
00554 #if !defined(ITK_NO_ANSI_STRING_STREAM)
00555 class OStringStream: public std::ostringstream
00556 {
00557 public:
00558 OStringStream() {}
00559 private:
00560 OStringStream(const OStringStream&);
00561 void operator=(const OStringStream&);
00562 };
00563 #else
00564 namespace OStringStreamDetail
00565 {
00566 class Cleanup
00567 {
00568 public:
00569 Cleanup(std::ostrstream& ostr): m_OStrStream(ostr) {}
00570 ~Cleanup() { m_OStrStream.rdbuf()->freeze(0); }
00571 static void IgnoreUnusedVariable(const Cleanup&) {}
00572 protected:
00573 std::ostrstream& m_OStrStream;
00574 };
00575 }
00577
00578 class OStringStream: public std::ostrstream
00579 {
00580 public:
00581 typedef std::ostrstream Superclass;
00582 OStringStream() {}
00583 std::string str()
00584 {
00585 OStringStreamDetail::Cleanup cleanup(*this);
00586 OStringStreamDetail::Cleanup::IgnoreUnusedVariable(cleanup);
00587 int pcount = this->pcount();
00588 const char* ptr = this->Superclass::str();
00589 return std::string(ptr?ptr:"", pcount);
00590 }
00591 private:
00592 OStringStream(const OStringStream&);
00593 void operator=(const OStringStream&);
00594 };
00595 #endif
00596
00597 }
00598
00599 #if defined(ITK_CPP_FUNCTION)
00600 #if defined(__BORLANDC__)
00601 #define ITK_LOCATION __FUNC__
00602 #elif defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(CABLE_CONFIGURATION) && !defined(CSWIG)
00603 #define ITK_LOCATION __FUNCSIG__
00604 #elif defined(__GNUC__)
00605 #define ITK_LOCATION __PRETTY_FUNCTION__
00606 #else
00607 #define ITK_LOCATION __FUNCTION__
00608 #endif
00609 #else
00610 #define ITK_LOCATION "unknown"
00611 #endif
00612
00613 #include "itkExceptionObject.h"
00614
00618 #define itkExceptionMacro(x) \
00619 { \
00620 ::itk::OStringStream message; \
00621 message << "itk::ERROR: " << this->GetNameOfClass() \
00622 << "(" << this << "): " x; \
00623 ::itk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str(),ITK_LOCATION); \
00624 throw e_; \
00625 }
00626
00627
00628 #define itkGenericExceptionMacro(x) \
00629 { \
00630 ::itk::OStringStream message; \
00631 message << "itk::ERROR: " x; \
00632 ::itk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str(),ITK_LOCATION); \
00633 throw e_; \
00634 }
00635
00636 #ifdef ITK_LEAN_AND_MEAN
00637 #define itkGenericOutputMacro(x)
00638 #else
00639 #define itkGenericOutputMacro(x) \
00640 { if (::itk::Object::GetGlobalWarningDisplay()) \
00641 { ::itk::OStringStream itkmsg; \
00642 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
00643 x << "\n\n"; \
00644 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str());} \
00645 }
00646 #endif
00647
00648
00649
00650
00651 #define itkLogMacro( x, y) \
00652 { \
00653 if (this->GetLogger() ) \
00654 { \
00655 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
00656 } \
00657 }
00658
00659
00660 #define itkLogMacroStatic( obj, x, y) \
00661 { \
00662 if (obj->GetLogger() ) \
00663 { \
00664 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
00665 } \
00666 }
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692 #if defined(ITK_LEGACY_REMOVE)
00693
00694
00695
00696
00697 # define itkLegacyMacro(method) class itkLegacyMethodRemoved
00698 #elif defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST) || defined(CSWIG)
00699
00700 # define itkLegacyMacro(method) method
00701 #else
00702
00703
00704 # if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
00705 # define itkLegacyMacro(method) method __attribute__((deprecated))
00706 # elif defined(_MSC_VER) && _MSC_VER >= 1300
00707 # define itkLegacyMacro(method) __declspec(deprecated) method
00708 # else
00709 # define itkLegacyMacro(method) method
00710 # endif
00711 #endif
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726 #if defined(ITK_LEGACY_REMOVE) || defined(ITK_LEGACY_SILENT)
00727 # define itkLegacyBodyMacro(method, version)
00728 # define itkLegacyReplaceBodyMacro(method, version, replace)
00729 # define itkGenericLegacyBodyMacro(method, version)
00730 # define itkGenericLegacyReplaceBodyMacro(method, version, replace)
00731 #else
00732 # define itkLegacyBodyMacro(method, version) \
00733 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
00734 # define itkLegacyReplaceBodyMacro(method, version, replace) \
00735 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version. Use " #replace " instead.")
00736 # define itkGenericLegacyBodyMacro(method, version) \
00737 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
00738 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
00739 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version. Use " #replace " instead.")
00740 #endif
00741
00742 #if defined(__INTEL_COMPILER)
00743 # pragma warning (disable: 193)
00744 #endif
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775 #if defined(ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_NULL_STRING)
00776 #define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T)
00777 #else
00778 #if defined(ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_EMPTY_BRACKETS)
00779 #define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) <>
00780 #else
00781 #if defined(ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_TEMPLATE_ARGUMENTS)
00782 #define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) <T>
00783 #endif
00784 #endif
00785 #endif
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798 #if defined(__sgi) && defined(_COMPILER_VERSION)
00799 # define ITK_TEMPLATE_DO_NOT_INSTANTIATE 1
00800 #elif defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 700
00801 # define ITK_TEMPLATE_EXTERN 1
00802 #elif defined(__GNUC__) && __GNUC__ >= 3
00803 # define ITK_TEMPLATE_EXTERN 1
00804 #elif defined(_MSC_VER) && _MSC_VER >= 1300
00805 # define ITK_TEMPLATE_EXTERN 1
00806 #endif
00807 #if !defined(ITK_TEMPLATE_DO_NOT_INSTANTIATE)
00808 # define ITK_TEMPLATE_DO_NOT_INSTANTIATE 0
00809 #endif
00810 #if !defined(ITK_TEMPLATE_EXTERN)
00811 # define ITK_TEMPLATE_EXTERN 0
00812 #endif
00813
00814
00815
00816
00817
00818
00819
00820
00821 #define ITK_TEMPLATE_EXPORT(x) ITK_TEMPLATE_EXPORT_DELAY(x)
00822 #define ITK_TEMPLATE_EXPORT_DELAY(x) template ITK_TEMPLATE_##x;
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832 #if ITK_TEMPLATE_EXTERN
00833 # define ITK_TEMPLATE_IMPORT_DELAY(x) extern template ITK_TEMPLATE_##x;
00834 # if defined(_MSC_VER)
00835 # pragma warning (disable: 4231)
00836 # endif
00837 #elif ITK_TEMPLATE_DO_NOT_INSTANTIATE
00838 # define ITK_TEMPLATE_IMPORT_DELAY(x) \
00839 ITK_TEMPLATE_IMPORT_IMPL(do_not_instantiate ITK_TEMPLATE_##x)
00840 # define ITK_TEMPLATE_IMPORT_IMPL(x) _Pragma(#x)
00841 #endif
00842 #if defined(ITK_TEMPLATE_IMPORT_DELAY)
00843 # define ITK_TEMPLATE_IMPORT(x) ITK_TEMPLATE_IMPORT_DELAY(x)
00844 # define ITK_TEMPLATE_IMPORT_WORKS 1
00845 #else
00846 # define ITK_TEMPLATE_IMPORT(x)
00847 # define ITK_TEMPLATE_IMPORT_WORKS 0
00848 #endif
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906 #define ITK_EXPORT_TEMPLATE(EXPORT, c, x, y) \
00907 ITK_TEMPLATE_##c(ITK_TEMPLATE_EXPORT, EXPORT ITK_EMPTY, x, y)
00908 #define ITK_IMPORT_TEMPLATE(EXPORT, c, x, y) \
00909 ITK_TEMPLATE_##c(ITK_TEMPLATE_IMPORT, EXPORT ITK_EMPTY, x, y)
00910 #define ITK_EMPTY
00911
00912
00913
00914
00915
00916 #define ITK_TEMPLATE_1(x1) x1
00917 #define ITK_TEMPLATE_2(x1,x2) x1,x2
00918 #define ITK_TEMPLATE_3(x1,x2,x3) x1,x2,x3
00919 #define ITK_TEMPLATE_4(x1,x2,x3,x4) x1,x2,x3,x4
00920 #define ITK_TEMPLATE_5(x1,x2,x3,x4,x5) x1,x2,x3,x4,x5
00921 #define ITK_TEMPLATE_6(x1,x2,x3,x4,x5,x6) x1,x2,x3,x4,x5,x6
00922 #define ITK_TEMPLATE_7(x1,x2,x3,x4,x5,x6,x7) x1,x2,x3,x4,x5,x6,x7
00923 #define ITK_TEMPLATE_8(x1,x2,x3,x4,x5,x6,x7,x8) x1,x2,x3,x4,x5,x6,x7,x8
00924 #define ITK_TEMPLATE_9(x1,x2,x3,x4,x5,x6,x7,x8,x9) x1,x2,x3,x4,x5,x6,x7,x8,x9
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934 #if defined(ITK_MANUAL_INSTANTIATION)
00935 # define ITK_TEMPLATE_TXX 0
00936 #else
00937 # define ITK_TEMPLATE_TXX !(ITK_TEMPLATE_CXX || ITK_TEMPLATE_TYPE)
00938 #endif
00939
00940
00941
00942
00943
00944
00945 #if ITK_TEMPLATE_CXX
00946 # undef ITK_MANUAL_INSTANTIATION
00947 # define ITK_MANUAL_INSTANTIATION
00948 # if defined(_MSC_VER)
00949 # pragma warning (disable: 4275)
00950 # pragma warning (disable: 4661)
00951 # endif
00952 #endif
00953
00954
00955
00956
00957 #define ITK_EXPORT_ITKCommon(c, x, n) \
00958 ITK_EXPORT_TEMPLATE(ITKCommon_EXPORT, c, x, n)
00959 #define ITK_IMPORT_ITKCommon(c, x, n) \
00960 ITK_IMPORT_TEMPLATE(ITKCommon_EXPORT, c, x, n)
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975 #if ITK_TEMPLATE_IMPORT_WORKS && defined(ITK_EXPLICIT_INSTANTIATION)
00976 # define ITK_TEMPLATE_EXPLICIT !ITK_TEMPLATE_CXX
00977 #else
00978 # define ITK_TEMPLATE_EXPLICIT 0
00979 #endif
00980
00981
00982
00983
00984
00985
00986
00987
00988 #if defined(__GNUC__)
00989 # if (((__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 3))
00990 # define ITK_NO_RETURN \
00991 __attribute__ ((noreturn))
00992 # endif
00993 #else
00994 # define ITK_NO_RETURN
00995 #endif
00996
00997
00998 #ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010 #define itkForLoopAssignmentMacro(DestinationType,SourceType,DestinationElementType,DestinationArray,SourceArray,NumberOfIterations) \
01011 for(unsigned int i=0;i < NumberOfIterations; ++i) \
01012 { \
01013 DestinationArray[i] = static_cast< DestinationElementType >( SourceArray[i] ); \
01014 }
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024 #define itkForLoopRoundingAndAssignmentMacro(DestinationType,Sourcrnd_halfintup,DestinationElementType,DestinationArray,SourceArray,NumberOfIterations) \
01025 for(unsigned int i=0;i < NumberOfIterations; ++i) \
01026 { \
01027 DestinationArray[i] = itk::Math::Round< DestinationElementType >( SourceArray[i] ); \
01028 }
01029
01030 #endif
01031
01032
01033
01034 #ifndef NDEBUG
01035
01036 #ifdef _POSIX_SOURCE
01037 #define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail (msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
01038 #else
01039 #define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro( << msg );
01040 #endif
01041
01042 #else
01043 #define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro( << msg);
01044 #endif
01045
01046 #define itkAssertOrThrowMacro(test, message) \
01047 if( !(test) ) \
01048 { \
01049 ::itk::OStringStream msgstr; \
01050 msgstr << message; \
01051 itkAssertInDebugOrThrowInReleaseMacro( msgstr.str().c_str() ); \
01052 }
01053
01054 #endif //end of itkMacro.h
01055