ImfKeyCode.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. // class KeyCode
  37. //
  38. //-----------------------------------------------------------------------------
  39. #include <ImfKeyCode.h>
  40. #include "Iex.h"
  41. #include "ImfNamespace.h"
  42. OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
  43. KeyCode::KeyCode (int filmMfcCode,
  44. int filmType,
  45. int prefix,
  46. int count,
  47. int perfOffset,
  48. int perfsPerFrame,
  49. int perfsPerCount)
  50. {
  51. setFilmMfcCode (filmMfcCode);
  52. setFilmType (filmType);
  53. setPrefix (prefix);
  54. setCount (count);
  55. setPerfOffset (perfOffset);
  56. setPerfsPerFrame (perfsPerFrame);
  57. setPerfsPerCount (perfsPerCount);
  58. }
  59. KeyCode::KeyCode (const KeyCode &other)
  60. {
  61. _filmMfcCode = other._filmMfcCode;
  62. _filmType = other._filmType;
  63. _prefix = other._prefix;
  64. _count = other._count;
  65. _perfOffset = other._perfOffset;
  66. _perfsPerFrame = other._perfsPerFrame;
  67. _perfsPerCount = other._perfsPerCount;
  68. }
  69. KeyCode &
  70. KeyCode::operator = (const KeyCode &other)
  71. {
  72. _filmMfcCode = other._filmMfcCode;
  73. _filmType = other._filmType;
  74. _prefix = other._prefix;
  75. _count = other._count;
  76. _perfOffset = other._perfOffset;
  77. _perfsPerFrame = other._perfsPerFrame;
  78. _perfsPerCount = other._perfsPerCount;
  79. return *this;
  80. }
  81. int
  82. KeyCode::filmMfcCode () const
  83. {
  84. return _filmMfcCode;
  85. }
  86. void
  87. KeyCode::setFilmMfcCode (int filmMfcCode)
  88. {
  89. if (filmMfcCode < 0 || filmMfcCode > 99)
  90. throw IEX_NAMESPACE::ArgExc ("Invalid key code film manufacturer code "
  91. "(must be between 0 and 99).");
  92. _filmMfcCode = filmMfcCode;
  93. }
  94. int
  95. KeyCode::filmType () const
  96. {
  97. return _filmType;
  98. }
  99. void
  100. KeyCode::setFilmType (int filmType)
  101. {
  102. if (filmType < 0 || filmType > 99)
  103. throw IEX_NAMESPACE::ArgExc ("Invalid key code film type "
  104. "(must be between 0 and 99).");
  105. _filmType = filmType;
  106. }
  107. int
  108. KeyCode::prefix () const
  109. {
  110. return _prefix;
  111. }
  112. void
  113. KeyCode::setPrefix (int prefix)
  114. {
  115. if (prefix < 0 || prefix > 999999)
  116. throw IEX_NAMESPACE::ArgExc ("Invalid key code prefix "
  117. "(must be between 0 and 999999).");
  118. _prefix = prefix;
  119. }
  120. int
  121. KeyCode::count () const
  122. {
  123. return _count;
  124. }
  125. void
  126. KeyCode::setCount (int count)
  127. {
  128. if (count < 0 || count > 9999)
  129. throw IEX_NAMESPACE::ArgExc ("Invalid key code count "
  130. "(must be between 0 and 9999).");
  131. _count = count;
  132. }
  133. int
  134. KeyCode::perfOffset () const
  135. {
  136. return _perfOffset;
  137. }
  138. void
  139. KeyCode::setPerfOffset (int perfOffset)
  140. {
  141. if (perfOffset < 0 || perfOffset > 119)
  142. throw IEX_NAMESPACE::ArgExc ("Invalid key code perforation offset "
  143. "(must be between 0 and 119).");
  144. _perfOffset = perfOffset;
  145. }
  146. int
  147. KeyCode::perfsPerFrame () const
  148. {
  149. return _perfsPerFrame;
  150. }
  151. void
  152. KeyCode::setPerfsPerFrame (int perfsPerFrame)
  153. {
  154. if (perfsPerFrame < 1 || perfsPerFrame > 15)
  155. throw IEX_NAMESPACE::ArgExc ("Invalid key code number of perforations per frame "
  156. "(must be between 1 and 15).");
  157. _perfsPerFrame = perfsPerFrame;
  158. }
  159. int
  160. KeyCode::perfsPerCount () const
  161. {
  162. return _perfsPerCount;
  163. }
  164. void
  165. KeyCode::setPerfsPerCount (int perfsPerCount)
  166. {
  167. if (perfsPerCount < 20 || perfsPerCount > 120)
  168. throw IEX_NAMESPACE::ArgExc ("Invalid key code number of perforations per count "
  169. "(must be between 20 and 120).");
  170. _perfsPerCount = perfsPerCount;
  171. }
  172. OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT