]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/MatrixValuesContainer.h
...
[FrontAlgorithms.git] / lib / fpa / Base / MatrixValuesContainer.h
1 #ifndef __FPA__BASE__MATRIXVALUESCONTAINER__H__
2 #define __FPA__BASE__MATRIXVALUESCONTAINER__H__
3
4 #include <map>
5 #include <itkSimpleDataObjectDecorator.h>
6 #include <itkSmartPointer.h>
7
8 namespace fpa
9 {
10   namespace Base
11   {
12     /**
13      */
14     template< class I, class V, class VI >
15     class MatrixValuesContainer
16       : public itk::SimpleDataObjectDecorator< std::map< I, std::map< I, V, VI >, VI > >
17     {
18     public:
19       typedef std::map< I, V, VI >                         TDecoratedRow;
20       typedef std::map< I, TDecoratedRow, VI >             TDecorated;
21       typedef MatrixValuesContainer                        Self;
22       typedef itk::SimpleDataObjectDecorator< TDecorated > Superclass;
23       typedef itk::SmartPointer< Self >                    Pointer;
24       typedef itk::SmartPointer< const Self >              ConstPointer;
25
26       typedef I  TIndex;
27       typedef V  TValue;
28       typedef VI TIndexCompare;
29
30       typedef typename TDecoratedRow::iterator       RowIterator;
31       typedef typename TDecoratedRow::const_iterator ConstRowIterator;
32       typedef typename TDecorated::iterator          Iterator;
33       typedef typename TDecorated::const_iterator    ConstIterator;
34
35     public:
36       itkNewMacro( Self );
37       itkTypeMacro( MatrixValuesContainer, itkSimpleDataObjectDecorator );
38
39     public:
40       void SetValue( const I& a, const I& b, const V& v )
41         { this->Get( )[ a ][ b ] = v; this->Modified( ); }
42       void Clear( )
43         { this->Get( ).clear( ); this->Modified( ); }
44       Iterator Begin( )
45         { return( this->Get( ).begin( ) ); }
46       Iterator End( )
47         { return( this->Get( ).end( ) ); }
48       ConstIterator Begin( ) const
49         { return( this->Get( ).begin( ) ); }
50       ConstIterator End( ) const
51         { return( this->Get( ).end( ) ); }
52       RowIterator Begin( const Iterator& i )
53         { return( i->second.begin( ) ); }
54       RowIterator End( const Iterator& i )
55         { return( i->second.end( ) ); }
56       ConstRowIterator Begin( const ConstIterator& i ) const
57         { return( i->second.begin( ) ); }
58       ConstRowIterator End( const ConstIterator& i ) const
59         { return( i->second.end( ) ); }
60
61     protected:
62       MatrixValuesContainer( )
63         : Superclass( )
64         { }
65       virtual ~MatrixValuesContainer( )
66         { }
67
68     private:
69       // Purposely not implemented
70       MatrixValuesContainer( const Self& other );
71       Self& operator=( const Self& other );
72     };
73
74   } // ecapseman
75
76 } // ecapseman
77
78 #endif // __FPA__BASE__MATRIXVALUESCONTAINER__H__
79
80 // eof - $RCSfile$