00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ESTAR_UTIL_HPP
00022 #define ESTAR_UTIL_HPP
00023
00024
00025 #include <boost/scoped_array.hpp>
00026
00027
00028 namespace estar {
00029
00030
00041 void set_cleanup(void (*function)());
00042
00043
00051 template<typename value_t, typename index_t = size_t>
00052 class array
00053 {
00054 public:
00055 typedef boost::scoped_array<value_t> inner_t;
00056 typedef boost::scoped_array<inner_t> outer_t;
00057
00058 array(index_t xsize, index_t ysize)
00059 : data(new inner_t[xsize])
00060 {
00061 for (index_t ix(0); ix < xsize; ++ix)
00062 data[ix].reset(new value_t[ysize]);
00063 }
00064
00065 array(index_t xsize, index_t ysize, const value_t & init)
00066 : data(new inner_t[xsize])
00067 {
00068 for (index_t ix(0); ix < xsize; ++ix) {
00069 data[ix].reset(new value_t[ysize]);
00070 for(index_t iy(0); iy < ysize; ++iy)
00071 data[ix][iy] = init;
00072 }
00073 }
00074
00075 inner_t & operator [] (index_t ix) { return data[ix]; }
00076 const inner_t & operator [] (index_t ix) const { return data[ix]; }
00077
00078 outer_t data;
00079 };
00080
00081 }
00082
00083 #endif // ESTAR_UTIL_HPP