Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __cmtkMacros_h_included_
00034 #define __cmtkMacros_h_included_
00035
00036 #include <cmtkconfig.h>
00037
00038 #include <stdlib.h>
00039 #include <string.h>
00040 #include <vector>
00041
00042 #include <Base/cmtkTypes.h>
00043
00051 inline void abstract() {
00052 #ifdef DEBUG
00053 abort();
00054 #endif
00055 }
00056
00060 #define cmtkGetSetMacro(type,name) \
00061 public: type m_##name; \
00062 void Set##name( const type& v ) { this->m_##name = v; } \
00063 const type& Get##name() const { return this->m_##name; } \
00064 type& Get##name() { return this->m_##name; } \
00065 void Get##name( type& to ) { to = this->m_##name; }
00066
00070 #define cmtkGetSetMacroDefault(type,name,default) \
00071 public: type m_##name; \
00072 void Set##name( const type v = default ) { this->m_##name = v; } \
00073 const type& Get##name() const { return this->m_##name; } \
00074 type& Get##name() { return this->m_##name; } \
00075 void Get##name( type& to ) { to = this->m_##name; }
00076
00080 #define cmtkGetSetMacroString(name) \
00081 protected: char *m_##name; \
00082 public: void Set##name( const char* v ) { \
00083 if ( (this->m_##name != NULL) ) { if ( v != NULL ) \
00084 if ( !strcmp( this->m_##name, v ) ) return; \
00085 free(this->m_##name); this->m_##name = NULL; \
00086 } else { if ( v == NULL ) return; } \
00087 if ( v != NULL ) { this->m_##name = strdup(v); } } \
00088 char* Get##name() { return this->m_##name; } \
00089 const char* Get##name() const { return this->m_##name; } \
00090 void Get##name( char*& to ) { to = this->m_##name; }
00091
00095 #define cmtkGetSetMacroPtr(t,name) \
00096 public: t *m_##name; \
00097 void Set##name( t *const v ) { this->m_##name = v; } \
00098 t* Get##name() { return this->m_##name; } \
00099 const t* Get##name() const { return this->m_##name; } \
00100 void Get##name( t*& to ) { to = this->m_##name; }
00101
00105 #define cmtkGetSetMacro2Array(type,name) \
00106 public: type m_##name[2]; \
00107 void Set##name( const type v0, const type v1 ) \
00108 { this->m_##name[0] = v0; this->m_##name[1] = v1; } \
00109 void SetByIndex##name( const int axis, const type v ) \
00110 { this->m_##name[axis] = v; } \
00111 void Set##name( const type* v ) \
00112 { this->m_##name[0] = v[0]; this->m_##name[1] = v[1]; } \
00113 void Get##name( type &v0, type &v1 ) const \
00114 { v0 = this->m_##name[0]; v1 = this->m_##name[1]; } \
00115 void Get##name( type *const v ) const \
00116 { v[0] = this->m_##name[0]; v[1] = this->m_##name[1]; } \
00117 const type* Get##name() const { return this->m_##name; } \
00118 type* Get##name() { return this->m_##name; } \
00119 type Get##name( const int i ) const { return this->m_##name[i]; }
00120
00124 #define cmtkGetSetMacro3Array(type,name) \
00125 public: type m_##name[3]; \
00126 void Set##name( const type v0, const type v1, const type v2 ) \
00127 { this->m_##name[0] = v0; this->m_##name[1] = v1; this->m_##name[2] = v2; } \
00128 void SetByIndex##name( const int axis, const type v ) \
00129 { this->m_##name[axis] = v; } \
00130 void Set##name( const type* v ) \
00131 { this->m_##name[0] = v[0]; this->m_##name[1] = v[1]; this->m_##name[2] = v[2]; } \
00132 void Get##name( type &v0, type &v1, type &v2 ) const \
00133 { v0 = this->m_##name[0]; v1 = this->m_##name[1]; v2 = this->m_##name[2]; } \
00134 void Get##name( type *const v ) const \
00135 { v[0] = this->m_##name[0]; v[1] = this->m_##name[1]; v[2] = this->m_##name[2]; } \
00136 const type* Get##name() const { return this->m_##name; } \
00137 type* Get##name() { return this->m_##name; } \
00138 type Get##name( const int i ) const { return this->m_##name[i]; }
00139
00143 #define cmtkGetMacro3Array(type,name) \
00144 public: type m_##name[3]; \
00145 void Get##name( type &v0, type &v1, type &v2 ) const \
00146 { v0 = this->m_##name[0]; v1 = this->m_##name[1]; v2 = this->m_##name[2]; } \
00147 void Get##name( type *const v ) const \
00148 { v[0] = this->m_##name[0]; v[1] = this->m_##name[1]; v[2] = this->m_##name[2]; } \
00149 const type* Get##name() const { return this->m_##name; } \
00150 type* Get##name() { return this->m_##name; } \
00151 type Get##name( const int i ) const { return this->m_##name[i]; }
00152
00153
00154 #endif // #ifndef __cmtkMacros_h_included_