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: 2003-09-10 14:29:43 $
00007   Version:   $Revision: 1.27 $
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 
00021 
00022 
00023 
00039 //#define FEM_USE_SMART_POINTERS
00040 
00041 
00042 
00043 
00059 //#define FEM_BUILD_VISUALIZATION
00060 
00061 
00062 
00063 
00070 #ifdef FEM_BUILD_VISUALIZATION
00071 #include <afxwin.h>        /* required to draw the element on device context */
00072 #endif
00073 
00074 // Include this first, to avoid duplicate linking problems on some platforms (MSVC6).
00075 #include <fstream>
00076 
00077 #include "itkFEMObjectFactory.h"
00078 
00079 
00080 
00081 
00082 /* Required includes for itk's SmartPointer compatibility */
00083 #ifdef FEM_USE_SMART_POINTERS
00084 #include "itkMacro.h"
00085 #include "itkSmartPointer.h"
00086 #include "itkObjectFactory.h"
00087 #include "itkLightObject.h"
00088 #endif
00089 
00090 
00091 
00092 
00110 #ifndef FEM_USE_SMART_POINTERS
00111 
00112 #define FEM_ABSTRACT_CLASS(thisClass,parentClass)           \
00113 public:                                               \
00114                       \
00115   typedef thisClass Self;                             \
00116 
00117                \
00118   typedef parentClass Superclass;                     \
00119        \
00121   typedef Self* Pointer;                              \
00122  \
00124   typedef const Self* ConstPointer;                   \
00125 private:  // everything that follows from here is private by default (like in the beginning of class)
00126 
00127 #else
00128 
00129 #define FEM_ABSTRACT_CLASS(thisClass,parentClass)  \
00130 public:                                      \
00131              \
00132   typedef thisClass Self;                    \
00133 
00134       \
00135   typedef parentClass Superclass;            \
00136           \
00138   typedef SmartPointer<Self> Pointer;        \
00139     \
00141   typedef SmartPointer<const Self> ConstPointer;  \
00142   itkTypeMacro(thisClass,parentClass)        \
00143 private:  // everything that follows from here is private by default (like in the beginning of class)
00144 
00145 #endif
00146 
00147 
00148 
00149 
00168 #ifndef FEM_USE_SMART_POINTERS
00169   #define FEM_CLASS(thisClass,parentClass)   \
00170     /*  Pointers.... */                      \
00171     FEM_ABSTRACT_CLASS(thisClass,parentClass)      \
00172   public:                                    \
00173 
00174  \
00175     virtual Baseclass::Pointer Clone() const \
00176       { return new Self(*this); }            \
00177  \
00179     static Pointer New()                     \
00180       { return new Self(); }                 \
00181  \
00183     static Baseclass::Pointer NewB()         \
00184       { return New(); }                      \
00185    \
00187     static int CLID(void);                   \
00188  \
00190     virtual int ClassID() const              \
00191       { return CLID(); }                     \
00192   private:  // everything that follows from here is private by default (like in the beginning of class)
00193 #else
00194   #define FEM_CLASS(thisClass,parentClass)   \
00195     /*  Pointers.... */                      \
00196     FEM_ABSTRACT_CLASS(thisClass,parentClass)      \
00197   public:                                    \
00198 
00199   \
00200     virtual Baseclass::Pointer Clone() const \
00201       { Pointer o=new Self(*this);           \
00202         o->SetReferenceCount(1);             \
00203         return o; }                          \
00204  \
00206     itkNewMacro(Self)                        \
00207  \
00209     static Baseclass::Pointer NewB()         \
00210       { return New(); }                      \
00211    \
00213     static int CLID(void)                    \
00214  \
00216     virtual int ClassID() const              \
00217       { return CLID(); }                     \
00218   private:  // everything that follows from here is private by default (like in the beginning of class)
00219 #endif
00220 
00221 
00222 
00242 // FIXME: Remove definition, when no longer required.
00243 #define FEM_CLASS_REGISTER(thisClass) \
00244   int thisClass::CLID(void) \
00245   { static const int CLID_ = FEMObjectFactory<thisClass::Baseclass>::Register( thisClass::NewB, #thisClass); \
00246     return CLID_; }
00247 
00248 
00249 
00250 
00251 
00252 namespace itk {
00253 namespace fem {
00254 
00259 struct INITClass {
00260   INITClass(int i) {
00261     /*
00262      * Do something with the passed variable to
00263      * make sure that it is evaluated. This should
00264      * avoid all optimizations that compiler may
00265      * want to perform.
00266      */
00267     volatile int Dummy=i;
00268     Dummy++;
00269   }
00270 };
00271 
00272 }} // end namespace itk::fem
00273 
00274 
00275 
00290 #define FEM_CLASS_INIT(thisClass) \
00291   static INITClass Initializer_##thisClass(thisClass::CLID());
00292 
00293 
00294 
00295 #endif // #ifndef __itkFEMMacro_h
00296 

Generated at Mon Apr 14 12:23:53 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000