/src/core/Look.cpp

http://github.com/imageworks/OpenColorIO · C++ · 163 lines · 103 code · 32 blank · 28 comment · 4 complexity · 000a0d803b9b435bdf43ec9987c3a0b3 MD5 · raw file

  1. /*
  2. Copyright (c) 2003-2010 Sony Pictures Imageworks Inc., et al.
  3. All Rights Reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. * Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. * Neither the name of Sony Pictures Imageworks nor the names of its
  13. contributors may be used to endorse or promote products derived from
  14. this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  16. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  17. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  19. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #include <cstring>
  28. #include <sstream>
  29. #include <vector>
  30. #include <OpenColorIO/OpenColorIO.h>
  31. OCIO_NAMESPACE_ENTER
  32. {
  33. LookRcPtr Look::Create()
  34. {
  35. return LookRcPtr(new Look(), &deleter);
  36. }
  37. void Look::deleter(Look* c)
  38. {
  39. delete c;
  40. }
  41. class Look::Impl
  42. {
  43. public:
  44. std::string name_;
  45. std::string processSpace_;
  46. TransformRcPtr transform_;
  47. TransformRcPtr inverseTransform_;
  48. Impl()
  49. { }
  50. ~Impl()
  51. { }
  52. Impl& operator= (const Impl & rhs)
  53. {
  54. name_ = rhs.name_;
  55. processSpace_ = rhs.processSpace_;
  56. transform_ = rhs.transform_;
  57. if(transform_) transform_ = transform_->createEditableCopy();
  58. inverseTransform_ = rhs.inverseTransform_;
  59. if(inverseTransform_) inverseTransform_ = inverseTransform_->createEditableCopy();
  60. return *this;
  61. }
  62. };
  63. ///////////////////////////////////////////////////////////////////////////
  64. Look::Look()
  65. : m_impl(new Look::Impl)
  66. {
  67. }
  68. Look::~Look()
  69. {
  70. delete m_impl;
  71. m_impl = NULL;
  72. }
  73. LookRcPtr Look::createEditableCopy() const
  74. {
  75. LookRcPtr cs = Look::Create();
  76. *cs->m_impl = *m_impl;
  77. return cs;
  78. }
  79. const char * Look::getName() const
  80. {
  81. return getImpl()->name_.c_str();
  82. }
  83. void Look::setName(const char * name)
  84. {
  85. getImpl()->name_ = name;
  86. }
  87. const char * Look::getProcessSpace() const
  88. {
  89. return getImpl()->processSpace_.c_str();
  90. }
  91. void Look::setProcessSpace(const char * processSpace)
  92. {
  93. getImpl()->processSpace_ = processSpace;
  94. }
  95. ConstTransformRcPtr Look::getTransform() const
  96. {
  97. return getImpl()->transform_;
  98. }
  99. void Look::setTransform(const ConstTransformRcPtr & transform)
  100. {
  101. getImpl()->transform_ = transform->createEditableCopy();
  102. }
  103. ConstTransformRcPtr Look::getInverseTransform() const
  104. {
  105. return getImpl()->inverseTransform_;
  106. }
  107. void Look::setInverseTransform(const ConstTransformRcPtr & transform)
  108. {
  109. getImpl()->inverseTransform_ = transform->createEditableCopy();
  110. }
  111. std::ostream& operator<< (std::ostream& os, const Look& look)
  112. {
  113. os << "<Look ";
  114. os << "name=" << look.getName() << ", ";
  115. os << "processSpace=" << look.getProcessSpace() << ", ";
  116. if(look.getTransform())
  117. {
  118. os << "\tTransform: ";
  119. os << *look.getTransform();
  120. }
  121. if(look.getInverseTransform())
  122. {
  123. os << "\tInverseTransform: ";
  124. os << *look.getInverseTransform();
  125. }
  126. os << ">";
  127. return os;
  128. }
  129. }
  130. OCIO_NAMESPACE_EXIT