KWStyle - itkSTLConstContainerAdaptor.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkSTLConstContainerAdaptor.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 __itkSTLConstContainerAdaptor_h
18 #define __itkSTLConstContainerAdaptor_h
19
20
21 namespace itk {
22
23
24 /** \class STLConstContainerAdaptor
25 LEN  * An adapter object that casts a [const itk::XxxContainer] into [const std::xxx]
26  * and enables access to the underlying data structure.
27  * The class is provided for interface consistency with STLContainerAdaptor
28 LEN  * plus the [const] modifier. Since everything is const, there is no need to call
29  * AdapteeType::Modified() in the destructor.
30  * Here's a usage example of STLContainerAdaptor
31 LEN  *     itk::STLConstContainerAdaptor<itk::VectorContainer<unsigned long, ElementType>> vecAdaptor(aContainer);
32  *     const std::vector<ElementType> & vec = vecAdaptor.GetSTLContainerRef();
33  *     // do things with vec ...
34  */
35
36
37 template<typename TContainer>
38 class STLConstContainerAdaptor
39 {
40 public:
41
42   typedef const TContainer                      AdapteeType;
43
44   typedef const typename AdapteeType::Element            ElementType;
45   typedef const typename AdapteeType::STLContainerType   TargetType;
46   
47
48 private:
49
50   AdapteeType & m_AdapteeRef;
51   
52 LEN   /** hide the copy constructor to allow only direct construction of the adapter */
53   STLConstContainerAdaptor(const STLConstContainerAdaptor & r);
54   
55   /* hide and avoid operator= */
56 LEN   const STLConstContainerAdaptor & operator=(const STLConstContainerAdaptor & r);
57   
58   
59 public:
60
61   STLConstContainerAdaptor(AdapteeType & adaptee)
62 IND ****: m_AdapteeRef(adaptee)
63 IND **{}
64   
65   STLConstContainerAdaptor(AdapteeType * adaptee)
66 IND ****: m_AdapteeRef(*adaptee)
67 IND **{}
68   
69   TargetType & GetSTLConstContainerRef()
70 IND **{
71     return m_AdapteeRef.CastToSTLConstContainer(); 
72 IND **}
73   
74 };
75
76
77 }   // end namespace itk
78
79 #endif
80

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