codimtable.hh
00001 #ifndef DUNE_GENERICGEOMETRY_CODIMTABLE_HH
00002 #define DUNE_GENERICGEOMETRY_CODIMTABLE_HH
00003
00004 #include <dune/common/misc.hh>
00005
00006 namespace Dune
00007 {
00008
00009 namespace GenericGeometry
00010 {
00011
00012 template< template< int > class Element, int codim >
00013 class CodimTableStorage
00014 {
00015 CodimTableStorage< Element, codim - 1 > map_;
00016 Element< codim > element_;
00017
00018 public:
00019 CodimTableStorage ()
00020 : map_(),
00021 element_()
00022 {}
00023
00024 CodimTableStorage ( const CodimTableStorage &other )
00025 : map_( other.map_ ),
00026 element_( other.element_ )
00027 {}
00028
00029 const CodimTableStorage &operator= ( const CodimTableStorage &other )
00030 {
00031 map_ = other.map_;
00032 element_ = other.element_;
00033 return *this;
00034 }
00035
00036 template< int cd >
00037 const Element< cd > &operator[] ( const Int2Type< cd > codimVariable ) const
00038 {
00039 return map_[ codimVariable ];
00040 }
00041
00042 template< int cd >
00043 Element< cd > &operator[] ( const Int2Type< cd > codimVariable )
00044 {
00045 return map_[ codimVariable ];
00046 }
00047
00048 const Element< codim > &operator[] ( const Int2Type< codim > codimVariable ) const
00049 {
00050 return element_;
00051 }
00052
00053 Element< codim > &operator[] ( const Int2Type< codim > codimVariable )
00054 {
00055 return element_;
00056 }
00057 };
00058
00059
00060
00061 template< template< int > class Element >
00062 class CodimTableStorage< Element, 0 >
00063 {
00064 Element< 0 > element_;
00065
00066 public:
00067 CodimTableStorage ()
00068 : element_()
00069 {}
00070
00071 CodimTableStorage ( const CodimTableStorage &other )
00072 : element_( other.element_ )
00073 {}
00074
00075 CodimTableStorage &operator= ( const CodimTableStorage &other )
00076 {
00077 element_ = other.element_;
00078 return *this;
00079 }
00080
00081 const Element< 0 > &operator[] ( const Int2Type< 0 > codimVaraible ) const
00082 {
00083 return element_;
00084 }
00085
00086 Element< 0 > &operator[] ( const Int2Type< 0 > codimVaraible )
00087 {
00088 return element_;
00089 }
00090 };
00091
00092
00093
00094 template< template< int > class Element, int dim >
00095 class CodimTable
00096 {
00097 CodimTableStorage< Element, dim > map_;
00098
00099 public:
00100 CodimTable ()
00101 {}
00102
00103 CodimTable ( const CodimTable &other )
00104 : map_( other.map_ )
00105 {}
00106
00107 const CodimTable &operator= ( const CodimTable &other )
00108 {
00109 map_ = other.map_;
00110 return *this;
00111 }
00112
00113 template< int codim >
00114 const Element< codim > &operator[] ( const Int2Type< codim > codimVariable ) const
00115 {
00116 return map_[ codimVariable ];
00117 }
00118
00119 template< int codim >
00120 Element< codim > &operator[] ( const Int2Type< codim > codimVariable )
00121 {
00122 return map_[ codimVariable ];
00123 }
00124 };
00125
00126 }
00127
00128 }
00129
00130 #endif