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 #ifndef INCLUDED_IMF_FRAME_BUFFER_H
00038 #define INCLUDED_IMF_FRAME_BUFFER_H
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include <ImfName.h>
00048 #include <ImfPixelType.h>
00049 #include <map>
00050 #include <string>
00051
00052
00053 namespace Imf {
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 struct Slice
00066 {
00067
00068
00069
00070
00071 PixelType type;
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 char * base;
00094 size_t xStride;
00095 size_t yStride;
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 int xSampling;
00107 int ySampling;
00108
00109
00110
00111
00112
00113
00114
00115 double fillValue;
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 bool xTileCoords;
00131 bool yTileCoords;
00132
00133
00134
00135
00136
00137
00138 Slice (PixelType type = HALF,
00139 char * base = 0,
00140 size_t xStride = 0,
00141 size_t yStride = 0,
00142 int xSampling = 1,
00143 int ySampling = 1,
00144 double fillValue = 0.0,
00145 bool xTileCoords = false,
00146 bool yTileCoords = false);
00147 };
00148
00149
00150 class FrameBuffer
00151 {
00152 public:
00153
00154
00155
00156
00157
00158 void insert (const char name[],
00159 const Slice &slice);
00160
00161 void insert (const std::string &name,
00162 const Slice &slice);
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 Slice & operator [] (const char name[]);
00177 const Slice & operator [] (const char name[]) const;
00178
00179 Slice & operator [] (const std::string &name);
00180 const Slice & operator [] (const std::string &name) const;
00181
00182 Slice * findSlice (const char name[]);
00183 const Slice * findSlice (const char name[]) const;
00184
00185 Slice * findSlice (const std::string &name);
00186 const Slice * findSlice (const std::string &name) const;
00187
00188
00189
00190
00191
00192
00193 typedef std::map <Name, Slice> SliceMap;
00194
00195 class Iterator;
00196 class ConstIterator;
00197
00198 Iterator begin ();
00199 ConstIterator begin () const;
00200
00201 Iterator end ();
00202 ConstIterator end () const;
00203
00204 Iterator find (const char name[]);
00205 ConstIterator find (const char name[]) const;
00206
00207 Iterator find (const std::string &name);
00208 ConstIterator find (const std::string &name) const;
00209
00210 private:
00211
00212 SliceMap _map;
00213 };
00214
00215
00216
00217
00218
00219
00220 class FrameBuffer::Iterator
00221 {
00222 public:
00223
00224 Iterator ();
00225 Iterator (const FrameBuffer::SliceMap::iterator &i);
00226
00227 Iterator & operator ++ ();
00228 Iterator operator ++ (int);
00229
00230 const char * name () const;
00231 Slice & slice () const;
00232
00233 private:
00234
00235 friend class FrameBuffer::ConstIterator;
00236
00237 FrameBuffer::SliceMap::iterator _i;
00238 };
00239
00240
00241 class FrameBuffer::ConstIterator
00242 {
00243 public:
00244
00245 ConstIterator ();
00246 ConstIterator (const FrameBuffer::SliceMap::const_iterator &i);
00247 ConstIterator (const FrameBuffer::Iterator &other);
00248
00249 ConstIterator & operator ++ ();
00250 ConstIterator operator ++ (int);
00251
00252 const char * name () const;
00253 const Slice & slice () const;
00254
00255 private:
00256
00257 friend bool operator == (const ConstIterator &, const ConstIterator &);
00258 friend bool operator != (const ConstIterator &, const ConstIterator &);
00259
00260 FrameBuffer::SliceMap::const_iterator _i;
00261 };
00262
00263
00264
00265
00266
00267
00268 inline
00269 FrameBuffer::Iterator::Iterator (): _i()
00270 {
00271
00272 }
00273
00274
00275 inline
00276 FrameBuffer::Iterator::Iterator (const FrameBuffer::SliceMap::iterator &i):
00277 _i (i)
00278 {
00279
00280 }
00281
00282
00283 inline FrameBuffer::Iterator &
00284 FrameBuffer::Iterator::operator ++ ()
00285 {
00286 ++_i;
00287 return *this;
00288 }
00289
00290
00291 inline FrameBuffer::Iterator
00292 FrameBuffer::Iterator::operator ++ (int)
00293 {
00294 Iterator tmp = *this;
00295 ++_i;
00296 return tmp;
00297 }
00298
00299
00300 inline const char *
00301 FrameBuffer::Iterator::name () const
00302 {
00303 return *_i->first;
00304 }
00305
00306
00307 inline Slice &
00308 FrameBuffer::Iterator::slice () const
00309 {
00310 return _i->second;
00311 }
00312
00313
00314 inline
00315 FrameBuffer::ConstIterator::ConstIterator (): _i()
00316 {
00317
00318 }
00319
00320 inline
00321 FrameBuffer::ConstIterator::ConstIterator
00322 (const FrameBuffer::SliceMap::const_iterator &i): _i (i)
00323 {
00324
00325 }
00326
00327
00328 inline
00329 FrameBuffer::ConstIterator::ConstIterator (const FrameBuffer::Iterator &other):
00330 _i (other._i)
00331 {
00332
00333 }
00334
00335 inline FrameBuffer::ConstIterator &
00336 FrameBuffer::ConstIterator::operator ++ ()
00337 {
00338 ++_i;
00339 return *this;
00340 }
00341
00342
00343 inline FrameBuffer::ConstIterator
00344 FrameBuffer::ConstIterator::operator ++ (int)
00345 {
00346 ConstIterator tmp = *this;
00347 ++_i;
00348 return tmp;
00349 }
00350
00351
00352 inline const char *
00353 FrameBuffer::ConstIterator::name () const
00354 {
00355 return *_i->first;
00356 }
00357
00358 inline const Slice &
00359 FrameBuffer::ConstIterator::slice () const
00360 {
00361 return _i->second;
00362 }
00363
00364
00365 inline bool
00366 operator == (const FrameBuffer::ConstIterator &x,
00367 const FrameBuffer::ConstIterator &y)
00368 {
00369 return x._i == y._i;
00370 }
00371
00372
00373 inline bool
00374 operator != (const FrameBuffer::ConstIterator &x,
00375 const FrameBuffer::ConstIterator &y)
00376 {
00377 return !(x == y);
00378 }
00379
00380
00381 }
00382
00383 #endif