/src/FreeImage/Source/OpenEXR/IlmImf/ImfKeyCode.cpp

https://bitbucket.org/cabalistic/ogredeps/ · C++ · 216 lines · 133 code · 45 blank · 38 comment · 14 complexity · 1ec42d6478424eba52feb8105b007aa8 MD5 · raw file

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