]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/UniqueValuesContainer.h
I/O classes added
[FrontAlgorithms.git] / lib / fpa / Base / UniqueValuesContainer.h
1 #ifndef __FPA__BASE__UNIQUEVALUESCONTAINER__H__
2 #define __FPA__BASE__UNIQUEVALUESCONTAINER__H__
3
4 #include <set>
5 #include <itkSimpleDataObjectDecorator.h>
6 #include <itkSmartPointer.h>
7
8 namespace fpa
9 {
10   namespace Base
11   {
12     /**
13      */
14     template< class V, class VC >
15     class UniqueValuesContainer
16       : public itk::SimpleDataObjectDecorator< std::set< V, VC > >
17     {
18     public:
19       typedef std::set< V, VC >                            TDecorated;
20       typedef UniqueValuesContainer                        Self;
21       typedef itk::SimpleDataObjectDecorator< TDecorated > Superclass;
22       typedef itk::SmartPointer< Self >                    Pointer;
23       typedef itk::SmartPointer< const Self >              ConstPointer;
24
25       typedef V  TValue;
26       typedef VC TValueCompare;
27
28       typedef typename TDecorated::iterator       Iterator;
29       typedef typename TDecorated::const_iterator ConstIterator;
30
31     public:
32       itkNewMacro( Self );
33       itkTypeMacro( UniqueValuesContainer, itkSimpleDataObjectDecorator );
34
35     public:
36       void Insert( const V& v )
37         { this->Get( ).insert( v ); this->Modified( ); }
38       void Erase( const V& v )
39         { this->Get( ).erase( v ); this->Modified( ); }
40       void Clear( )
41         { this->Get( ).clear( ); this->Modified( ); }
42       bool Find( const V& v ) const
43         { return( this->Get( ).find( v ) != this->Get( ).end( ) ); }
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
53     protected:
54       UniqueValuesContainer( )
55         : Superclass( )
56         { }
57       virtual ~UniqueValuesContainer( )
58         { }
59
60     private:
61       // Purposely not implemented
62       UniqueValuesContainer( const Self& other );
63       Self& operator=( const Self& other );
64     };
65
66   } // ecapseman
67
68 } // ecapseman
69
70 #endif // __FPA__BASE__UNIQUEVALUESCONTAINER__H__
71
72 // eof - $RCSfile$