Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccMpeFactory.cpp
Go to the documentation of this file.
1/** @file
2 File: IccMpeFactory.cpp
3
4 Contains: Implementation of the CIccProcessElement 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// -Feb 4, 2006
68// Added CIccProcessElement Creation using factory support
69//
70//////////////////////////////////////////////////////////////////////
71
72#include "IccTagMPE.h"
73#include "IccMpeBasic.h"
74#include "IccMpeACS.h"
75#include "IccMpeCalc.h"
76#include "IccMpeSpectral.h"
77#include "IccMpeFactory.h"
78#include "IccUtil.h"
79#include "IccProfile.h"
80
81#ifdef USEREFICCMAXNAMESPACE
82namespace refIccMAX {
83#endif
84
86{
87 switch(elemTypeSig) {
89 return new CIccMpeCurveSet();
90
92 return new CIccMpeMatrix();
93
95 return new CIccMpeCLUT();
96
98 return new CIccMpeExtCLUT();
99
101 return new CIccMpeCalculator();
102
104 return new CIccMpeTintArray();
105
107 return new CIccMpeToneMap();
108
110 return new CIccMpeJabToXYZ();
111
113 return new CIccMpeXYZToJab();
114
116 return new CIccMpeEmissionMatrix();
117
119 return new CIccMpeInvEmissionMatrix();
120
122 return new CIccMpeEmissionCLUT();
123
125 return new CIccMpeReflectanceCLUT();
126
128 return new CIccMpeEmissionObserver();
129
131 return new CIccMpeReflectanceObserver();
132
134 return new CIccMpeBAcs();
135
137 return new CIccMpeEAcs();
138
139 default:
140 return new CIccMpeUnknown();
141 }
142}
143
144bool CIccBasicMpeFactory::GetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)
145{
146 switch(elemTypeSig) {
148 elemName = "Curve Set Element";
149 break;
150
152 elemName = "Matrix Element";
153 break;
154
156 elemName = "CLUT Element";
157 break;
158
160 elemName = "Extended CLUT Element";
161 break;
162
164 elemName = "Calculator Element";
165 break;
166
168 elemName = "Tint Array Element";
169 break;
170
172 elemName = "Tone Mapping Element";
173 break;
174
176 elemName = "JabToXYZ Element";
177 break;
178
180 elemName = "XYZToJab Element";
181 break;
182
184 elemName = "Observer Matrix Element";
185 break;
186
188 elemName = "Observer Inverse Matrix Element";
189 break;
190
192 elemName = "Emission CLUT Element";
193 break;
194
196 elemName = "Reflectance CLUT Element";
197 break;
198
200 elemName = "Emission Observer Element";
201 break;
202
204 elemName = "Reflectance Observer Element";
205 break;
206
208 elemName = "BACS Element";
209 break;
210
212 elemName = "EACS Element";
213 break;
214
215 default:
216 char buf[30], str[100];
217 sprintf(str, "Unknown Element Type (%s)", icGetSig(buf, elemTypeSig));
218 elemName = str;
219 return false;
220 }
221
222 return true;
223}
224
226
228{
229 IIccMpeFactory *pFactory = DoPopFactory(true);
230
231 while (pFactory) {
232 delete pFactory;
233 pFactory = DoPopFactory(true);
234 }
235}
236
238{
239 if (!theElementCreator.get()) {
240 theElementCreator = CIccMpeCreatorPtr(new CIccMpeCreator);
241
242 theElementCreator->DoPushFactory(new CIccBasicMpeFactory);
243 }
244
245 return theElementCreator.get();
246}
247
249{
250 CIccMpeFactoryList::iterator i;
251 CIccMultiProcessElement *rv = NULL;
252
253 for (i=factoryStack.begin(); i!=factoryStack.end(); i++) {
254 rv = (*i)->CreateElement(elemTypeSig);
255 if (rv)
256 break;
257 }
258 return rv;
259}
260
261bool CIccMpeCreator::DoGetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)
262{
263 CIccMpeFactoryList::iterator i;
264
265 for (i=factoryStack.begin(); i!=factoryStack.end(); i++) {
266 if ((*i)->GetElementSigName(elemName, elemTypeSig))
267 return true;
268 }
269
270 return false;
271}
272
274{
275 factoryStack.push_front(pFactory);
276}
277
279{
280 if (factoryStack.size()>0) {
281 CIccMpeFactoryList::iterator i=factoryStack.begin();
282 IIccMpeFactory* rv = (*i);
283 factoryStack.pop_front();
284 return rv;
285 }
286 return NULL;
287}
288
289#ifdef USEREFICCMAXNAMESPACE
290} //namespace refIccMAX
291#endif
File: IccMpeACS.h.
File: IccMpeBasic.h.
File: IccMpeCalc.h.
File: IccMpeFactory.h.
std::unique_ptr< CIccMpeCreator > CIccMpeCreatorPtr
File: IccMpeSpectral.h.
File: IccProfile.h.
File: IccTagMPE.h.
const icChar * icGetSig(icChar *pBuf, icUInt32Number nSig, bool bGetHexVal)
Definition IccUtil.cpp:1028
File: IccUtil.h.
Class: CIccBasicMpeFactory.
virtual CIccMultiProcessElement * CreateElement(icElemTypeSignature elementSig)
Function: CreateElement(elemTypeSig) Create a element of type elemTypeSig.
virtual bool GetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)
Function: GetElementSigName(elemTypeSig) Get display name of elemTypeSig.
Class: CIccMpeBAcs.
Definition IccMpeACS.h:131
Class: CIccMpeCLUT.
Class: CIccMpeCalculator.
Definition IccMpeCalc.h:447
Class: CIccMpeCreator.
IIccMpeFactory * DoPopFactory(bool bAll=false)
void DoPushFactory(IIccMpeFactory *pFactory)
CIccMultiProcessElement * DoCreateElement(icElemTypeSignature elemTypeSig)
static CIccMpeCreatorPtr theElementCreator
bool DoGetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)
static CIccMpeCreator * GetInstance()
Function: GetInstance() Private static function to access singleton CiccElementCreator Object.
Class: CIccMpeCurveSet.
Class: CIccMpeEndAcs.
Definition IccMpeACS.h:155
Class: CIccMpeEmissionCLUT.
Class: CIccMpeEmissionMatrix.
Class: CIccMpeEmissionObserver.
Class: CIccMpeInvEmissionMatrix.
Class: CIccMpeJabToXYZ.
Class: CIccMpeMatrix.
Class: CIccMpeReflectanceCLUT.
Class: CIccMpeReflectanceObserver.
Class: CIccMpeTintArray.
Class: CIccMpeToneMap.
Class: CIccMpeUnknown.
Definition IccTagMPE.h:230
Class: CIccMpeXYZToJab.
Class: CIccMultiProcessElement.
Definition IccTagMPE.h:146
Class: IIccMpeFactory.
icElemTypeSignature
Multi-Processing Element type signatures.
@ icSigEmissionMatrixElemType
@ icSigBAcsElemType
@ icSigEmissionCLUTElemType
@ icSigReflectanceCLUTElemType
@ icSigCurveSetElemType
@ icSigCLutElemType
@ icSigToneMapElemType
@ icSigReflectanceObserverElemType
@ icSigExtCLutElemType
@ icSigTintArrayElemType
@ icSigXYZToJabElemType
@ icSigJabToXYZElemType
@ icSigMatrixElemType
@ icSigEmissionObserverElemType
@ icSigInvEmissionMatrixElemType
@ icSigEAcsElemType
@ icSigCalculatorElemType