ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkObjectFactoryBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkObjectFactoryBase_h
29 #define __itkObjectFactoryBase_h
30 
32 #include <list>
33 #include <vector>
34 
35 namespace itk
36 {
56 class OverRideMap;
57 
58 class ITKCommon_EXPORT ObjectFactoryBase:public Object
59 {
60 public:
63  typedef Object Superclass;
66 
68  itkTypeMacro(ObjectFactoryBase, Object);
69 
74  static LightObject::Pointer CreateInstance(const char *itkclassname);
75 
80  static std::list< LightObject::Pointer >
81  CreateAllInstance(const char *itkclassname);
82 
85  static void ReHash();
86 
91  static void RegisterFactoryInternal(ObjectFactoryBase *);
92 
96  typedef enum
97  {
100  INSERT_AT_POSITION
101  } InsertionPositionType;
102 
118  static void RegisterFactory(ObjectFactoryBase *,
119  InsertionPositionType where=INSERT_AT_BACK, size_t position = 0);
121 
123  static void UnRegisterFactory(ObjectFactoryBase *);
124 
126  static void UnRegisterAllFactories();
127 
130  static std::list< ObjectFactoryBase * > GetRegisteredFactories();
131 
137  virtual const char * GetITKSourceVersion(void) const = 0;
138 
144  static void SetStrictVersionChecking( bool );
145  static void StrictVersionCheckingOn();
146  static void StrictVersionCheckingOff();
147  static bool GetStrictVersionChecking();
149 
151  virtual const char * GetDescription(void) const = 0;
152 
154  virtual std::list< std::string > GetClassOverrideNames();
155 
157  virtual std::list< std::string > GetClassOverrideWithNames();
158 
160  virtual std::list< std::string > GetClassOverrideDescriptions();
161 
163  virtual std::list< bool > GetEnableFlags();
164 
166  virtual void SetEnableFlag(bool flag,
167  const char *className,
168  const char *subclassName);
169 
171  virtual bool GetEnableFlag(const char *className,
172  const char *subclassName);
173 
177  virtual void Disable(const char *className);
178 
180  const char * GetLibraryPath();
181 
187  std::string m_Description;
188  std::string m_OverrideWithName;
191  };
192 protected:
193  virtual void PrintSelf(std::ostream & os, Indent indent) const;
194 
196  void RegisterOverride(const char *classOverride,
197  const char *overrideClassName,
198  const char *description,
199  bool enableFlag,
200  CreateObjectFunctionBase *createFunction);
201 
205  virtual LightObject::Pointer CreateObject(const char *itkclassname);
206 
210  virtual std::list< LightObject::Pointer >
211  CreateAllObject(const char *itkclassname);
212 
214  virtual ~ObjectFactoryBase();
215 private:
216  OverRideMap *m_OverrideMap;
217 
218  ObjectFactoryBase(const Self &); //purposely not implemented
219  void operator=(const Self &); //purposely not implemented
220 
222  static void InitializeFactoryList();
223 
226  static void Initialize();
227 
229  static void RegisterDefaults();
230 
232  static void LoadDynamicFactories();
233 
235  static void LoadLibrariesInPath(const char *);
236 
240  unsigned long m_LibraryDate;
241  std::string m_LibraryPath;
242 
244 };
245 } // end namespace itk
246 
247 #endif
248