SMILX  1.01
elxComponentLoader.cxx
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 
15 #ifndef __elxComponentLoader_cxx
16 #define __elxComponentLoader_cxx
17 
18 #include "elxComponentLoader.h"
19 #include "elxSupportedImageTypes.h"
20 #include "elxInstallFunctions.h"
21 #include "elxMacro.h"
22 #include "elxInstallAllComponents.h"
23 #include <iostream>
24 #include <string>
25 
26 namespace elastix
27 {
28 using namespace xl;
29 
35 template< ComponentDatabase::IndexType VIndex >
37 {
38 public:
39 
42  typedef ElastixTypedef< VIndex > ET;
43  typedef typename ET::ElastixType ElastixType;
44  typedef ComponentDatabase::ComponentDescriptionType ComponentDescriptionType;
45 
46  static int DO( const ComponentDescriptionType & name, ComponentDatabase * cdb )
47  {
48  int dummy1 = InstallFunctions< ElastixType >::InstallComponent( name, VIndex, cdb );
49  int dummy2 = cdb->SetIndex(
50  ET::fPixelTypeAsString(),
51  ET::fDim(),
52  ET::mPixelTypeAsString(),
53  ET::mDim(),
54  VIndex );
55  if( ElastixTypedef< VIndex + 1 >::Defined() )
56  {
58  }
59  return ( dummy1 + dummy2 );
60  }
61 
62 
63 };
64 
65 // end template class
66 
68 template< >
69 class _installsupportedimagesrecursively< NrOfSupportedImageTypes + 1 >
70 {
71 public:
72 
73  typedef ComponentDatabase::ComponentDescriptionType ComponentDescriptionType;
74  static int DO( const ComponentDescriptionType & ,
75  ComponentDatabase * )
76  {
77  return 0;
78  }
79 };
80 
81 // end template class specialization
82 
88 {
89  this->m_ImageTypeSupportInstalled = false;
90 }
91 
92 
98 {
99  this->UnloadComponents();
100 }
101 
102 
106 int
108 {
120  int _InstallDummy_SupportedImageTypes
121  = _installsupportedimagesrecursively< 1 >::DO( "Elastix", this->m_ComponentDatabase );
122 
123  if( _InstallDummy_SupportedImageTypes == 0 )
124  {
125  this->m_ImageTypeSupportInstalled = true;
126  }
127 
128  return _InstallDummy_SupportedImageTypes;
129 
130 } // end InstallSupportedImageTypes
131 
132 
137 int
139 {
140  int installReturnCode = 0;
141 
143  if( !this->m_ImageTypeSupportInstalled )
144  {
145  installReturnCode = this->InstallSupportedImageTypes();
146  if( installReturnCode != 0 )
147  {
148  xout[ "error" ]
149  << "ERROR: ImageTypeSupport installation failed. "
150  << std::endl;
151  return installReturnCode;
152  }
153  } //end if !ImageTypeSupportInstalled
154 
155  elxout << "Installing all components." << std::endl;
156 
158  installReturnCode = InstallAllComponents( this->m_ComponentDatabase );
159 
160  if( installReturnCode )
161  {
162  xout[ "error" ]
163  << "ERROR: Installing of at least one of components failed." << std::endl;
164  return installReturnCode;
165  }
166 
167  elxout << "InstallingComponents was successful.\n" << std::endl;
168 
169  return 0;
170 
171 } // end LoadComponents
172 
173 
178 void
180 {
185  //Not necessary I think:
186  //this->m_ComponentDatabase = 0;
187 
188 } // end UnloadComponents
189 
190 
191 } //end namespace elastix
192 
193 #endif //#ifndef __elxComponentLoader_cxx
virtual int LoadComponents(const char *argv0)
virtual int InstallSupportedImageTypes(void)
virtual void UnloadComponents(void)