Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccXformFactory.cpp
Go to the documentation of this file.
1/** @file
2 File: IccXformFactory.cpp
3
4 Contains: Implementation of the CIccXform class and creation factories
5
6 Version: V1
7
8 Copyright: (c) see ICC Software License
9*/
10
11/*
12 * The ICC Software License, Version 0.2
13 *
14 *
15 * Copyright (c) 2003-2012 The International Color Consortium. All rights
16 * reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 *
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in
27 * the documentation and/or other materials provided with the
28 * distribution.
29 *
30 * 3. In the absence of prior written permission, the names "ICC" and "The
31 * International Color Consortium" must not be used to imply that the
32 * ICC organization endorses or promotes products derived from this
33 * software.
34 *
35 *
36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
40 * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This software consists of voluntary contributions made by many
51 * individuals on behalf of the The International Color Consortium.
52 *
53 *
54 * Membership in the ICC is encouraged when this software is used for
55 * commercial purposes.
56 *
57 *
58 * For more information on The International Color Consortium, please
59 * see <http://www.color.org/>.
60 *
61 *
62 */
63
64//////////////////////////////////////////////////////////////////////
65// HISTORY:
66//
67// -Oct 30, 2005
68// Added CICCXform Creation using factory support
69//
70//////////////////////////////////////////////////////////////////////
71
72#include "IccXformFactory.h"
73
74#ifdef USEREFICCMAXNAMESPACE
75namespace refIccMAX {
76#endif
77
78CIccXform* CIccBaseXformFactory::CreateXform(icXformType xformSig, CIccTag *pTag/*=NULL*/, CIccCreateXformHintManager *pHintManager/*=NULL*/)
79{
80 //We generally ignore pHint in the base creator (used by others to determine what form of xform to create)
81 switch(xformSig) {
83 return new CIccXformMatrixTRC();
84
86 return new CIccXform3DLut(pTag);
87
89 return new CIccXform4DLut(pTag);
90
92 return new CIccXformNDLut(pTag);
93
95 if (pHintManager) {
96 IIccCreateXformHint* pHint = pHintManager->GetHint("CIccCreateNamedColorXformHint");
97 if (pHint) {
98 CIccCreateNamedColorXformHint *pNCHint = (CIccCreateNamedColorXformHint*)pHint;
99 return new CIccXformNamedColor(pTag, pNCHint->csPcs, pNCHint->csDevice,
100 pNCHint->csSpectralPcs,
101 &pNCHint->spectralRange,
102 &pNCHint->biSpectralRange);
103 }
104 }
105 return NULL;
106
107 case icXformTypeMpe:
108 return new CIccXformMpe(pTag);
109
111 return new CIccXformMonochrome();
112
113 default:
114 return NULL;
115 }
116}
117
118std::unique_ptr<CIccXformCreator> CIccXformCreator::theXformCreator;
119
121{
122 IIccXformFactory *pFactory = DoPopFactory(true);
123
124 while (pFactory) {
125 delete pFactory;
126 pFactory = DoPopFactory(true);
127 }
128}
129
131{
132 if (!theXformCreator.get()) {
133 theXformCreator = CIccXformCreatorPtr(new CIccXformCreator);
134
135 theXformCreator->DoPushFactory(new CIccBaseXformFactory);
136 }
137
138 return theXformCreator.get();
139}
140
141CIccXform* CIccXformCreator::DoCreateXform(icXformType xformTypeSig, CIccTag *pTag/*=NULL*/, CIccCreateXformHintManager *pHintManager/*=NULL*/)
142{
143 CIccXformFactoryList::iterator i;
144 CIccXform *rv = NULL;
145
146 for (i=factoryStack.begin(); i!=factoryStack.end(); i++) {
147 rv = (*i)->CreateXform(xformTypeSig, pTag, pHintManager);
148 if (rv)
149 break;
150 }
151 return rv;
152}
153
155{
156 factoryStack.push_front(pFactory);
157}
158
160{
161 //int nNum = (bAll ? 0 : 1);
162
163 if (factoryStack.size()>0) {
164 CIccXformFactoryList::iterator i=factoryStack.begin();
165 IIccXformFactory* rv = (*i);
166 factoryStack.pop_front();
167 return rv;
168 }
169 return NULL;
170}
171
172#ifdef USEREFICCMAXNAMESPACE
173} //namespace refIccMAX
174#endif
icXformType
Definition IccCmm.h:148
@ icXformTypeMpe
Definition IccCmm.h:154
@ icXformTypeMatrixTRC
Definition IccCmm.h:149
@ icXformTypeNDLut
Definition IccCmm.h:152
@ icXformTypeMonochrome
Definition IccCmm.h:155
@ icXformType3DLut
Definition IccCmm.h:150
@ icXformType4DLut
Definition IccCmm.h:151
@ icXformTypeNamedColor
Definition IccCmm.h:153
File: IccXformFactory.h.
std::unique_ptr< CIccXformCreator > CIccXformCreatorPtr
Class: CIccBaseXformFactory.
virtual CIccXform * CreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager *pHintManager=NULL)
Function: CreateXform(xformTypeSig) Create a xform of type xformTypeSig.
Class: CIccTag.
Class: CIccXformCreator.
CIccXform * DoCreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager *pHintManager=NULL)
static CIccXformCreatorPtr theXformCreator
IIccXformFactory * DoPopFactory(bool bAll=false)
static CIccXformCreator * GetInstance()
Function: GetInstance() Private static function to access singleton CiccXformCreator Object.
void DoPushFactory(IIccXformFactory *pFactory)
Class: IIccXformFactory.