ITK  4.13.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 struct ObjectFactoryBasePrivate;
59 
60 class ITKCommon_EXPORT ObjectFactoryBase:public Object
61 {
62 public:
63 
66  typedef Object Superclass;
69 
71  itkTypeMacro(ObjectFactoryBase, Object);
72 
77  static LightObject::Pointer CreateInstance(const char *itkclassname);
78 
83  static std::list< LightObject::Pointer >
84  CreateAllInstance(const char *itkclassname);
85 
88  static void ReHash();
89 
97  static void RegisterFactoryInternal(ObjectFactoryBase *);
98 
102  typedef enum
103  {
106  INSERT_AT_POSITION
107  } InsertionPositionType;
108 
127  static bool RegisterFactory(ObjectFactoryBase *,
128  InsertionPositionType where=INSERT_AT_BACK, size_t position = 0);
130 
132  static void UnRegisterFactory(ObjectFactoryBase *);
133 
135  static void UnRegisterAllFactories();
136 
139  static std::list< ObjectFactoryBase * > GetRegisteredFactories();
140 
146  virtual const char * GetITKSourceVersion(void) const = 0;
147 
153  static void SetStrictVersionChecking( bool );
154  static void StrictVersionCheckingOn();
155  static void StrictVersionCheckingOff();
156  static bool GetStrictVersionChecking();
158 
160  virtual const char * GetDescription(void) const = 0;
161 
163  virtual std::list< std::string > GetClassOverrideNames();
164 
166  virtual std::list< std::string > GetClassOverrideWithNames();
167 
169  virtual std::list< std::string > GetClassOverrideDescriptions();
170 
172  virtual std::list< bool > GetEnableFlags();
173 
175  virtual void SetEnableFlag(bool flag,
176  const char *className,
177  const char *subclassName);
178 
180  virtual bool GetEnableFlag(const char *className,
181  const char *subclassName);
182 
186  virtual void Disable(const char *className);
187 
189  const char * GetLibraryPath();
190 
196  std::string m_Description;
197  std::string m_OverrideWithName;
200  };
201 
207  static ObjectFactoryBasePrivate *GetObjectFactoryBase();
208  static void SynchronizeObjectFactoryBase(ObjectFactoryBasePrivate * objectFactoryBasePrivate);
210 
211 protected:
212  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
213 
215  void RegisterOverride(const char *classOverride,
216  const char *overrideClassName,
217  const char *description,
218  bool enableFlag,
219  CreateObjectFunctionBase *createFunction);
220 
224  virtual LightObject::Pointer CreateObject(const char *itkclassname);
225 
229  virtual std::list< LightObject::Pointer >
230  CreateAllObject(const char *itkclassname);
231 
233  virtual ~ObjectFactoryBase() ITK_OVERRIDE;
234 
235 private:
236  OverRideMap *m_OverrideMap;
237 
238  ITK_DISALLOW_COPY_AND_ASSIGN(ObjectFactoryBase);
239 
241  static void InitializeFactoryList();
242 
245  static void Initialize();
246 
248  static void RegisterInternal();
249 
251  static void LoadDynamicFactories();
252 
254  static void LoadLibrariesInPath(const char *);
255 
256  static void DeleteNonInternalFactory( ObjectFactoryBase * );
257 
260  void * m_LibraryHandle;
261  unsigned long m_LibraryDate;
262  std::string m_LibraryPath;
263 
264  static bool m_StrictVersionChecking;
265 
266  // This variable should NOT be accessed directly, but through GetObjectFactoryBase
267  static ObjectFactoryBasePrivate * m_ObjectFactoryBasePrivate;
268 };
269 } // end namespace itk
270 
271 #endif
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:59
CreateObjectFunctionBase::Pointer m_CreateObject