PageRenderTime 39ms CodeModel.GetById 17ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 0ms

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