ITK  4.12.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 // Forward reference because of private implementation
57 class OverRideMap;
58 
59 class ITKCommon_EXPORT ObjectFactoryBase:public Object
60 {
61 public:
64  typedef Object Superclass;
67 
69  itkTypeMacro(ObjectFactoryBase, Object);
70 
75  static LightObject::Pointer CreateInstance(const char *itkclassname);
76 
81  static std::list< LightObject::Pointer >
82  CreateAllInstance(const char *itkclassname);
83 
86  static void ReHash();
87 
95  static void RegisterFactoryInternal(ObjectFactoryBase *);
96 
100  typedef enum
101  {
104  INSERT_AT_POSITION
105  } InsertionPositionType;
106 
125  static bool RegisterFactory(ObjectFactoryBase *,
126  InsertionPositionType where=INSERT_AT_BACK, size_t position = 0);
128 
130  static void UnRegisterFactory(ObjectFactoryBase *);
131 
133  static void UnRegisterAllFactories();
134 
137  static std::list< ObjectFactoryBase * > GetRegisteredFactories();
138 
144  virtual const char * GetITKSourceVersion(void) const = 0;
145 
151  static void SetStrictVersionChecking( bool );
152  static void StrictVersionCheckingOn();
153  static void StrictVersionCheckingOff();
154  static bool GetStrictVersionChecking();
156 
158  virtual const char * GetDescription(void) const = 0;
159 
161  virtual std::list< std::string > GetClassOverrideNames();
162 
164  virtual std::list< std::string > GetClassOverrideWithNames();
165 
167  virtual std::list< std::string > GetClassOverrideDescriptions();
168 
170  virtual std::list< bool > GetEnableFlags();
171 
173  virtual void SetEnableFlag(bool flag,
174  const char *className,
175  const char *subclassName);
176 
178  virtual bool GetEnableFlag(const char *className,
179  const char *subclassName);
180 
184  virtual void Disable(const char *className);
185 
187  const char * GetLibraryPath();
188 
194  std::string m_Description;
195  std::string m_OverrideWithName;
198  };
199 
200 protected:
201  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
202 
204  void RegisterOverride(const char *classOverride,
205  const char *overrideClassName,
206  const char *description,
207  bool enableFlag,
208  CreateObjectFunctionBase *createFunction);
209 
213  virtual LightObject::Pointer CreateObject(const char *itkclassname);
214 
218  virtual std::list< LightObject::Pointer >
219  CreateAllObject(const char *itkclassname);
220 
222  virtual ~ObjectFactoryBase();
223 
224 private:
225  OverRideMap *m_OverrideMap;
226 
227  ITK_DISALLOW_COPY_AND_ASSIGN(ObjectFactoryBase);
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
virtual void PrintSelf(std::ostream &os, Indent indent) const override
SmartPointer< const Self > ConstPointer
virtual void Initialize()
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:59
CreateObjectFunctionBase::Pointer m_CreateObject