/src/openexr/src/lib/OpenEXR/ImfKeyCode.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // SPDX-License-Identifier: BSD-3-Clause |
3 | | // Copyright (c) Contributors to the OpenEXR Project. |
4 | | // |
5 | | |
6 | | //----------------------------------------------------------------------------- |
7 | | // |
8 | | // class KeyCode |
9 | | // |
10 | | //----------------------------------------------------------------------------- |
11 | | |
12 | | #include "Iex.h" |
13 | | #include "ImfNamespace.h" |
14 | | #include <ImfKeyCode.h> |
15 | | |
16 | | OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
17 | | |
18 | | KeyCode::KeyCode ( |
19 | | int filmMfcCode, |
20 | | int filmType, |
21 | | int prefix, |
22 | | int count, |
23 | | int perfOffset, |
24 | | int perfsPerFrame, |
25 | | int perfsPerCount) |
26 | 0 | { |
27 | 0 | setFilmMfcCode (filmMfcCode); |
28 | 0 | setFilmType (filmType); |
29 | 0 | setPrefix (prefix); |
30 | 0 | setCount (count); |
31 | 0 | setPerfOffset (perfOffset); |
32 | 0 | setPerfsPerFrame (perfsPerFrame); |
33 | 0 | setPerfsPerCount (perfsPerCount); |
34 | 0 | } |
35 | | |
36 | | KeyCode::KeyCode (const KeyCode& other) |
37 | 0 | { |
38 | 0 | _filmMfcCode = other._filmMfcCode; |
39 | 0 | _filmType = other._filmType; |
40 | 0 | _prefix = other._prefix; |
41 | 0 | _count = other._count; |
42 | 0 | _perfOffset = other._perfOffset; |
43 | 0 | _perfsPerFrame = other._perfsPerFrame; |
44 | 0 | _perfsPerCount = other._perfsPerCount; |
45 | 0 | } |
46 | | |
47 | | KeyCode& |
48 | | KeyCode::operator= (const KeyCode& other) |
49 | 0 | { |
50 | 0 | if (this != &other) |
51 | 0 | { |
52 | 0 | _filmMfcCode = other._filmMfcCode; |
53 | 0 | _filmType = other._filmType; |
54 | 0 | _prefix = other._prefix; |
55 | 0 | _count = other._count; |
56 | 0 | _perfOffset = other._perfOffset; |
57 | 0 | _perfsPerFrame = other._perfsPerFrame; |
58 | 0 | _perfsPerCount = other._perfsPerCount; |
59 | 0 | } |
60 | |
|
61 | 0 | return *this; |
62 | 0 | } |
63 | | |
64 | | bool |
65 | | KeyCode::operator== (const KeyCode& other) const |
66 | 0 | { |
67 | 0 | return (_filmMfcCode == other._filmMfcCode && |
68 | 0 | _filmType == other._filmType && |
69 | 0 | _prefix == other._prefix && |
70 | 0 | _count == other._count && |
71 | 0 | _perfOffset == other._perfOffset && |
72 | 0 | _perfsPerFrame == other._perfsPerFrame && |
73 | 0 | _perfsPerCount == other._perfsPerCount); |
74 | 0 | } |
75 | | |
76 | | int |
77 | | KeyCode::filmMfcCode () const |
78 | 0 | { |
79 | 0 | return _filmMfcCode; |
80 | 0 | } |
81 | | |
82 | | void |
83 | | KeyCode::setFilmMfcCode (int filmMfcCode) |
84 | 0 | { |
85 | 0 | if (filmMfcCode < 0 || filmMfcCode > 99) |
86 | 0 | throw IEX_NAMESPACE::ArgExc ("Invalid key code film manufacturer code " |
87 | 0 | "(must be between 0 and 99)."); |
88 | | |
89 | 0 | _filmMfcCode = filmMfcCode; |
90 | 0 | } |
91 | | |
92 | | int |
93 | | KeyCode::filmType () const |
94 | 0 | { |
95 | 0 | return _filmType; |
96 | 0 | } |
97 | | |
98 | | void |
99 | | KeyCode::setFilmType (int filmType) |
100 | 0 | { |
101 | 0 | if (filmType < 0 || filmType > 99) |
102 | 0 | throw IEX_NAMESPACE::ArgExc ("Invalid key code film type " |
103 | 0 | "(must be between 0 and 99)."); |
104 | | |
105 | 0 | _filmType = filmType; |
106 | 0 | } |
107 | | |
108 | | int |
109 | | KeyCode::prefix () const |
110 | 0 | { |
111 | 0 | return _prefix; |
112 | 0 | } |
113 | | |
114 | | void |
115 | | KeyCode::setPrefix (int prefix) |
116 | 0 | { |
117 | 0 | if (prefix < 0 || prefix > 999999) |
118 | 0 | throw IEX_NAMESPACE::ArgExc ("Invalid key code prefix " |
119 | 0 | "(must be between 0 and 999999)."); |
120 | | |
121 | 0 | _prefix = prefix; |
122 | 0 | } |
123 | | |
124 | | int |
125 | | KeyCode::count () const |
126 | 0 | { |
127 | 0 | return _count; |
128 | 0 | } |
129 | | |
130 | | void |
131 | | KeyCode::setCount (int count) |
132 | 0 | { |
133 | 0 | if (count < 0 || count > 9999) |
134 | 0 | throw IEX_NAMESPACE::ArgExc ("Invalid key code count " |
135 | 0 | "(must be between 0 and 9999)."); |
136 | | |
137 | 0 | _count = count; |
138 | 0 | } |
139 | | |
140 | | int |
141 | | KeyCode::perfOffset () const |
142 | 0 | { |
143 | 0 | return _perfOffset; |
144 | 0 | } |
145 | | |
146 | | void |
147 | | KeyCode::setPerfOffset (int perfOffset) |
148 | 0 | { |
149 | 0 | if (perfOffset < 0 || perfOffset > 119) |
150 | 0 | throw IEX_NAMESPACE::ArgExc ("Invalid key code perforation offset " |
151 | 0 | "(must be between 0 and 119)."); |
152 | | |
153 | 0 | _perfOffset = perfOffset; |
154 | 0 | } |
155 | | |
156 | | int |
157 | | KeyCode::perfsPerFrame () const |
158 | 0 | { |
159 | 0 | return _perfsPerFrame; |
160 | 0 | } |
161 | | |
162 | | void |
163 | | KeyCode::setPerfsPerFrame (int perfsPerFrame) |
164 | 0 | { |
165 | 0 | if (perfsPerFrame < 1 || perfsPerFrame > 15) |
166 | 0 | throw IEX_NAMESPACE::ArgExc ( |
167 | 0 | "Invalid key code number of perforations per frame " |
168 | 0 | "(must be between 1 and 15)."); |
169 | | |
170 | 0 | _perfsPerFrame = perfsPerFrame; |
171 | 0 | } |
172 | | |
173 | | int |
174 | | KeyCode::perfsPerCount () const |
175 | 0 | { |
176 | 0 | return _perfsPerCount; |
177 | 0 | } |
178 | | |
179 | | void |
180 | | KeyCode::setPerfsPerCount (int perfsPerCount) |
181 | 0 | { |
182 | 0 | if (perfsPerCount < 20 || perfsPerCount > 120) |
183 | 0 | throw IEX_NAMESPACE::ArgExc ( |
184 | 0 | "Invalid key code number of perforations per count " |
185 | 0 | "(must be between 20 and 120)."); |
186 | | |
187 | 0 | _perfsPerCount = perfsPerCount; |
188 | 0 | } |
189 | | |
190 | | OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |