52 #if !defined(CMAKE_NO_ANSI_STRING_STREAM)
54 #elif !defined(CMAKE_NO_ANSI_STREAM_HEADERS)
56 # define IGTL_NO_ANSI_STRING_STREAM
58 # include <strstream.h>
59 # define IGTL_NO_ANSI_STRING_STREAM
71 #define igtlNotUsed(x)
87 #if defined(_MSC_VER) && (_MSC_VER <= 1300)
88 # define IGTL_NO_INCLASS_MEMBER_INITIALIZATION
90 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x540)
91 # define IGTL_NO_INCLASS_MEMBER_INITIALIZATION
93 #if defined(__SVR4) && !defined(__SUNPRO_CC)
94 # define IGTL_NO_INCLASS_MEMBER_INITIALIZATION
104 #if defined(__GNUC__)
105 # define IGTL_NO_SIZEOF_CONSTANT_LOOKUP
108 #if defined(_MSC_VER) && (_MSC_VER <= 1300)
109 #define IGTL_NO_SELF_AS_TRAIT_IN_TEMPLATE_ARGUMENTS
112 #if defined(IGTL_NO_INCLASS_MEMBER_INITIALIZATION) || \
113 defined(IGTL_NO_SIZEOF_CONSTANT_LOOKUP)
114 # define igtlStaticConstMacro(name,type,value) enum { name = value }
116 # define igtlStaticConstMacro(name,type,value) static const type name = value
119 #ifdef IGTL_NO_SELF_AS_TRAIT_IN_TEMPLATE_ARGUMENTS
120 # define igtlGetStaticConstMacro(name) name
122 # define igtlGetStaticConstMacro(name) (Self::name)
126 #define igtlSetInputMacro(name, type, number) \
127 virtual void Set##name##Input(const type *_arg) \
129 igtlDebugMacro("setting input " #name " to " << _arg); \
130 if (_arg != static_cast<type *>(this->ProcessObject::GetInput( number ))) \
132 this->ProcessObject::SetNthInput( number, const_cast<type *>(_arg) ); \
135 virtual void SetInput##number(const type *_arg) \
137 igtlDebugMacro("setting input " #number " to " << _arg); \
138 if (_arg != static_cast<type *>(this->ProcessObject::GetInput( number ))) \
140 this->ProcessObject::SetNthInput( number, const_cast<type *>(_arg) ); \
146 #define igtlSuperclassTraitMacro(traitnameType) \
147 typedef typename Superclass::traitnameType traitnameType;
150 #define igtlGetInputMacro(name, type, number) \
151 virtual const type * Get##name##Input() const \
153 igtlDebugMacro("returning input " << #name " of " << static_cast<const type *>(this->ProcessObject::GetInput( number )) ); \
154 return static_cast<const type *>(this->ProcessObject::GetInput( number )); \
156 virtual const type * GetInput##number() const \
158 igtlDebugMacro("returning input " << #number " of " << static_cast<const type *>(this->ProcessObject::GetInput( number )) ); \
159 return static_cast<const type *>(this->ProcessObject::GetInput( number )); \
165 #define igtlSetDecoratedInputMacro(name, type, number) \
166 igtlSetInputMacro(name, SimpleDataObjectDecorator<type>, number); \
167 igtlGetInputMacro(name, SimpleDataObjectDecorator<type>, number); \
168 virtual void Set##name(const type &_arg) \
170 typedef SimpleDataObjectDecorator< type > DecoratorType; \
171 igtlDebugMacro("setting input " #name " to " << _arg); \
172 const DecoratorType * oldInput = \
173 static_cast< const DecoratorType * >( \
174 this->ProcessObject::GetInput(number) ); \
175 if( oldInput && oldInput->Get() == _arg ) \
179 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
180 newInput->Set( _arg ); \
181 this->Set##name##Input( newInput ); \
188 #define igtlSetDecoratedObjectInputMacro(name, type, number) \
189 igtlSetInputMacro(name, DataObjectDecorator<type>, number); \
190 igtlGetInputMacro(name, DataObjectDecorator<type>, number); \
191 virtual void Set##name(const type *_arg) \
193 typedef DataObjectDecorator< type > DecoratorType; \
194 igtlDebugMacro("setting input " #name " to " << _arg); \
195 const DecoratorType * oldInput = \
196 static_cast< const DecoratorType * >( \
197 this->ProcessObject::GetInput(number) ); \
198 if( oldInput && oldInput->Get() == _arg ) \
202 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
203 newInput->Set( _arg ); \
204 this->Set##name##Input( newInput ); \
210 #define igtlSetMacro(name,type) \
211 virtual void Set##name (const type _arg) \
213 igtlDebugMacro("setting " #name " to " << _arg); \
214 if (this->m_##name != _arg) \
216 this->m_##name = _arg; \
222 #define igtlGetMacro(name,type) \
223 virtual type Get##name () \
225 igtlDebugMacro("returning " << #name " of " << this->m_##name ); \
226 return this->m_##name; \
233 #define igtlGetConstMacro(name,type) \
234 virtual type Get##name () const \
236 igtlDebugMacro("returning " << #name " of " << this->m_##name ); \
237 return this->m_##name; \
245 #define igtlGetConstReferenceMacro(name,type) \
246 virtual const type & Get##name () const \
248 igtlDebugMacro("returning " << #name " of " << this->m_##name ); \
249 return this->m_##name; \
256 #define igtlSetEnumMacro(name,type) \
257 virtual void Set##name (const type _arg) \
259 igtlDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
260 if (this->m_##name != _arg) \
262 this->m_##name = _arg; \
270 #define igtlGetEnumMacro(name,type) \
271 virtual type Get##name () const \
273 igtlDebugMacro("returning " << #name " of " << static_cast<long>(this->m_##name) ); \
274 return this->m_##name; \
281 #define igtlSetStringMacro(name) \
282 virtual void Set##name (const char* _arg) \
284 if ( _arg && (_arg == this->m_##name) ) { return;} \
287 this->m_##name = _arg;\
291 this->m_##name = ""; \
294 virtual void Set##name (const std::string & _arg) \
296 this->Set##name( _arg.c_str() ); \
304 #define igtlGetStringMacro(name) \
305 virtual const char* Get##name () const \
307 return this->m_##name.c_str(); \
313 #define igtlSetClampMacro(name,type,min,max) \
314 virtual void Set##name (type _arg) \
316 igtlDebugMacro("setting " << #name " to " << _arg ); \
317 if (this->m_##name != (_arg<min?min:(_arg>max?max:_arg))) \
319 this->m_##name = (_arg<min?min:(_arg>max?max:_arg)); \
328 #define igtlSetObjectMacro(name,type) \
329 virtual void Set##name (type* _arg) \
331 igtlDebugMacro("setting " << #name " to " << _arg ); \
332 if (this->m_##name != _arg) \
334 this->m_##name = _arg; \
341 #define igtlGetObjectMacro(name,type) \
342 virtual type * Get##name () \
344 igtlDebugMacro("returning " #name " address " << this->m_##name ); \
345 return this->m_##name.GetPointer(); \
353 #define igtlSetConstObjectMacro(name,type) \
354 virtual void Set##name (const type* _arg) \
356 igtlDebugMacro("setting " << #name " to " << _arg ); \
357 if (this->m_##name != _arg) \
359 this->m_##name = _arg; \
367 #define igtlGetConstObjectMacro(name,type) \
368 virtual const type * Get##name () const \
370 igtlDebugMacro("returning " #name " address " << this->m_##name ); \
371 return this->m_##name.GetPointer(); \
377 #define igtlGetConstReferenceObjectMacro(name,type) \
378 virtual const typename type::Pointer & Get##name () const \
380 igtlDebugMacro("returning " #name " address " << this->m_##name ); \
381 return this->m_##name; \
387 #define igtlBooleanMacro(name) \
388 virtual void name##On () { this->Set##name(true);} \
389 virtual void name##Off () { this->Set##name(false);}
395 #define igtlSetVectorMacro(name,type,count) \
396 virtual void Set##name(type data[]) \
399 for (i=0; i<count; i++) { if ( data[i] != this->m_##name[i] ) { break; }} \
402 for (i=0; i<count; i++) { this->m_##name[i] = data[i]; }\
409 #define igtlGetVectorMacro(name,type,count) \
410 virtual type *Get##name () const \
412 return this->m_##name; \
431 #define igtlNewMacro(x) \
432 static Pointer New(void) \
434 Pointer smartPtr = ::igtl::ObjectFactory<x>::Create(); \
435 if(smartPtr.GetPointer() == NULL) \
439 smartPtr->UnRegister(); \
442 virtual ::igtl::LightObject::Pointer CreateAnother(void) const \
444 ::igtl::LightObject::Pointer smartPtr; \
445 smartPtr = x::New().GetPointer(); \
467 #define igtlFactorylessNewMacro(x) \
468 static Pointer New(void) \
473 rawPtr->UnRegister(); \
476 virtual ::igtl::LightObject::Pointer CreateAnother(void) const \
478 ::igtl::LightObject::Pointer smartPtr; \
479 smartPtr = x::New().GetPointer(); \
486 #define igtlTypeMacro(thisClass,superclass) \
487 virtual const char *GetNameOfClass() const \
510 #if defined(IGTL_LEAN_AND_MEAN) || defined(__BORLANDC__)
511 #define igtlDebugMacro(x)
513 #define igtlDebugMacro(x) \
514 { if (this->GetDebug() ) \
515 { ::igtl::OStringStream igtlmsg; \
516 igtlmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
517 << this->GetNameOfClass() << " (" << this << "): " x \
519 std::cerr << igtlmsg.str(); } \
528 #ifdef IGTL_LEAN_AND_MEAN
529 #define igtlWarningMacro(x)
531 #define igtlWarningMacro(x) \
533 { ::igtl::OStringStream igtlmsg; \
534 igtlmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
535 << this->GetNameOfClass() << " (" << this << "): " x \
537 std::cerr << igtlmsg.str(); } \
550 #if !defined(IGTL_NO_ANSI_STRING_STREAM)
560 namespace OStringStreamDetail
565 Cleanup(std::ostrstream& ostr): m_OStrStream(ostr) {}
566 ~Cleanup() { m_OStrStream.rdbuf()->freeze(0); }
567 static void IgnoreUnusedVariable(
const Cleanup&) {}
569 std::ostrstream& m_OStrStream;
574 class OStringStream:
public std::ostrstream
577 typedef std::ostrstream Superclass;
581 OStringStreamDetail::Cleanup cleanup(*
this);
582 OStringStreamDetail::Cleanup::IgnoreUnusedVariable(cleanup);
583 int pcount = this->pcount();
584 const char* ptr = this->Superclass::str();
585 return std::string(ptr?ptr:
"", pcount);
595 #if defined(IGTL_CPP_FUNCTION)
596 #if defined(__BORLANDC__)
597 #define IGTL_LOCATION __FUNC__
598 #elif defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(CABLE_CONFIGURATION) && !defined(CSWIG)
599 #define IGTL_LOCATION __FUNCSIG__
600 #elif defined(__GNUC__)
601 #define IGTL_LOCATION __PRETTY_FUNCTION__
603 #define IGTL_LOCATION __FUNCTION__
606 #define IGTL_LOCATION "unknown"
609 #define igtlExceptionMacro(x) \
611 ::igtl::OStringStream igtlmsg; \
612 igtlmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
613 << this->GetNameOfClass() << " (" << this << "): " x \
615 std::cerr << igtlmsg.str(); \
618 #define igtlErrorMacro(x) \
620 ::igtl::OStringStream igtlmsg; \
621 igtlmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
622 << this->GetNameOfClass() << " (" << this << "): " x \
624 std::cerr << igtlmsg.str(); \
628 #ifdef IGTL_LEAN_AND_MEAN
629 #define igtlGenericOutputMacro(x)
631 #define igtlGenericOutputMacro(x) \
633 { ::igtl::OStringStream igtlmsg; \
634 igtlmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
636 std::cerr << igtlmsg.str();} \
645 #define igtlLogMacro( x, y) \
647 if (this->GetLogger() ) \
649 this->GetLogger()->Write(::igtl::LoggerBase::x, y); \
654 #define igtlLogMacroStatic( obj, x, y) \
656 if (obj->GetLogger() ) \
658 obj->GetLogger()->Write(::igtl::LoggerBase::x, y); \
686 #if defined(IGTL_LEGACY_REMOVE)
691 # define igtlLegacyMacro(method) class igtlLegacyMethodRemoved
692 #elif defined(IGTL_LEGACY_SILENT) || defined(IGTL_LEGACY_TEST) || defined(CSWIG)
694 # define igtlLegacyMacro(method) method
698 # if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
699 # define igtlLegacyMacro(method) method __attribute__((deprecated))
700 # elif defined(_MSC_VER) && _MSC_VER >= 1300
701 # define igtlLegacyMacro(method) __declspec(deprecated) method
703 # define igtlLegacyMacro(method) method
720 #if defined(IGTL_LEGACY_REMOVE) || defined(IGTL_LEGACY_SILENT)
721 # define igtlLegacyBodyMacro(method, version)
722 # define igtlLegacyReplaceBodyMacro(method, version, replace)
724 # define igtlLegacyBodyMacro(method, version) \
725 igtlWarningMacro(#method " was deprecated for IGTL " #version " and will be removed in a future version.")
726 # define igtlLegacyReplaceBodyMacro(method, version, replace) \
727 igtlWarningMacro(#method " was deprecated for IGTL " #version " and will be removed in a future version. Use " #replace " instead.")
730 #if defined(__INTEL_COMPILER)
731 # pragma warning (disable: 193)
744 #if defined(__sgi) && defined(_COMPILER_VERSION)
745 # define IGTL_TEMPLATE_DO_NOT_INSTANTIATE 1
746 #elif defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 700
747 # define IGTL_TEMPLATE_EXTERN 1
748 #elif defined(__GNUC__) && __GNUC__ >= 3
749 # define IGTL_TEMPLATE_EXTERN 1
750 #elif defined(_MSC_VER) && _MSC_VER >= 1300
751 # define IGTL_TEMPLATE_EXTERN 1
753 #if !defined(IGTL_TEMPLATE_DO_NOT_INSTANTIATE)
754 # define IGTL_TEMPLATE_DO_NOT_INSTANTIATE 0
756 #if !defined(IGTL_TEMPLATE_EXTERN)
757 # define IGTL_TEMPLATE_EXTERN 0
767 #define IGTL_TEMPLATE_EXPORT(x) IGTL_TEMPLATE_EXPORT_DELAY(x)
768 #define IGTL_TEMPLATE_EXPORT_DELAY(x) template IGTL_TEMPLATE_##x;
778 #if IGTL_TEMPLATE_EXTERN
779 # define IGTL_TEMPLATE_IMPORT_DELAY(x) extern template IGTL_TEMPLATE_##x;
780 # if defined(_MSC_VER)
781 # pragma warning (disable: 4231)
783 #elif IGTL_TEMPLATE_DO_NOT_INSTANTIATE
784 # define IGTL_TEMPLATE_IMPORT_DELAY(x) \
785 IGTL_TEMPLATE_IMPORT_IMPL(do_not_instantiate IGTL_TEMPLATE_##x)
786 # define IGTL_TEMPLATE_IMPORT_IMPL(x) _Pragma(#x)
788 #if defined(IGTL_TEMPLATE_IMPORT_DELAY)
789 # define IGTL_TEMPLATE_IMPORT(x) IGTL_TEMPLATE_IMPORT_DELAY(x)
790 # define IGTL_TEMPLATE_IMPORT_WORKS 1
792 # define IGTL_TEMPLATE_IMPORT(x)
793 # define IGTL_TEMPLATE_IMPORT_WORKS 0
852 #define IGTL_EXPORT_TEMPLATE(EXPORT, c, x, y) \
853 IGTL_TEMPLATE_##c(IGTL_TEMPLATE_EXPORT, EXPORT IGTL_EMPTY, x, y)
854 #define IGTL_IMPORT_TEMPLATE(EXPORT, c, x, y) \
855 IGTL_TEMPLATE_##c(IGTL_TEMPLATE_IMPORT, EXPORT IGTL_EMPTY, x, y)
862 #define IGTL_TEMPLATE_1(x1) x1
863 #define IGTL_TEMPLATE_2(x1,x2) x1,x2
864 #define IGTL_TEMPLATE_3(x1,x2,x3) x1,x2,x3
865 #define IGTL_TEMPLATE_4(x1,x2,x3,x4) x1,x2,x3,x4
866 #define IGTL_TEMPLATE_5(x1,x2,x3,x4,x5) x1,x2,x3,x4,x5
867 #define IGTL_TEMPLATE_6(x1,x2,x3,x4,x5,x6) x1,x2,x3,x4,x5,x6
868 #define IGTL_TEMPLATE_7(x1,x2,x3,x4,x5,x6,x7) x1,x2,x3,x4,x5,x6,x7
869 #define IGTL_TEMPLATE_8(x1,x2,x3,x4,x5,x6,x7,x8) x1,x2,x3,x4,x5,x6,x7,x8
870 #define IGTL_TEMPLATE_9(x1,x2,x3,x4,x5,x6,x7,x8,x9) x1,x2,x3,x4,x5,x6,x7,x8,x9
880 #if defined(IGTL_MANUAL_INSTANTIATION)
881 # define IGTL_TEMPLATE_TXX 0
883 # define IGTL_TEMPLATE_TXX !(IGTL_TEMPLATE_CXX || IGTL_TEMPLATE_TYPE)
891 #if IGTL_TEMPLATE_CXX
892 # undef IGTL_MANUAL_INSTANTIATION
893 # define IGTL_MANUAL_INSTANTIATION
894 # if defined(_MSC_VER)
895 # pragma warning (disable: 4275)
896 # pragma warning (disable: 4661)
903 #define IGTL_EXPORT_IGTLCommon(c, x, n) \
904 IGTL_EXPORT_TEMPLATE(IGTLCommon_EXPORT, c, x, n)
905 #define IGTL_IMPORT_IGTLCommon(c, x, n) \
906 IGTL_IMPORT_TEMPLATE(IGTLCommon_EXPORT, c, x, n)
921 #if IGTL_TEMPLATE_IMPORT_WORKS && defined(IGTL_EXPLICIT_INSTANTIATION)
922 # define IGTL_TEMPLATE_EXPLICIT !IGTL_TEMPLATE_CXX
924 # define IGTL_TEMPLATE_EXPLICIT 0
934 #if defined(__GNUC__)
935 # if (((__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 3))
936 # define IGTL_NO_RETURN \
937 __attribute__ ((noreturn))
940 # define IGTL_NO_RETURN
944 #ifdef IGTL_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
956 #define igtlFoorLoopAssignmentMacro(DestinationType,SourceType,DestinationElementType,DestinationArray,SourceArray,NumberOfIterations) \
957 for(unsigned int i=0;i < NumberOfIterations; ++i) \
959 DestinationArray[i] = static_cast< DestinationElementType >( SourceArray[i] ); \
970 #define igtlFoorLoopRoundingAndAssignmentMacro(DestinationType,SourceType,DestinationElementType,DestinationArray,SourceArray,NumberOfIterations) \
971 for(unsigned int i=0;i < NumberOfIterations; ++i) \
973 DestinationArray[i] = static_cast< DestinationElementType >( vnl_math_rnd( SourceArray[i] ) ); \
980 #endif //end of igtlMacro.h
The "igtl" namespace contains all OpenIGTLink classes. There are several nested namespaces within the...