ITK  5.0.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 "itkSingletonMacro.h"
33 #include <list>
34 #include <vector>
35 
36 namespace itk
37 {
57 // Forward reference because of private implementation
58 class OverRideMap;
59 struct ObjectFactoryBasePrivate;
60 
61 class ITKCommon_EXPORT ObjectFactoryBase:public Object
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_ASSIGN(ObjectFactoryBase);
65 
68  using Superclass = Object;
71 
73  itkTypeMacro(ObjectFactoryBase, Object);
74 
79  static LightObject::Pointer CreateInstance(const char *itkclassname);
80 
85  static std::list< LightObject::Pointer >
86  CreateAllInstance(const char *itkclassname);
87 
90  static void ReHash();
91 
99  static void RegisterFactoryInternal(ObjectFactoryBase *);
100 
104  typedef enum
105  {
108  INSERT_AT_POSITION
109  } InsertionPositionType;
110 
129  static bool RegisterFactory(ObjectFactoryBase *,
130  InsertionPositionType where=INSERT_AT_BACK, size_t position = 0);
132 
134  static void UnRegisterFactory(ObjectFactoryBase *);
135 
137  static void UnRegisterAllFactories();
138 
141  static std::list< ObjectFactoryBase * > GetRegisteredFactories();
142 
148  virtual const char * GetITKSourceVersion() const = 0;
149 
155  static void SetStrictVersionChecking( bool );
156  static void StrictVersionCheckingOn();
157  static void StrictVersionCheckingOff();
158  static bool GetStrictVersionChecking();
160 
162  virtual const char * GetDescription() const = 0;
163 
165  virtual std::list< std::string > GetClassOverrideNames();
166 
168  virtual std::list< std::string > GetClassOverrideWithNames();
169 
171  virtual std::list< std::string > GetClassOverrideDescriptions();
172 
174  virtual std::list< bool > GetEnableFlags();
175 
177  virtual void SetEnableFlag(bool flag,
178  const char *className,
179  const char *subclassName);
180 
182  virtual bool GetEnableFlag(const char *className,
183  const char *subclassName);
184 
188  virtual void Disable(const char *className);
189 
191  const char * GetLibraryPath();
192 
198  std::string m_Description;
199  std::string m_OverrideWithName;
202  };
203 
204 protected:
205  void PrintSelf(std::ostream & os, Indent indent) const override;
206 
208  void RegisterOverride(const char *classOverride,
209  const char *overrideClassName,
210  const char *description,
211  bool enableFlag,
212  CreateObjectFunctionBase *createFunction);
213 
217  virtual LightObject::Pointer CreateObject(const char *itkclassname);
218 
222  virtual std::list< LightObject::Pointer >
223  CreateAllObject(const char *itkclassname);
224 
226  ~ObjectFactoryBase() override;
227 
228 private:
229 
232  static void SynchronizeObjectFactoryBase(void * objectFactoryBasePrivate);
233  itkGetGlobalDeclarationMacro(ObjectFactoryBasePrivate, PimplGlobals);
235 
236  OverRideMap *m_OverrideMap;
237 
239  static void InitializeFactoryList();
240 
243  static void Initialize();
244 
246  static void RegisterInternal();
247 
249  static void LoadDynamicFactories();
250 
252  static void LoadLibrariesInPath(const char *);
253 
254  static void DeleteNonInternalFactory( ObjectFactoryBase * );
255 
259  unsigned long m_LibraryDate;
260  std::string m_LibraryPath;
261 
262  static ObjectFactoryBasePrivate * m_PimplGlobals;
263 };
264 
265 
266 } // end namespace itk
267 
268 #endif
Light weight base class for most itk classes.
static ObjectFactoryBasePrivate * m_PimplGlobals
Create instances of classes using an object factory.
#define itkGetGlobalDeclarationMacro(Type, VarName)
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:60
CreateObjectFunctionBase::Pointer m_CreateObject