Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkFEMMacro.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFEMMacro.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-01-30 21:10:19 $
00007   Version:   $Revision: 1.28 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkFEMMacro_h
00019 #define __itkFEMMacro_h
00020 
00036 //#define FEM_USE_SMART_POINTERS
00037 
00053 //#define FEM_BUILD_VISUALIZATION
00054 
00061 #ifdef FEM_BUILD_VISUALIZATION
00062 #include <afxwin.h>        /* required to draw the element on device context */
00063 #endif
00064 
00065 // Include this first, to avoid duplicate linking problems on some platforms (MSVC6).
00066 #include <fstream>
00067 
00068 #include "itkFEMObjectFactory.h"
00069 
00070 /* Required includes for itk's SmartPointer compatibility */
00071 #ifdef FEM_USE_SMART_POINTERS
00072 #include "itkMacro.h"
00073 #include "itkSmartPointer.h"
00074 #include "itkObjectFactory.h"
00075 #include "itkLightObject.h"
00076 #endif
00077 
00095 #ifndef FEM_USE_SMART_POINTERS
00096 
00097 #define FEM_ABSTRACT_CLASS(thisClass,parentClass)           \
00098 public:                                               \
00099                       \
00100   typedef thisClass Self;                             \
00101 
00102                \
00103   typedef parentClass Superclass;                     \
00104        \
00106   typedef Self* Pointer;                              \
00107  \
00109   typedef const Self* ConstPointer;                   \
00110 private:  // everything that follows from here is private by default (like in the beginning of class)
00111 
00112 #else
00113 
00114 #define FEM_ABSTRACT_CLASS(thisClass,parentClass)  \
00115 public:                                      \
00116              \
00117   typedef thisClass Self;                    \
00118 
00119       \
00120   typedef parentClass Superclass;            \
00121           \
00123   typedef SmartPointer<Self> Pointer;        \
00124     \
00126   typedef SmartPointer<const Self> ConstPointer;  \
00127   itkTypeMacro(thisClass,parentClass)        \
00128 private:  // everything that follows from here is private by default (like in the beginning of class)
00129 
00130 #endif
00131 
00150 #ifndef FEM_USE_SMART_POINTERS
00151   #define FEM_CLASS(thisClass,parentClass)   \
00152     /*  Pointers.... */                      \
00153     FEM_ABSTRACT_CLASS(thisClass,parentClass)      \
00154   public:                                    \
00155 
00156  \
00157     virtual Baseclass::Pointer Clone() const \
00158       { return new Self(*this); }            \
00159  \
00161     static Pointer New()                     \
00162       { return new Self(); }                 \
00163  \
00165     static Baseclass::Pointer NewB()         \
00166       { return New(); }                      \
00167    \
00169     static int CLID(void);                   \
00170  \
00172     virtual int ClassID() const              \
00173       { return CLID(); }                     \
00174   private:  // everything that follows from here is private by default (like in the beginning of class)
00175 #else
00176   #define FEM_CLASS(thisClass,parentClass)   \
00177     /*  Pointers.... */                      \
00178     FEM_ABSTRACT_CLASS(thisClass,parentClass)      \
00179   public:                                    \
00180 
00181   \
00182     virtual Baseclass::Pointer Clone() const \
00183       { Pointer o=new Self(*this);           \
00184         o->SetReferenceCount(1);             \
00185         return o; }                          \
00186  \
00188     itkNewMacro(Self)                        \
00189  \
00191     static Baseclass::Pointer NewB()         \
00192       { return New(); }                      \
00193    \
00195     static int CLID(void)                    \
00196  \
00198     virtual int ClassID() const              \
00199       { return CLID(); }                     \
00200   private:  // everything that follows from here is private by default (like in the beginning of class)
00201 #endif
00202 
00222 // FIXME: Remove definition, when no longer required.
00223 #define FEM_CLASS_REGISTER(thisClass) \
00224   int thisClass::CLID(void) \
00225   { static const int CLID_ = FEMObjectFactory<thisClass::Baseclass>::Register( thisClass::NewB, #thisClass); \
00226     return CLID_; }
00227 
00228 
00229 namespace itk {
00230 namespace fem {
00231 
00236 struct INITClass {
00237   INITClass(int i) {
00238     /*
00239      * Do something with the passed variable to
00240      * make sure that it is evaluated. This should
00241      * avoid all optimizations that compiler may
00242      * want to perform.
00243      */
00244     volatile int Dummy=i;
00245     Dummy++;
00246   }
00247 };
00248 
00249 }} // end namespace itk::fem
00250 
00265 #define FEM_CLASS_INIT(thisClass) \
00266   static INITClass Initializer_##thisClass(thisClass::CLID());
00267 
00268 #endif // #ifndef __itkFEMMacro_h
00269 

Generated at Sat Feb 28 12:24:47 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000