KWStyle - itkSTLContainerAdaptor.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkSTLContainerAdaptor.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:48 $
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      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 #ifndef __itkSTLContainerAdaptor_h
18 #define __itkSTLContainerAdaptor_h
19
20
21 namespace itk {
22
23
24 /** \class STLContainerAdaptor
25 IND * An adapter object that casts a itk::XxxContainer into std::xxx
26 LEN,IND * and enables access to the underlying data structure. When the STLContainerAdaptor
27 IND * is destroyed, it automatically calls XxxContainer::Modified().
28 IND * Here's a usage example of STLContainerAdaptor
29 LEN,IND *     itk::STLContainerAdaptor<itk::VectorContainer<unsigned long, ElementType>> vecAdaptor(aContainer);
30 IND *     std::vector<ElementType> & vec = vecAdaptor.GetSTLContainerRef();
31 IND *     // do things with vec ...
32 LEN,IND *     // upon return from function, vecAdaptor is destroyed and aContainer is Modified()
33 IND */
34
35 template<typename TContainer>
36 class STLContainerAdaptor
37 {
38 public:
39
40   typedef TContainer                      AdapteeType;
41
42   typedef typename AdapteeType::Element            ElementType;
43   typedef typename AdapteeType::STLContainerType   TargetType;
44   
45 private:
46
47   AdapteeType & m_AdapteeRef;
48   
49 LEN   /** hide the copy constructor to allow only direct construction of the adapter */
50   STLContainerAdaptor(const STLContainerAdaptor & r);
51   
52   /* hide and avoid operator= */
53   const STLContainerAdaptor & operator=(const STLContainerAdaptor & r);
54   
55   
56 public:
57   STLContainerAdaptor(AdapteeType & adaptee)
58 IND ****: m_AdapteeRef(adaptee)
59 IND **{}
60   
61   STLContainerAdaptor(AdapteeType * adaptee)
62 IND ****: m_AdapteeRef(*adaptee)
63 IND **{}
64   
65   ~STLContainerAdaptor()
66 IND **{
67     m_AdapteeRef.Modified();
68 IND **}
69   
70   TargetType & GetSTLContainerRef()
71 IND **{
72     return m_AdapteeRef.CastToSTLContainer(); 
73 IND **}
74   
75 };
76
77
78 // end namespace itk
79
80 #endif
81

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