1
///////////////////////////////////////////////////////////////////////////
3
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
6
// All rights reserved.
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
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
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.
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.
33
///////////////////////////////////////////////////////////////////////////
37
//-----------------------------------------------------------------------------
42
//-----------------------------------------------------------------------------
44
#include <ImfChannelList.h>
54
Channel::Channel (PixelType t, int xs, int ys, bool pl):
65
Channel::operator == (const Channel &other) const
67
return type == other.type &&
68
xSampling == other.xSampling &&
69
ySampling == other.ySampling &&
70
pLinear == other.pLinear;
75
ChannelList::insert (const char name[], const Channel &channel)
78
THROW (Iex::ArgExc, "Image channel name cannot be an empty string.");
85
ChannelList::operator [] (const char name[])
87
ChannelMap::iterator i = _map.find (name);
90
THROW (Iex::ArgExc, "Cannot find image channel \"" << name << "\".");
97
ChannelList::operator [] (const char name[]) const
99
ChannelMap::const_iterator i = _map.find (name);
102
THROW (Iex::ArgExc, "Cannot find image channel \"" << name << "\".");
109
ChannelList::findChannel (const char name[])
111
ChannelMap::iterator i = _map.find (name);
112
return (i == _map.end())? 0: &i->second;
117
ChannelList::findChannel (const char name[]) const
119
ChannelMap::const_iterator i = _map.find (name);
120
return (i == _map.end())? 0: &i->second;
124
ChannelList::Iterator
125
ChannelList::begin ()
131
ChannelList::ConstIterator
132
ChannelList::begin () const
138
ChannelList::Iterator
145
ChannelList::ConstIterator
146
ChannelList::end () const
152
ChannelList::Iterator
153
ChannelList::find (const char name[])
155
return _map.find (name);
159
ChannelList::ConstIterator
160
ChannelList::find (const char name[]) const
162
return _map.find (name);
167
ChannelList::layers (set <string> &layerNames) const
171
for (ConstIterator i = begin(); i != end(); ++i)
173
string layerName = i.name();
174
size_t pos = layerName.rfind ('.');
176
if (pos != string::npos && pos != 0 && pos + 1 < layerName.size())
178
layerName.erase (pos);
179
layerNames.insert (layerName);
186
ChannelList::channelsInLayer (const string &layerName,
190
channelsWithPrefix ((layerName + '.').c_str(), first, last);
195
ChannelList::channelsInLayer (const string &layerName,
196
ConstIterator &first,
197
ConstIterator &last) const
199
channelsWithPrefix ((layerName + '.').c_str(), first, last);
204
ChannelList::channelsWithPrefix (const char prefix[],
208
first = last = _map.lower_bound (prefix);
209
int n = strlen (prefix);
211
while (last != Iterator (_map.end()) &&
212
strncmp (last.name(), prefix, n) <= 0)
220
ChannelList::channelsWithPrefix (const char prefix[],
221
ConstIterator &first,
222
ConstIterator &last) const
224
first = last = _map.lower_bound (prefix);
225
int n = strlen (prefix);
227
while (last != ConstIterator (_map.end()) &&
228
strncmp (last.name(), prefix, n) <= 0)
236
ChannelList::operator == (const ChannelList &other) const
238
ConstIterator i = begin();
239
ConstIterator j = other.begin();
241
while (i != end() && j != other.end())
243
if (!(i.channel() == j.channel()))
250
return i == end() && j == other.end();
1
///////////////////////////////////////////////////////////////////////////
3
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
6
// All rights reserved.
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
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
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.
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.
33
///////////////////////////////////////////////////////////////////////////
37
//-----------------------------------------------------------------------------
42
//-----------------------------------------------------------------------------
44
#include <ImfChannelList.h>
54
Channel::Channel (PixelType t, int xs, int ys, bool pl):
65
Channel::operator == (const Channel &other) const
67
return type == other.type &&
68
xSampling == other.xSampling &&
69
ySampling == other.ySampling &&
70
pLinear == other.pLinear;
75
ChannelList::insert (const char name[], const Channel &channel)
78
THROW (Iex::ArgExc, "Image channel name cannot be an empty string.");
85
ChannelList::operator [] (const char name[])
87
ChannelMap::iterator i = _map.find (name);
90
THROW (Iex::ArgExc, "Cannot find image channel \"" << name << "\".");
97
ChannelList::operator [] (const char name[]) const
99
ChannelMap::const_iterator i = _map.find (name);
102
THROW (Iex::ArgExc, "Cannot find image channel \"" << name << "\".");
109
ChannelList::findChannel (const char name[])
111
ChannelMap::iterator i = _map.find (name);
112
return (i == _map.end())? 0: &i->second;
117
ChannelList::findChannel (const char name[]) const
119
ChannelMap::const_iterator i = _map.find (name);
120
return (i == _map.end())? 0: &i->second;
124
ChannelList::Iterator
125
ChannelList::begin ()
131
ChannelList::ConstIterator
132
ChannelList::begin () const
138
ChannelList::Iterator
145
ChannelList::ConstIterator
146
ChannelList::end () const
152
ChannelList::Iterator
153
ChannelList::find (const char name[])
155
return _map.find (name);
159
ChannelList::ConstIterator
160
ChannelList::find (const char name[]) const
162
return _map.find (name);
167
ChannelList::layers (set <string> &layerNames) const
171
for (ConstIterator i = begin(); i != end(); ++i)
173
string layerName = i.name();
174
size_t pos = layerName.rfind ('.');
176
if (pos != string::npos && pos != 0 && pos + 1 < layerName.size())
178
layerName.erase (pos);
179
layerNames.insert (layerName);
186
ChannelList::channelsInLayer (const string &layerName,
190
channelsWithPrefix ((layerName + '.').c_str(), first, last);
195
ChannelList::channelsInLayer (const string &layerName,
196
ConstIterator &first,
197
ConstIterator &last) const
199
channelsWithPrefix ((layerName + '.').c_str(), first, last);
204
ChannelList::channelsWithPrefix (const char prefix[],
208
first = last = _map.lower_bound (prefix);
209
int n = strlen (prefix);
211
while (last != Iterator (_map.end()) &&
212
strncmp (last.name(), prefix, n) <= 0)
220
ChannelList::channelsWithPrefix (const char prefix[],
221
ConstIterator &first,
222
ConstIterator &last) const
224
first = last = _map.lower_bound (prefix);
225
int n = strlen (prefix);
227
while (last != ConstIterator (_map.end()) &&
228
strncmp (last.name(), prefix, n) <= 0)
236
ChannelList::operator == (const ChannelList &other) const
238
ConstIterator i = begin();
239
ConstIterator j = other.begin();
241
while (i != end() && j != other.end())
243
if (!(i.channel() == j.channel()))
250
return i == end() && j == other.end();