~cosme/ubuntu/precise/freeimage/freeimage-3.15.1

« back to all changes in this revision

Viewing changes to Source/OpenEXR/IlmImf/ImfChannelList.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-07-20 13:42:15 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100720134215-xt1454zaedv3b604
Tags: 3.13.1-0ubuntu1
* New upstream release. Closes: (LP: #607800)
 - Updated debian/freeimage-get-orig-source script.
 - Removing no longer necessary debian/patches/* and
   the patch system in debian/rules.
 - Updated debian/rules to work with the new Makefiles.
 - Drop from -O3 to -O2 and use lzma compression saves
   ~10 MB of free space. 
* lintian stuff
 - fixed debhelper-but-no-misc-depends
 - fixed ldconfig-symlink-missing-for-shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
///////////////////////////////////////////////////////////////////////////
2
 
//
3
 
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
4
 
// Digital Ltd. LLC
5
 
// 
6
 
// All rights reserved.
7
 
// 
8
 
// Redistribution and use in source and binary forms, with or without
9
 
// modification, are permitted provided that the following conditions are
10
 
// met:
11
 
// *       Redistributions of source code must retain the above copyright
12
 
// notice, this list of conditions and the following disclaimer.
13
 
// *       Redistributions in binary form must reproduce the above
14
 
// copyright notice, this list of conditions and the following disclaimer
15
 
// in the documentation and/or other materials provided with the
16
 
// distribution.
17
 
// *       Neither the name of Industrial Light & Magic nor the names of
18
 
// its contributors may be used to endorse or promote products derived
19
 
// from this software without specific prior written permission. 
20
 
// 
21
 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
 
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
 
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
 
//
33
 
///////////////////////////////////////////////////////////////////////////
34
 
 
35
 
 
36
 
 
37
 
#ifndef INCLUDED_IMF_CHANNEL_LIST_H
38
 
#define INCLUDED_IMF_CHANNEL_LIST_H
39
 
 
40
 
//-----------------------------------------------------------------------------
41
 
//
42
 
//      class Channel
43
 
//      class ChannelList
44
 
//
45
 
//-----------------------------------------------------------------------------
46
 
 
47
 
#include <ImfName.h>
48
 
#include <ImfPixelType.h>
49
 
#include <map>
50
 
#include <set>
51
 
#include <string>
52
 
 
53
 
 
54
 
namespace Imf {
55
 
 
56
 
 
57
 
struct Channel
58
 
{
59
 
    //------------------------------
60
 
    // Data type; see ImfPixelType.h
61
 
    //------------------------------
62
 
 
63
 
    PixelType           type;
64
 
 
65
 
 
66
 
    //--------------------------------------------
67
 
    // Subsampling: pixel (x, y) is present in the
68
 
    // channel only if 
69
 
    //
70
 
    //  x % xSampling == 0 && y % ySampling == 0
71
 
    //
72
 
    //--------------------------------------------
73
 
 
74
 
    int                 xSampling;
75
 
    int                 ySampling;
76
 
 
77
 
 
78
 
    //--------------------------------------------------------------
79
 
    // Hint to lossy compression methods that indicates whether
80
 
    // human perception of the quantity represented by this channel
81
 
    // is closer to linear or closer to logarithmic.  Compression
82
 
    // methods may optimize image quality by adjusting pixel data
83
 
    // quantization acording to this hint.
84
 
    // For example, perception of red, green, blue and luminance is
85
 
    // approximately logarithmic; the difference between 0.1 and 0.2
86
 
    // is perceived to be roughly the same as the difference between
87
 
    // 1.0 and 2.0.  Perception of chroma coordinates tends to be
88
 
    // closer to linear than logarithmic; the difference between 0.1
89
 
    // and 0.2 is perceived to be roughly the same as the difference
90
 
    // between 1.0 and 1.1.
91
 
    //--------------------------------------------------------------
92
 
 
93
 
    bool                pLinear;
94
 
 
95
 
 
96
 
    //------------
97
 
    // Constructor
98
 
    //------------
99
 
    
100
 
    Channel (PixelType type = HALF,
101
 
             int xSampling = 1,
102
 
             int ySampling = 1,
103
 
             bool pLinear = false);
104
 
 
105
 
 
106
 
    //------------
107
 
    // Operator ==
108
 
    //------------
109
 
 
110
 
    bool                operator == (const Channel &other) const;
111
 
};
112
 
 
113
 
 
114
 
class ChannelList
115
 
{
116
 
  public:
117
 
 
118
 
    //--------------
119
 
    // Add a channel
120
 
    //--------------
121
 
 
122
 
    void                        insert (const char name[],
123
 
                                        const Channel &channel);
124
 
 
125
 
    //------------------------------------------------------------------
126
 
    // Access to existing channels:
127
 
    //
128
 
    // [n]              Returns a reference to the channel with name n.
129
 
    //                  If no channel with name n exists, an Iex::ArgExc
130
 
    //                  is thrown.
131
 
    //
132
 
    // findChannel(n)   Returns a pointer to the channel with name n,
133
 
    //                  or 0 if no channel with name n exists.
134
 
    //
135
 
    //------------------------------------------------------------------
136
 
 
137
 
    Channel &                   operator [] (const char name[]);
138
 
    const Channel &             operator [] (const char name[]) const;
139
 
 
140
 
    Channel *                   findChannel (const char name[]);
141
 
    const Channel *             findChannel (const char name[]) const;
142
 
 
143
 
 
144
 
    //-------------------------------------------
145
 
    // Iterator-style access to existing channels
146
 
    //-------------------------------------------
147
 
 
148
 
    typedef std::map <Name, Channel> ChannelMap;
149
 
 
150
 
    class Iterator;
151
 
    class ConstIterator;
152
 
 
153
 
    Iterator                    begin ();
154
 
    ConstIterator               begin () const;
155
 
    Iterator                    end ();
156
 
    ConstIterator               end () const;
157
 
    Iterator                    find (const char name[]);
158
 
    ConstIterator               find (const char name[]) const;
159
 
 
160
 
    
161
 
    //-----------------------------------------------------------------
162
 
    // Support for image layers:
163
 
    //
164
 
    // In an image file with many channels it is sometimes useful to
165
 
    // group the channels into "layers", that is, into sets of channels
166
 
    // that logically belong together.  Grouping channels into layers
167
 
    // is done using a naming convention:  channel C in layer L is
168
 
    // called "L.C".
169
 
    //
170
 
    // For example, a computer graphic image may contain separate
171
 
    // R, G and B channels for light that originated at each of
172
 
    // several different virtual light sources.  The channels in
173
 
    // this image might be called "light1.R", "light1.G", "light1.B",
174
 
    // "light2.R", "light2.G", "light2.B", etc.
175
 
    // 
176
 
    // Note that this naming convention allows layers to be nested;
177
 
    // for example, "light1.specular.R" identifies the "R" channel
178
 
    // in the "specular" sub-layer of layer "light1".
179
 
    //
180
 
    // Channel names that don't contain a "." or that contain a
181
 
    // "." only at the beginning or at the end are not considered
182
 
    // to be part of any layer.
183
 
    //
184
 
    // layers(lns)              sorts the channels in this ChannelList
185
 
    //                          into layers and stores the names of
186
 
    //                          all layers, sorted alphabetically,
187
 
    //                          into string set lns.
188
 
    //
189
 
    // channelsInLayer(ln,f,l)  stores a pair of iterators in f and l
190
 
    //                          such that the loop
191
 
    //
192
 
    //                          for (ConstIterator i = f; i != l; ++i)
193
 
    //                             ...
194
 
    //
195
 
    //                          iterates over all channels in layer ln.
196
 
    //                          channelsInLayer (ln, l, p) calls
197
 
    //                          channelsWithPrefix (ln + ".", l, p).
198
 
    //
199
 
    //-----------------------------------------------------------------
200
 
 
201
 
    void                layers (std::set <std::string> &layerNames) const;
202
 
 
203
 
    void                channelsInLayer (const std::string &layerName,
204
 
                                         Iterator &first,
205
 
                                         Iterator &last);
206
 
 
207
 
    void                channelsInLayer (const std::string &layerName,
208
 
                                         ConstIterator &first,
209
 
                                         ConstIterator &last) const;
210
 
 
211
 
 
212
 
    //-------------------------------------------------------------------
213
 
    // Find all channels whose name begins with a given prefix:
214
 
    //
215
 
    // channelsWithPrefix(p,f,l) stores a pair of iterators in f and l
216
 
    // such that the following loop iterates over all channels whose name
217
 
    // begins with string p:
218
 
    //
219
 
    //          for (ConstIterator i = f; i != l; ++i)
220
 
    //              ...
221
 
    //
222
 
    //-------------------------------------------------------------------
223
 
 
224
 
    void                        channelsWithPrefix (const char prefix[],
225
 
                                                    Iterator &first,
226
 
                                                    Iterator &last);
227
 
 
228
 
    void                        channelsWithPrefix (const char prefix[],
229
 
                                                    ConstIterator &first,
230
 
                                                    ConstIterator &last) const;
231
 
 
232
 
    //------------
233
 
    // Operator ==
234
 
    //------------
235
 
 
236
 
    bool                        operator == (const ChannelList &other) const;
237
 
 
238
 
  private:
239
 
 
240
 
    ChannelMap                  _map;
241
 
};
242
 
 
243
 
 
244
 
//----------
245
 
// Iterators
246
 
//----------
247
 
 
248
 
class ChannelList::Iterator
249
 
{
250
 
  public:
251
 
 
252
 
    Iterator ();
253
 
    Iterator (const ChannelList::ChannelMap::iterator &i);
254
 
 
255
 
    Iterator &                  operator ++ ();
256
 
    Iterator                    operator ++ (int);
257
 
 
258
 
    const char *                name () const;
259
 
    Channel &                   channel () const;
260
 
 
261
 
  private:
262
 
 
263
 
    friend class ChannelList::ConstIterator;
264
 
 
265
 
    ChannelList::ChannelMap::iterator _i;
266
 
};
267
 
 
268
 
 
269
 
class ChannelList::ConstIterator
270
 
{
271
 
  public:
272
 
 
273
 
    ConstIterator ();
274
 
    ConstIterator (const ChannelList::ChannelMap::const_iterator &i);
275
 
    ConstIterator (const ChannelList::Iterator &other);
276
 
 
277
 
    ConstIterator &             operator ++ ();
278
 
    ConstIterator               operator ++ (int);
279
 
 
280
 
    const char *                name () const;
281
 
    const Channel &             channel () const;
282
 
 
283
 
  private:
284
 
 
285
 
    friend bool operator == (const ConstIterator &, const ConstIterator &);
286
 
    friend bool operator != (const ConstIterator &, const ConstIterator &);
287
 
 
288
 
    ChannelList::ChannelMap::const_iterator _i;
289
 
};
290
 
 
291
 
 
292
 
//-----------------
293
 
// Inline Functions
294
 
//-----------------
295
 
 
296
 
inline
297
 
ChannelList::Iterator::Iterator (): _i()
298
 
{
299
 
    // empty
300
 
}
301
 
 
302
 
 
303
 
inline
304
 
ChannelList::Iterator::Iterator (const ChannelList::ChannelMap::iterator &i):
305
 
    _i (i)
306
 
{
307
 
    // empty
308
 
}
309
 
 
310
 
 
311
 
inline ChannelList::Iterator &          
312
 
ChannelList::Iterator::operator ++ ()
313
 
{
314
 
    ++_i;
315
 
    return *this;
316
 
}
317
 
 
318
 
 
319
 
inline ChannelList::Iterator    
320
 
ChannelList::Iterator::operator ++ (int)
321
 
{
322
 
    Iterator tmp = *this;
323
 
    ++_i;
324
 
    return tmp;
325
 
}
326
 
 
327
 
 
328
 
inline const char *
329
 
ChannelList::Iterator::name () const
330
 
{
331
 
    return *_i->first;
332
 
}
333
 
 
334
 
 
335
 
inline Channel &        
336
 
ChannelList::Iterator::channel () const
337
 
{
338
 
    return _i->second;
339
 
}
340
 
 
341
 
 
342
 
inline
343
 
ChannelList::ConstIterator::ConstIterator (): _i()
344
 
{
345
 
    // empty
346
 
}
347
 
 
348
 
inline
349
 
ChannelList::ConstIterator::ConstIterator
350
 
    (const ChannelList::ChannelMap::const_iterator &i): _i (i)
351
 
{
352
 
    // empty
353
 
}
354
 
 
355
 
 
356
 
inline
357
 
ChannelList::ConstIterator::ConstIterator (const ChannelList::Iterator &other):
358
 
    _i (other._i)
359
 
{
360
 
    // empty
361
 
}
362
 
 
363
 
inline ChannelList::ConstIterator &
364
 
ChannelList::ConstIterator::operator ++ ()
365
 
{
366
 
    ++_i;
367
 
    return *this;
368
 
}
369
 
 
370
 
 
371
 
inline ChannelList::ConstIterator               
372
 
ChannelList::ConstIterator::operator ++ (int)
373
 
{
374
 
    ConstIterator tmp = *this;
375
 
    ++_i;
376
 
    return tmp;
377
 
}
378
 
 
379
 
 
380
 
inline const char *
381
 
ChannelList::ConstIterator::name () const
382
 
{
383
 
    return *_i->first;
384
 
}
385
 
 
386
 
inline const Channel &  
387
 
ChannelList::ConstIterator::channel () const
388
 
{
389
 
    return _i->second;
390
 
}
391
 
 
392
 
 
393
 
inline bool
394
 
operator == (const ChannelList::ConstIterator &x,
395
 
             const ChannelList::ConstIterator &y)
396
 
{
397
 
    return x._i == y._i;
398
 
}
399
 
 
400
 
 
401
 
inline bool
402
 
operator != (const ChannelList::ConstIterator &x,
403
 
             const ChannelList::ConstIterator &y)
404
 
{
405
 
    return !(x == y);
406
 
}
407
 
 
408
 
 
409
 
} // namespace Imf
410
 
 
411
 
#endif
 
1
///////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
 
4
// Digital Ltd. LLC
 
5
// 
 
6
// All rights reserved.
 
7
// 
 
8
// Redistribution and use in source and binary forms, with or without
 
9
// modification, are permitted provided that the following conditions are
 
10
// met:
 
11
// *       Redistributions of source code must retain the above copyright
 
12
// notice, this list of conditions and the following disclaimer.
 
13
// *       Redistributions in binary form must reproduce the above
 
14
// copyright notice, this list of conditions and the following disclaimer
 
15
// in the documentation and/or other materials provided with the
 
16
// distribution.
 
17
// *       Neither the name of Industrial Light & Magic nor the names of
 
18
// its contributors may be used to endorse or promote products derived
 
19
// from this software without specific prior written permission. 
 
20
// 
 
21
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
22
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
23
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
24
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
25
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
26
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
27
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
28
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
29
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
30
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
31
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
32
//
 
33
///////////////////////////////////////////////////////////////////////////
 
34
 
 
35
 
 
36
 
 
37
#ifndef INCLUDED_IMF_CHANNEL_LIST_H
 
38
#define INCLUDED_IMF_CHANNEL_LIST_H
 
39
 
 
40
//-----------------------------------------------------------------------------
 
41
//
 
42
//      class Channel
 
43
//      class ChannelList
 
44
//
 
45
//-----------------------------------------------------------------------------
 
46
 
 
47
#include <ImfName.h>
 
48
#include <ImfPixelType.h>
 
49
#include <map>
 
50
#include <set>
 
51
#include <string>
 
52
 
 
53
 
 
54
namespace Imf {
 
55
 
 
56
 
 
57
struct Channel
 
58
{
 
59
    //------------------------------
 
60
    // Data type; see ImfPixelType.h
 
61
    //------------------------------
 
62
 
 
63
    PixelType           type;
 
64
 
 
65
 
 
66
    //--------------------------------------------
 
67
    // Subsampling: pixel (x, y) is present in the
 
68
    // channel only if 
 
69
    //
 
70
    //  x % xSampling == 0 && y % ySampling == 0
 
71
    //
 
72
    //--------------------------------------------
 
73
 
 
74
    int                 xSampling;
 
75
    int                 ySampling;
 
76
 
 
77
 
 
78
    //--------------------------------------------------------------
 
79
    // Hint to lossy compression methods that indicates whether
 
80
    // human perception of the quantity represented by this channel
 
81
    // is closer to linear or closer to logarithmic.  Compression
 
82
    // methods may optimize image quality by adjusting pixel data
 
83
    // quantization acording to this hint.
 
84
    // For example, perception of red, green, blue and luminance is
 
85
    // approximately logarithmic; the difference between 0.1 and 0.2
 
86
    // is perceived to be roughly the same as the difference between
 
87
    // 1.0 and 2.0.  Perception of chroma coordinates tends to be
 
88
    // closer to linear than logarithmic; the difference between 0.1
 
89
    // and 0.2 is perceived to be roughly the same as the difference
 
90
    // between 1.0 and 1.1.
 
91
    //--------------------------------------------------------------
 
92
 
 
93
    bool                pLinear;
 
94
 
 
95
 
 
96
    //------------
 
97
    // Constructor
 
98
    //------------
 
99
    
 
100
    Channel (PixelType type = HALF,
 
101
             int xSampling = 1,
 
102
             int ySampling = 1,
 
103
             bool pLinear = false);
 
104
 
 
105
 
 
106
    //------------
 
107
    // Operator ==
 
108
    //------------
 
109
 
 
110
    bool                operator == (const Channel &other) const;
 
111
};
 
112
 
 
113
 
 
114
class ChannelList
 
115
{
 
116
  public:
 
117
 
 
118
    //--------------
 
119
    // Add a channel
 
120
    //--------------
 
121
 
 
122
    void                        insert (const char name[],
 
123
                                        const Channel &channel);
 
124
 
 
125
    //------------------------------------------------------------------
 
126
    // Access to existing channels:
 
127
    //
 
128
    // [n]              Returns a reference to the channel with name n.
 
129
    //                  If no channel with name n exists, an Iex::ArgExc
 
130
    //                  is thrown.
 
131
    //
 
132
    // findChannel(n)   Returns a pointer to the channel with name n,
 
133
    //                  or 0 if no channel with name n exists.
 
134
    //
 
135
    //------------------------------------------------------------------
 
136
 
 
137
    Channel &                   operator [] (const char name[]);
 
138
    const Channel &             operator [] (const char name[]) const;
 
139
 
 
140
    Channel *                   findChannel (const char name[]);
 
141
    const Channel *             findChannel (const char name[]) const;
 
142
 
 
143
 
 
144
    //-------------------------------------------
 
145
    // Iterator-style access to existing channels
 
146
    //-------------------------------------------
 
147
 
 
148
    typedef std::map <Name, Channel> ChannelMap;
 
149
 
 
150
    class Iterator;
 
151
    class ConstIterator;
 
152
 
 
153
    Iterator                    begin ();
 
154
    ConstIterator               begin () const;
 
155
    Iterator                    end ();
 
156
    ConstIterator               end () const;
 
157
    Iterator                    find (const char name[]);
 
158
    ConstIterator               find (const char name[]) const;
 
159
 
 
160
    
 
161
    //-----------------------------------------------------------------
 
162
    // Support for image layers:
 
163
    //
 
164
    // In an image file with many channels it is sometimes useful to
 
165
    // group the channels into "layers", that is, into sets of channels
 
166
    // that logically belong together.  Grouping channels into layers
 
167
    // is done using a naming convention:  channel C in layer L is
 
168
    // called "L.C".
 
169
    //
 
170
    // For example, a computer graphic image may contain separate
 
171
    // R, G and B channels for light that originated at each of
 
172
    // several different virtual light sources.  The channels in
 
173
    // this image might be called "light1.R", "light1.G", "light1.B",
 
174
    // "light2.R", "light2.G", "light2.B", etc.
 
175
    // 
 
176
    // Note that this naming convention allows layers to be nested;
 
177
    // for example, "light1.specular.R" identifies the "R" channel
 
178
    // in the "specular" sub-layer of layer "light1".
 
179
    //
 
180
    // Channel names that don't contain a "." or that contain a
 
181
    // "." only at the beginning or at the end are not considered
 
182
    // to be part of any layer.
 
183
    //
 
184
    // layers(lns)              sorts the channels in this ChannelList
 
185
    //                          into layers and stores the names of
 
186
    //                          all layers, sorted alphabetically,
 
187
    //                          into string set lns.
 
188
    //
 
189
    // channelsInLayer(ln,f,l)  stores a pair of iterators in f and l
 
190
    //                          such that the loop
 
191
    //
 
192
    //                          for (ConstIterator i = f; i != l; ++i)
 
193
    //                             ...
 
194
    //
 
195
    //                          iterates over all channels in layer ln.
 
196
    //                          channelsInLayer (ln, l, p) calls
 
197
    //                          channelsWithPrefix (ln + ".", l, p).
 
198
    //
 
199
    //-----------------------------------------------------------------
 
200
 
 
201
    void                layers (std::set <std::string> &layerNames) const;
 
202
 
 
203
    void                channelsInLayer (const std::string &layerName,
 
204
                                         Iterator &first,
 
205
                                         Iterator &last);
 
206
 
 
207
    void                channelsInLayer (const std::string &layerName,
 
208
                                         ConstIterator &first,
 
209
                                         ConstIterator &last) const;
 
210
 
 
211
 
 
212
    //-------------------------------------------------------------------
 
213
    // Find all channels whose name begins with a given prefix:
 
214
    //
 
215
    // channelsWithPrefix(p,f,l) stores a pair of iterators in f and l
 
216
    // such that the following loop iterates over all channels whose name
 
217
    // begins with string p:
 
218
    //
 
219
    //          for (ConstIterator i = f; i != l; ++i)
 
220
    //              ...
 
221
    //
 
222
    //-------------------------------------------------------------------
 
223
 
 
224
    void                        channelsWithPrefix (const char prefix[],
 
225
                                                    Iterator &first,
 
226
                                                    Iterator &last);
 
227
 
 
228
    void                        channelsWithPrefix (const char prefix[],
 
229
                                                    ConstIterator &first,
 
230
                                                    ConstIterator &last) const;
 
231
 
 
232
    //------------
 
233
    // Operator ==
 
234
    //------------
 
235
 
 
236
    bool                        operator == (const ChannelList &other) const;
 
237
 
 
238
  private:
 
239
 
 
240
    ChannelMap                  _map;
 
241
};
 
242
 
 
243
 
 
244
//----------
 
245
// Iterators
 
246
//----------
 
247
 
 
248
class ChannelList::Iterator
 
249
{
 
250
  public:
 
251
 
 
252
    Iterator ();
 
253
    Iterator (const ChannelList::ChannelMap::iterator &i);
 
254
 
 
255
    Iterator &                  operator ++ ();
 
256
    Iterator                    operator ++ (int);
 
257
 
 
258
    const char *                name () const;
 
259
    Channel &                   channel () const;
 
260
 
 
261
  private:
 
262
 
 
263
    friend class ChannelList::ConstIterator;
 
264
 
 
265
    ChannelList::ChannelMap::iterator _i;
 
266
};
 
267
 
 
268
 
 
269
class ChannelList::ConstIterator
 
270
{
 
271
  public:
 
272
 
 
273
    ConstIterator ();
 
274
    ConstIterator (const ChannelList::ChannelMap::const_iterator &i);
 
275
    ConstIterator (const ChannelList::Iterator &other);
 
276
 
 
277
    ConstIterator &             operator ++ ();
 
278
    ConstIterator               operator ++ (int);
 
279
 
 
280
    const char *                name () const;
 
281
    const Channel &             channel () const;
 
282
 
 
283
  private:
 
284
 
 
285
    friend bool operator == (const ConstIterator &, const ConstIterator &);
 
286
    friend bool operator != (const ConstIterator &, const ConstIterator &);
 
287
 
 
288
    ChannelList::ChannelMap::const_iterator _i;
 
289
};
 
290
 
 
291
 
 
292
//-----------------
 
293
// Inline Functions
 
294
//-----------------
 
295
 
 
296
inline
 
297
ChannelList::Iterator::Iterator (): _i()
 
298
{
 
299
    // empty
 
300
}
 
301
 
 
302
 
 
303
inline
 
304
ChannelList::Iterator::Iterator (const ChannelList::ChannelMap::iterator &i):
 
305
    _i (i)
 
306
{
 
307
    // empty
 
308
}
 
309
 
 
310
 
 
311
inline ChannelList::Iterator &          
 
312
ChannelList::Iterator::operator ++ ()
 
313
{
 
314
    ++_i;
 
315
    return *this;
 
316
}
 
317
 
 
318
 
 
319
inline ChannelList::Iterator    
 
320
ChannelList::Iterator::operator ++ (int)
 
321
{
 
322
    Iterator tmp = *this;
 
323
    ++_i;
 
324
    return tmp;
 
325
}
 
326
 
 
327
 
 
328
inline const char *
 
329
ChannelList::Iterator::name () const
 
330
{
 
331
    return *_i->first;
 
332
}
 
333
 
 
334
 
 
335
inline Channel &        
 
336
ChannelList::Iterator::channel () const
 
337
{
 
338
    return _i->second;
 
339
}
 
340
 
 
341
 
 
342
inline
 
343
ChannelList::ConstIterator::ConstIterator (): _i()
 
344
{
 
345
    // empty
 
346
}
 
347
 
 
348
inline
 
349
ChannelList::ConstIterator::ConstIterator
 
350
    (const ChannelList::ChannelMap::const_iterator &i): _i (i)
 
351
{
 
352
    // empty
 
353
}
 
354
 
 
355
 
 
356
inline
 
357
ChannelList::ConstIterator::ConstIterator (const ChannelList::Iterator &other):
 
358
    _i (other._i)
 
359
{
 
360
    // empty
 
361
}
 
362
 
 
363
inline ChannelList::ConstIterator &
 
364
ChannelList::ConstIterator::operator ++ ()
 
365
{
 
366
    ++_i;
 
367
    return *this;
 
368
}
 
369
 
 
370
 
 
371
inline ChannelList::ConstIterator               
 
372
ChannelList::ConstIterator::operator ++ (int)
 
373
{
 
374
    ConstIterator tmp = *this;
 
375
    ++_i;
 
376
    return tmp;
 
377
}
 
378
 
 
379
 
 
380
inline const char *
 
381
ChannelList::ConstIterator::name () const
 
382
{
 
383
    return *_i->first;
 
384
}
 
385
 
 
386
inline const Channel &  
 
387
ChannelList::ConstIterator::channel () const
 
388
{
 
389
    return _i->second;
 
390
}
 
391
 
 
392
 
 
393
inline bool
 
394
operator == (const ChannelList::ConstIterator &x,
 
395
             const ChannelList::ConstIterator &y)
 
396
{
 
397
    return x._i == y._i;
 
398
}
 
399
 
 
400
 
 
401
inline bool
 
402
operator != (const ChannelList::ConstIterator &x,
 
403
             const ChannelList::ConstIterator &y)
 
404
{
 
405
    return !(x == y);
 
406
}
 
407
 
 
408
 
 
409
} // namespace Imf
 
410
 
 
411
#endif