Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccXformFactory.h
Go to the documentation of this file.
1/** @file
2 File: IccXformFactory.h
3
4 Contains: Header for implementation of CIccXformFactory class and
5 creation factories
6
7 Version: V1
8
9 Copyright: (c) see ICC Software License
10*/
11
12/*
13 * The ICC Software License, Version 0.2
14 *
15 *
16 * Copyright (c) 2007 The International Color Consortium. All rights
17 * reserved.
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 *
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 *
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
29 * distribution.
30 *
31 * 3. In the absence of prior written permission, the names "ICC" and "The
32 * International Color Consortium" must not be used to imply that the
33 * ICC organization endorses or promotes products derived from this
34 * software.
35 *
36 *
37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40 * DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
41 * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This software consists of voluntary contributions made by many
52 * individuals on behalf of the The International Color Consortium.
53 *
54 *
55 * Membership in the ICC is encouraged when this software is used for
56 * commercial purposes.
57 *
58 *
59 * For more information on The International Color Consortium, please
60 * see <http://www.color.org/>.
61 *
62 *
63 */
64
65//////////////////////////////////////////////////////////////////////
66// HISTORY:
67//
68// -Nov 21, 2007
69// A CIccXformCreator singleton class has been added to provide general
70// support for dynamically creating xform classes using a xform type.
71// Prototype and private xform type support can be added to the system
72// by pushing additional IIccXformFactory based objects to the
73// singleton CIccXformCreator object.
74//
75//////////////////////////////////////////////////////////////////////
76
77#ifndef _ICCXFORMFACTORY_H
78#define _ICCXFORMFACTORY_H
79
80#include "IccCmm.h"
81#include <memory>
82#include <list>
83#include <string>
84
85//CIccXform factory support
86#ifdef USEREFICCMAXNAMESPACE
87namespace refIccMAX {
88#endif
89
90/**
91 ***********************************************************************
92 * Class: IIccXformFactory
93 *
94 * Purpose:
95 * IIccXformFactory is a factory pattern interface for CIccXform creation.
96 * This class is pure virtual.
97 ***********************************************************************
98 */
100{
101public:
102 virtual ~IIccXformFactory() {}
103
104 /**
105 * Function: CreateXform(xformTypeSig)
106 * Create a xform of type xformTypeSig.
107 *
108 * Parameter(s):
109 * xformTypeSig = signature of the ICC xform type for the xform to be created
110 * pTag = tag information for created xform
111 * pHintManager = contains additional information used to create xform
112 *
113 * Returns a new CIccXform object of the given signature type. If the xform
114 * factory doesn't support creation of xforms of type xformTypeSig then it
115 * should return NULL.
116 */
117 virtual CIccXform* CreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager* pHintManager=0)=0;
118};
119
120
121//A CIccXformFactoryList is used by CIccXformCreator to keep track of xform
122//creation factories
123typedef std::list<IIccXformFactory*> CIccXformFactoryList;
124
125
126/**
127 ***********************************************************************
128 * Class: CIccBaseXformFactory
129 *
130 * Purpose:
131 * CIccSpecXformFactory provides creation of Base CIccXform's. The
132 * CIccXformCreator always creates a CIccSpecXformFactory.
133 ***********************************************************************
134 */
136{
137public:
138 /**
139 * Function: CreateXform(xformTypeSig)
140 * Create a xform of type xformTypeSig.
141 *
142 * Parameter(s):
143 * xformTypeSig = signature of the ICC xform type for the xform to be created
144 * pTag = tag information for created xform
145 * pHintManager = contains additional information used to create xform
146 *
147 * Returns a new CIccXform object of the given xform type.
148 * Unrecognized xformTypeSig's will be created as a CIccXformUnknown object.
149 */
150 virtual CIccXform* CreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager *pHintManager=NULL);
151
152};
153
154class CIccXformCreator;
155
156typedef std::unique_ptr<CIccXformCreator> CIccXformCreatorPtr;
157
158/**
159 ***********************************************************************
160 * Class: CIccXformCreator
161 *
162 * Purpose:
163 * CIccXformCreator uses a singleton pattern to provide dynamically
164 * upgradeable CIccXform derived object creation based on xform type.
165 ***********************************************************************
166 */
168{
169public:
171
172 /**
173 * Function: CreateXform(xformTypeSig)
174 * Create a xform of type xformTypeSig.
175 *
176 * Parameter(s):
177 * xformType = signature of the ICC xform type for the xform to be created
178 * pTag = tag information for created xform
179 * pHintManager = contains additional information used to create xform
180 *
181 * Returns a new CIccXform object of the given xform type.
182 * Each factory in the factoryStack is used until a factory supports the
183 * signature type.
184 */
185 static CIccXform* CreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager *pHintManager=NULL)
186 { return CIccXformCreator::GetInstance()->DoCreateXform(xformType, pTag, pHintManager); }
187
188 /**
189 * Function: PushFactory(pFactory)
190 * Add an IIccXformFactory to the stack of xform factories tracked by the system.
191 *
192 * Parameter(s):
193 * pFactory = pointer to an IIccXformFactory object to add to the system.
194 * The pFactory must be created with new, and will be owned CIccXformCreator
195 * until popped off the stack using PopFactory(). Any factories not
196 * popped off will be taken care of properly on application shutdown.
197 *
198 */
199 static void PushFactory(IIccXformFactory *pFactory)
200 { CIccXformCreator::GetInstance()->CIccXformCreator::DoPushFactory(pFactory); }
201
202 /**
203 * Function: PopFactory()
204 * Remove the top IIccXformFactory from the stack of xform factories tracked by the system.
205 *
206 * Parameter(s):
207 * None
208 *
209 * Returns the top IIccXformFactory from the stack of xform factories tracked by the system.
210 * The returned xform factory is no longer owned by the system and needs to be deleted
211 * to avoid memory leaks.
212 *
213 * Note: The initial CIccSpecXformFactory cannot be popped off the stack.
214 */
217
218private:
219 /**Only GetInstance() can create the signleton*/
221
222 /**
223 * Function: GetInstance()
224 * Private static function to access singleton CiccXformCreator Object.
225 *
226 * Parameter(s):
227 * None
228 *
229 * Returns the singleton CIccXformCreator object. It will allocate
230 * a new one and push a single CIccSpecXform Factory object onto the factory
231 * stack if the singleton has not been intialized.
232 */
233 static CIccXformCreator* GetInstance();
234
235 CIccXform* DoCreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager *pHintManager=NULL);
236 void DoPushFactory(IIccXformFactory *pFactory);
237 IIccXformFactory* DoPopFactory(bool bAll=false);
238
240
242};
243
244#ifdef USEREFICCMAXNAMESPACE
245} //namespace refIccMAX
246#endif
247
248#endif //_ICCXFORMFACTORY_H
File: IccCmm.h.
icXformType
Definition IccCmm.h:148
std::unique_ptr< CIccXformCreator > CIccXformCreatorPtr
std::list< IIccXformFactory * > CIccXformFactoryList
Class: CIccBaseXformFactory.
Class: CIccTag.
Class: CIccXformCreator.
static void PushFactory(IIccXformFactory *pFactory)
Function: PushFactory(pFactory) Add an IIccXformFactory to the stack of xform factories tracked by th...
static CIccXform * CreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager *pHintManager=NULL)
Function: CreateXform(xformTypeSig) Create a xform of type xformTypeSig.
CIccXform * DoCreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager *pHintManager=NULL)
static CIccXformCreatorPtr theXformCreator
CIccXformCreator()
Only GetInstance() can create the signleton.
CIccXformFactoryList factoryStack
IIccXformFactory * DoPopFactory(bool bAll=false)
static IIccXformFactory * PopFactory()
Function: PopFactory() Remove the top IIccXformFactory from the stack of xform factories tracked by t...
static CIccXformCreator * GetInstance()
Function: GetInstance() Private static function to access singleton CiccXformCreator Object.
Class: IIccXformFactory.
virtual CIccXform * CreateXform(icXformType xformType, CIccTag *pTag=NULL, CIccCreateXformHintManager *pHintManager=0)=0
Function: CreateXform(xformTypeSig) Create a xform of type xformTypeSig.
virtual ~IIccXformFactory()