ITK  4.3.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 
193 protected:
194  virtual void PrintSelf(std::ostream & os, Indent indent) const;
195 
197  void RegisterOverride(const char *classOverride,
198  const char *overrideClassName,
199  const char *description,
200  bool enableFlag,
201  CreateObjectFunctionBase *createFunction);
202 
206  virtual LightObject::Pointer CreateObject(const char *itkclassname);
207 
211  virtual std::list< LightObject::Pointer >
212  CreateAllObject(const char *itkclassname);
213 
215  virtual ~ObjectFactoryBase();
216 
217 private:
218  OverRideMap *m_OverrideMap;
219 
220  ObjectFactoryBase(const Self &); //purposely not implemented
221  void operator=(const Self &); //purposely not implemented
222 
224  static void InitializeFactoryList();
225 
228  static void Initialize();
229 
231  static void RegisterDefaults();
232 
234  static void LoadDynamicFactories();
235 
237  static void LoadLibrariesInPath(const char *);
238 
242  unsigned long m_LibraryDate;
243  std::string m_LibraryPath;
244 
246 };
247 } // end namespace itk
248 
249 #endif
250