KWStyle - itkAutoPointerDataObjectDecorator.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkAutoPointerDataObjectDecorator.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:33 $
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 __itkAutoPointerDataObjectDecorator_h
21 #define __itkAutoPointerDataObjectDecorator_h
22
23 #include <memory>
24 #include "itkDataObject.h"
25
26 namespace itk
27 {
28
29
30 /** \class AutoPointerDataObjectDecorator
31 LEN  * \brief Decorates any pointer to a simple object with a DataObject API using AutoPointer semantics.
32  *
33  * AutoPointerDataObjectDecorator decorates a pointer to an object
34  * with a DataObject API. This allows a pointer to an object to be
35  * encapsulated in a DataObject and passed through the pipeline. This
36  * object differs from SimpleDataObjectDecorator in that the decorator
37  * takes control of deleting the pointer upon destruction.
38  *
39  * The decorator provides two methods Set() and Get() to access the
40  * decorated object (referred internally as the component).
41  *
42  * Note that when an instance of SimpleDataObjectDecorator is created,
43  * the component is initialized with its default constructor (i.e. a
44  * null pointer).
45  *
46  * \sa SimpleDataObjectDecorator
47  * \sa DataObjectDecorator
48  * \ingroup ITKSystemObjects
49  *
50  */
51 template<class T>
52 class ITK_EXPORT AutoPointerDataObjectDecorator : public DataObject
53 {
54 public:
55   /** Standard typedefs. */
56   typedef AutoPointerDataObjectDecorator           Self;
57 TDA   typedef DataObject  Superclass;
58 TDA   typedef SmartPointer<Self>  Pointer;
59 TDA   typedef SmartPointer<const Self>  ConstPointer;
60
61   /** Typedef for the component type (object being decorated) */
62   typedef T ComponentType;
63 TDA   typedef std::auto_ptr<T> ComponentPointer;
64   
65   /** Method for creation through the object factory. */
66   itkNewMacro(Self);
67
68   /** Run-time type information (and related methods). */
69   itkTypeMacro(AutoPointerDataObjectDecorator, DataObject);
70
71   /** Set the contained object */
72   virtual void Set(T* val);
73   
74   /** Get the contained object */
75   virtual T* Get() { return m_Component.get(); }
76   virtual const T* Get() const { return m_Component.get(); }
77   
78 protected:
79   AutoPointerDataObjectDecorator();
80   ~AutoPointerDataObjectDecorator();
81   virtual void PrintSelf(std::ostream& os, Indent indent) const;
82
83 protected:
84
85 private:
86   AutoPointerDataObjectDecorator(const Self&); //purposely not implemented
87   void operator=(const Self&); //purposely not implemented
88
89   ComponentPointer m_Component;
90 };
91
92 // end namespace itk
93
94 #ifndef ITK_MANUAL_INSTANTIATION
95 #include "itkAutoPointerDataObjectDecorator.txx"
96 #endif
97
98 #endif
99
100 EOF

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