KWStyle - itkObjectFactory.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkObjectFactory.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:43 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12   Portions of this code are covered under the VTK copyright.
13   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
14
15      This software is distributed WITHOUT ANY WARRANTY; without even 
16      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
17 IND *****PURPOSE.  See the above copyright notices for more information.
18
19 =========================================================================*/
20 #ifndef __itkObjectFactory_h
21 #define __itkObjectFactory_h
22
23 #include "itkObjectFactoryBase.h"
24
25 namespace itk
26 {
27
28 /** \class ObjectFactory
29  * \brief Create instances of a class.
30  *
31  * ObjectFactory is a helper class used to created instances of a
32  * class. Object factories are used for instantiation because they allow
33  * run-time replacement of a class with a user-supplied version. For
34  * example, if you wished to replace an algorithm with your own custom
35  * version, or with a hardware-accelerated version, ObjectFactory
36  * can be used to do this.
37  *
38  * This implementation of the object factory is templated and uses RTTI
39  * (Run-Time Type Information) to create the name of the class it is to
40  * instantiate. (The name may include template type parameters, depending
41  * on the class definition.)
42  *
43  * \ingroup ITKSystemObjects
44  */
45
46 template <class T>
47 class ObjectFactory : public ObjectFactoryBase
48 {
49 public:
50   static typename T::Pointer Create()
51 IND **{
52     LightObject::Pointer ret = ObjectFactory::CreateInstance(typeid(T).name());
53     return dynamic_cast<T*>(ret.GetPointer());
54 IND **}
55 };
56
57 // end namespace itk
58
59 #endif
60
61 EOF         
62 EOF
63 EOF

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:37PM
© Kitware Inc.