ITK  4.6.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 
94  static void RegisterFactoryInternal(ObjectFactoryBase *);
95 
99  typedef enum
100  {
103  INSERT_AT_POSITION
104  } InsertionPositionType;
105 
124  static bool RegisterFactory(ObjectFactoryBase *,
125  InsertionPositionType where=INSERT_AT_BACK, size_t position = 0);
127 
129  static void UnRegisterFactory(ObjectFactoryBase *);
130 
132  static void UnRegisterAllFactories();
133 
136  static std::list< ObjectFactoryBase * > GetRegisteredFactories();
137 
143  virtual const char * GetITKSourceVersion(void) const = 0;
144 
150  static void SetStrictVersionChecking( bool );
151  static void StrictVersionCheckingOn();
152  static void StrictVersionCheckingOff();
153  static bool GetStrictVersionChecking();
155 
157  virtual const char * GetDescription(void) const = 0;
158 
160  virtual std::list< std::string > GetClassOverrideNames();
161 
163  virtual std::list< std::string > GetClassOverrideWithNames();
164 
166  virtual std::list< std::string > GetClassOverrideDescriptions();
167 
169  virtual std::list< bool > GetEnableFlags();
170 
172  virtual void SetEnableFlag(bool flag,
173  const char *className,
174  const char *subclassName);
175 
177  virtual bool GetEnableFlag(const char *className,
178  const char *subclassName);
179 
183  virtual void Disable(const char *className);
184 
186  const char * GetLibraryPath();
187 
193  std::string m_Description;
194  std::string m_OverrideWithName;
197  };
198 
199 protected:
200  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
201 
203  void RegisterOverride(const char *classOverride,
204  const char *overrideClassName,
205  const char *description,
206  bool enableFlag,
207  CreateObjectFunctionBase *createFunction);
208 
212  virtual LightObject::Pointer CreateObject(const char *itkclassname);
213 
217  virtual std::list< LightObject::Pointer >
218  CreateAllObject(const char *itkclassname);
219 
221  virtual ~ObjectFactoryBase();
222 
223 private:
224  OverRideMap *m_OverrideMap;
225 
226  ObjectFactoryBase(const Self &); //purposely not implemented
227  void operator=(const Self &); //purposely not implemented
228 
230  static void InitializeFactoryList();
231 
234  static void Initialize();
235 
237  static void RegisterInternal();
238 
240  static void LoadDynamicFactories();
241 
243  static void LoadLibrariesInPath(const char *);
244 
245  static void DeleteNonInternalFactory( ObjectFactoryBase * );
246 
250  unsigned long m_LibraryDate;
251  std::string m_LibraryPath;
252 
254 };
255 } // end namespace itk
256 
257 #endif
Light weight base class for most itk classes.
SmartPointer< const Self > ConstPointer
Create instances of classes using an object factory.
SmartPointer< Self > Pointer
Internal implementation class for ObjectFactorBase.
Define API for object creation callback functions.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:57
CreateObjectFunctionBase::Pointer m_CreateObject