1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2004, 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 //
38 // class KeyCode
39 //
40 //-----------------------------------------------------------------------------
41
42 #include <ImfKeyCode.h>
43 #include "Iex.h"
44 #include "ImfNamespace.h"
45
46 OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
47
48
KeyCode(int filmMfcCode,int filmType,int prefix,int count,int perfOffset,int perfsPerFrame,int perfsPerCount)49 KeyCode::KeyCode (int filmMfcCode,
50 int filmType,
51 int prefix,
52 int count,
53 int perfOffset,
54 int perfsPerFrame,
55 int perfsPerCount)
56 {
57 setFilmMfcCode (filmMfcCode);
58 setFilmType (filmType);
59 setPrefix (prefix);
60 setCount (count);
61 setPerfOffset (perfOffset);
62 setPerfsPerFrame (perfsPerFrame);
63 setPerfsPerCount (perfsPerCount);
64 }
65
66
KeyCode(const KeyCode & other)67 KeyCode::KeyCode (const KeyCode &other)
68 {
69 _filmMfcCode = other._filmMfcCode;
70 _filmType = other._filmType;
71 _prefix = other._prefix;
72 _count = other._count;
73 _perfOffset = other._perfOffset;
74 _perfsPerFrame = other._perfsPerFrame;
75 _perfsPerCount = other._perfsPerCount;
76 }
77
78
79 KeyCode &
operator =(const KeyCode & other)80 KeyCode::operator = (const KeyCode &other)
81 {
82 _filmMfcCode = other._filmMfcCode;
83 _filmType = other._filmType;
84 _prefix = other._prefix;
85 _count = other._count;
86 _perfOffset = other._perfOffset;
87 _perfsPerFrame = other._perfsPerFrame;
88 _perfsPerCount = other._perfsPerCount;
89
90 return *this;
91 }
92
93
94 int
filmMfcCode() const95 KeyCode::filmMfcCode () const
96 {
97 return _filmMfcCode;
98 }
99
100
101 void
setFilmMfcCode(int filmMfcCode)102 KeyCode::setFilmMfcCode (int filmMfcCode)
103 {
104 if (filmMfcCode < 0 || filmMfcCode > 99)
105 throw IEX_NAMESPACE::ArgExc ("Invalid key code film manufacturer code "
106 "(must be between 0 and 99).");
107
108 _filmMfcCode = filmMfcCode;
109 }
110
111 int
filmType() const112 KeyCode::filmType () const
113 {
114 return _filmType;
115 }
116
117
118 void
setFilmType(int filmType)119 KeyCode::setFilmType (int filmType)
120 {
121 if (filmType < 0 || filmType > 99)
122 throw IEX_NAMESPACE::ArgExc ("Invalid key code film type "
123 "(must be between 0 and 99).");
124
125 _filmType = filmType;
126 }
127
128 int
prefix() const129 KeyCode::prefix () const
130 {
131 return _prefix;
132 }
133
134
135 void
setPrefix(int prefix)136 KeyCode::setPrefix (int prefix)
137 {
138 if (prefix < 0 || prefix > 999999)
139 throw IEX_NAMESPACE::ArgExc ("Invalid key code prefix "
140 "(must be between 0 and 999999).");
141
142 _prefix = prefix;
143 }
144
145
146 int
count() const147 KeyCode::count () const
148 {
149 return _count;
150 }
151
152
153 void
setCount(int count)154 KeyCode::setCount (int count)
155 {
156 if (count < 0 || count > 9999)
157 throw IEX_NAMESPACE::ArgExc ("Invalid key code count "
158 "(must be between 0 and 9999).");
159
160 _count = count;
161 }
162
163
164 int
perfOffset() const165 KeyCode::perfOffset () const
166 {
167 return _perfOffset;
168 }
169
170
171 void
setPerfOffset(int perfOffset)172 KeyCode::setPerfOffset (int perfOffset)
173 {
174 if (perfOffset < 0 || perfOffset > 119)
175 throw IEX_NAMESPACE::ArgExc ("Invalid key code perforation offset "
176 "(must be between 0 and 119).");
177
178 _perfOffset = perfOffset;
179 }
180
181
182 int
perfsPerFrame() const183 KeyCode::perfsPerFrame () const
184 {
185 return _perfsPerFrame;
186 }
187
188
189 void
setPerfsPerFrame(int perfsPerFrame)190 KeyCode::setPerfsPerFrame (int perfsPerFrame)
191 {
192 if (perfsPerFrame < 1 || perfsPerFrame > 15)
193 throw IEX_NAMESPACE::ArgExc ("Invalid key code number of perforations per frame "
194 "(must be between 1 and 15).");
195
196 _perfsPerFrame = perfsPerFrame;
197 }
198
199
200 int
perfsPerCount() const201 KeyCode::perfsPerCount () const
202 {
203 return _perfsPerCount;
204 }
205
206
207 void
setPerfsPerCount(int perfsPerCount)208 KeyCode::setPerfsPerCount (int perfsPerCount)
209 {
210 if (perfsPerCount < 20 || perfsPerCount > 120)
211 throw IEX_NAMESPACE::ArgExc ("Invalid key code number of perforations per count "
212 "(must be between 20 and 120).");
213
214 _perfsPerCount = perfsPerCount;
215 }
216
217 OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
218