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: 2002/10/02 22:54:34 $
00007   Version:   $Revision: 1.26 $
00008 
00009   Copyright (c) 2002 Insight 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   typedef parentClass Superclass;                     \
00118        \
00119   typedef Self* Pointer;                              \
00120  \
00121   typedef const Self* ConstPointer;                   \
00122 private:  // everything that follows from here is private by default (like in the beginning of class)
00123 
00124 #else
00125 
00126 #define FEM_ABSTRACT_CLASS(thisClass,parentClass)  \
00127 public:                                      \
00128              \
00129   typedef thisClass Self;                    \
00130       \
00131   typedef parentClass Superclass;            \
00132           \
00133   typedef SmartPointer<Self> Pointer;        \
00134     \
00135   typedef SmartPointer<const Self> ConstPointer;  \
00136   itkTypeMacro(thisClass,parentClass)        \
00137 private:  // everything that follows from here is private by default (like in the beginning of class)
00138 
00139 #endif
00140 
00141 
00142 
00143 
00162 #ifndef FEM_USE_SMART_POINTERS
00163   #define FEM_CLASS(thisClass,parentClass)   \
00164     /*  Pointers.... */                      \
00165     FEM_ABSTRACT_CLASS(thisClass,parentClass)      \
00166   public:                                    \
00167  \
00168     virtual Baseclass::Pointer Clone() const \
00169       { return new Self(*this); }            \
00170  \
00171     static Pointer New()                     \
00172       { return new Self(); }                 \
00173  \
00174     static Baseclass::Pointer NewB()         \
00175       { return New(); }                      \
00176    \
00177     static int CLID(void);                   \
00178  \
00179     virtual int ClassID() const              \
00180       { return CLID(); }                     \
00181   private:  // everything that follows from here is private by default (like in the beginning of class)
00182 #else
00183   #define FEM_CLASS(thisClass,parentClass)   \
00184     /*  Pointers.... */                      \
00185     FEM_ABSTRACT_CLASS(thisClass,parentClass)      \
00186   public:                                    \
00187   \
00188     virtual Baseclass::Pointer Clone() const \
00189       { Pointer o=new Self(*this);           \
00190         o->SetReferenceCount(1);             \
00191         return o; }                          \
00192  \
00193     itkNewMacro(Self)                        \
00194  \
00195     static Baseclass::Pointer NewB()         \
00196       { return New(); }                      \
00197    \
00198     static int CLID(void)                    \
00199  \
00200     virtual int ClassID() const              \
00201       { return CLID(); }                     \
00202   private:  // everything that follows from here is private by default (like in the beginning of class)
00203 #endif
00204 
00205 
00206 
00226 // FIXME: Remove definition, when no longer required.
00227 #define FEM_CLASS_REGISTER(thisClass) \
00228   int thisClass::CLID(void) \
00229   { static const int CLID_ = FEMObjectFactory<thisClass::Baseclass>::Register( thisClass::NewB, #thisClass); \
00230     return CLID_; }
00231 
00232 
00233 
00234 
00235 namespace itk {
00236 namespace fem {
00237 
00242 struct INITClass {
00243   INITClass(int i) {
00244     /*
00245      * Do something with the passed variable to
00246      * make sure that it is evaluated. This should
00247      * avoid all optimizations that compiler may
00248      * want to perform.
00249      */
00250     volatile int Dummy=i;
00251     Dummy++;
00252   }
00253 };
00254 
00255 }} // end namespace itk::fem
00256 
00257 
00258 
00273 #define FEM_CLASS_INIT(thisClass) \
00274   static INITClass Initializer_##thisClass(thisClass::CLID());
00275 
00276 
00277 
00278 #endif // #ifndef __itkFEMMacro_h

Generated at Wed Mar 12 01:12:56 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000