CudaImageSet.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef CUDAIMAGESET_H_DEFINED
00039 #define CUDAIMAGESET_H_DEFINED
00040
00041 #include "CUDA/CudaImage.H"
00042 #include "Image/ImageSet.H"
00043 #include "Image/Pixels.H"
00044 #include "Util/Assert.H"
00045
00046 #include <deque>
00047
00048
00049
00050 template <class T>
00051 class CudaImageSet
00052 {
00053 public:
00054
00055 inline CudaImageSet(const uint n=0);
00056
00057
00058 inline CudaImageSet(const uint n, const Dims& dims, const MemoryPolicy mp, const int dev);
00059
00060
00061 inline CudaImageSet(const uint n, const Dims& dims, const InitPolicy init, const MemoryPolicy mp, const int dev);
00062
00063 inline CudaImageSet(const ImageSet<T>& cp, const MemoryPolicy mp, const int dev);
00064
00065
00066
00067
00068 inline CudaImageSet(const CudaImageSet<T>& cp);
00069
00070
00071 inline CudaImageSet(const CudaImageSet<T>& cp, const MemoryPolicy mp, const int dev);
00072
00073
00074 inline void swap(CudaImageSet<T>& that);
00075
00076
00077
00078 inline void clear();
00079
00080
00081 inline void reset(uint newDepth = 0);
00082
00083
00084 inline uint size() const;
00085
00086
00087 inline const CudaImage<T>& getImage(const uint lev) const;
00088
00089
00090 inline const CudaImage<T>& operator[](const uint lev) const;
00091
00092
00093 inline CudaImage<T>& getImageMut(const uint lev);
00094
00095
00096 inline CudaImage<T>& operator[](const uint lev);
00097
00098
00099 inline void push_back(CudaImage<T>& img);
00100
00101
00102 inline void push_front(CudaImage<T>& img);
00103
00104
00105 inline CudaImage<T> pop_back();
00106
00107
00108 inline CudaImage<T> pop_front();
00109
00110
00111 inline CudaImage<T> front() const;
00112
00113
00114 inline CudaImage<T> back() const;
00115
00116
00117 inline bool isEmpty() const;
00118
00119
00120 inline bool isNonEmpty() const;
00121
00122
00123 inline CudaImageSet<T> subSet(const uint a, const uint b) const;
00124
00125 private:
00126 std::deque< CudaImage<T> > itsLevels;
00127 };
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 template <class T> inline
00139 CudaImageSet<T>::CudaImageSet(const uint n)
00140 : itsLevels(n, CudaImage<T>())
00141 {}
00142
00143
00144 template <class T> inline
00145 CudaImageSet<T>::CudaImageSet(const uint n, const Dims& dims, const MemoryPolicy mp, const int dev)
00146 : itsLevels(n, CudaImage<T>(dims,mp,dev))
00147 {}
00148
00149
00150 template <class T> inline
00151 CudaImageSet<T>::CudaImageSet(const ImageSet<T>& cp, const MemoryPolicy mp, const int dev)
00152 : itsLevels(cp.size())
00153 {
00154 for (uint i = 0; i < cp.size(); ++i)
00155 this->itsLevels[i] = CudaImage<T>(cp[i],mp,dev);
00156 }
00157
00158
00159
00160 template <class T> inline
00161 CudaImageSet<T>::CudaImageSet(const uint n, const Dims& dims, const InitPolicy init, const MemoryPolicy mp, const int dev)
00162 : itsLevels(n, CudaImage<T>(dims,init,mp,dev))
00163 {}
00164
00165
00166 template <class T> inline
00167 CudaImageSet<T>::CudaImageSet(const CudaImageSet<T>& cp)
00168 : itsLevels(cp.size())
00169 {
00170 for (uint i = 0; i < cp.size(); ++i)
00171 this->itsLevels[i] = CudaImage<T>(cp.itsLevels[i]);
00172 }
00173
00174
00175 template <class T> inline
00176 CudaImageSet<T>::CudaImageSet(const CudaImageSet<T>& cp, const MemoryPolicy mp, const int dev)
00177 : itsLevels(cp.size())
00178 {
00179 for (uint i = 0; i < cp.size(); ++i)
00180 this->itsLevels[i] = CudaImage<T>(cp.itsLevels[i],mp,dev);
00181 }
00182
00183
00184 template <class T> inline
00185 void CudaImageSet<T>::swap(CudaImageSet<T>& that)
00186 {
00187 this->itsLevels.swap(that.itsLevels);
00188 }
00189
00190
00191 template <class T> inline
00192 void CudaImageSet<T>::clear()
00193 {
00194
00195 std::deque< CudaImage<T> >(itsLevels.size()).swap(itsLevels);
00196 }
00197
00198
00199 template <class T> inline
00200 void CudaImageSet<T>::reset(uint newDepth)
00201 {
00202
00203 std::deque< CudaImage<T> >(newDepth).swap(itsLevels);
00204 }
00205
00206
00207 template <class T> inline
00208 uint CudaImageSet<T>::size() const { return itsLevels.size(); }
00209
00210
00211 template <class T> inline
00212 const CudaImage<T>& CudaImageSet<T>::getImage(const uint lev) const
00213 {
00214 ASSERT(lev < itsLevels.size());
00215 return itsLevels[lev];
00216 }
00217
00218
00219 template <class T> inline
00220 const CudaImage<T>& CudaImageSet<T>::operator[](const uint lev) const
00221 { return getImage(lev); }
00222
00223
00224 template <class T> inline
00225 CudaImage<T>& CudaImageSet<T>::getImageMut(const uint lev)
00226 {
00227 ASSERT(lev < itsLevels.size());
00228 return itsLevels[lev];
00229 }
00230
00231
00232 template <class T> inline
00233 CudaImage<T>& CudaImageSet<T>::operator[](const uint lev)
00234 { return getImageMut(lev); }
00235
00236
00237 template <class T> inline
00238 void CudaImageSet<T>::push_back(CudaImage<T>& img)
00239 {
00240 itsLevels.push_back(img);
00241 }
00242
00243
00244 template <class T> inline
00245 void CudaImageSet<T>::push_front(CudaImage<T>& img)
00246 {
00247 itsLevels.push_front(img);
00248 }
00249
00250
00251 template <class T> inline
00252 CudaImage<T> CudaImageSet<T>::pop_back()
00253 {
00254 ASSERT(isNonEmpty());
00255 CudaImage<T> tmp = itsLevels.back();
00256 itsLevels.pop_back();
00257 return tmp;
00258 }
00259
00260
00261 template <class T> inline
00262 CudaImage<T> CudaImageSet<T>::pop_front()
00263 {
00264 ASSERT(isNonEmpty());
00265 CudaImage<T> tmp = itsLevels.front();
00266 itsLevels.pop_front();
00267 return tmp;
00268 }
00269
00270
00271 template <class T> inline
00272 CudaImage<T> CudaImageSet<T>::front() const
00273 {
00274 ASSERT(isNonEmpty());
00275 return itsLevels.front();
00276 }
00277
00278
00279 template <class T> inline
00280 CudaImage<T> CudaImageSet<T>::back() const
00281 {
00282 ASSERT(isNonEmpty());
00283 return itsLevels.back();
00284 }
00285
00286
00287 template <class T> inline
00288 bool CudaImageSet<T>::isEmpty() const { return !isNonEmpty(); }
00289
00290
00291 template <class T> inline
00292 bool CudaImageSet<T>::isNonEmpty() const
00293 {
00294 for (uint i = 0; i < itsLevels.size(); ++i)
00295 if (itsLevels[i].initialized()) return true;
00296
00297 return false;
00298 }
00299
00300
00301 template <class T> inline
00302 CudaImageSet<T> CudaImageSet<T>::subSet(const uint a, const uint b) const
00303 {
00304 ASSERT(b >= a);
00305 ASSERT(b <= this->size());
00306
00307 CudaImageSet<T> result(b-a);
00308 for (uint i = a; i < b; ++i)
00309 result.itsLevels[i-a] = this->itsLevels[i];
00310
00311 return result;
00312 }
00313
00314
00315
00316 template class CudaImageSet<float>;
00317
00318 #endif // !CUDAIMAGESET_H_DEFINED
00319
00320
00321
00322
00323
00324