Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccArrayFactory.h
Go to the documentation of this file.
1/** @file
2 File: IccArrayFactory.h
3
4 Contains: Header for implementation of IIccArray Handler 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) 2011 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// -Jun 27, 2011
68// A CIccArrayCreator singleton class has been added to provide general
69// support for dynamically creating array handler classes using a signature.
70// Prototype and private struct type support can be added to the system
71// by pushing additional IIccArrayFactory based objects to the
72// singleton CIccArrayCreator object.
73//
74/////////////////////////////////////////////////////////////////////
75
76#ifndef _ICCARRAYFACTORY_H
77#define _ICCARRAYFACTORY_H
78
79#include "IccDefs.h"
80#include <memory>
81#include <list>
82
83//CIccArray factory support
84#ifdef USEREFICCMAXNAMESPACE
85namespace refIccMAX {
86#endif
87
88class IIccArray;
89class CIccTagArray;
90
91/**
92 ***********************************************************************
93 * Class: IIccArrayFactory
94 *
95 * Purpose:
96 * IIccArrayFactory is a factory pattern interface for CIccArray
97 * creation.
98 * This class is pure virtual.
99 ***********************************************************************
100 */
102{
103public:
104 virtual ~IIccArrayFactory() {}
105
106 /**
107 * Function: CreateArray(arrayTypeSig)
108 * Create a element of type arrayTypeSig.
109 *
110 * Parameter(s):
111 * arrayTypeSig = signature of the ICC element type for the element to
112 * be created
113 *
114 * Returns a new IIArrayObject object of the given signature type.
115 * If the element factory doesn't support creation of array handlers of type
116 * arrayTypeSig then it should return NULL.
117 */
118 virtual IIccArray* CreateArray(icArraySignature arrayTypeSig, CIccTagArray *pTagArray=NULL)=0;
119
120 /**
121 * Function: GeArraySigName(structTypeSig)
122 * Get display name of arrayTypeSig.
123 *
124 * Parameter(s):
125 * arrayName = string to put struct name into,
126 * arrayTypeSig = signature of the ICC struct type to get a name for
127 * bFindUnknown = fills arrayName if strutTypeSig is unknown
128 *
129 * Returns true if arraySig is recognized by the factory, false if the
130 * factory doesn't create arrayTypeSig arrays.
131 */
132 virtual bool GetArraySigName(std::string &arrayName, icArraySignature arrayTypeSig, bool bFillUnknown)=0;
133
134 /**
135 * Function: GetArraySig(arrayName)
136 * Get signature associate with display name arrayName handler
137 *
138 * Parameter(s):
139 * arrayName = string to find signature for
140 *
141 * Returns true if arraySig is recognized by the factory, false if the
142 * factory doesn't create arraySig arrays.
143 */
144 virtual icArraySignature GetArraySig(const icChar *arrayName)=0;
145};
146
147
148//A CIccArrayFactoryList is used by CIccArrayCreator to keep track of element
149//creation factories
150typedef std::list<IIccArrayFactory*> CIccArrayFactoryList;
151
152
153/**
154 ***********************************************************************
155 * Class: CIccBasicArrayFactory
156 *
157 * Purpose:
158 * CIccBasicArrayFactory provides creation of CIccArray handlers
159 * defined by the ICC profile specification. The CIccArrayCreator always
160 * creates a CIccBasicElemFactory.
161 ***********************************************************************
162 */
164{
165public:
166 /**
167 * Function: CreateArray(arrayTypeSig)
168 * Create an array object handler of type arrayTypeSig.
169 *
170 * Parameter(s):
171 * arrayTypeSig = signature of the ICC array type for the array handler to be created
172 * pTagArray = pointer to tag array to associate with the handerl
173 *
174 * Returns a new CIccArray handler of the given signature type.
175 * Unrecognized structTypeSig's will be created as a CIccArrayUnknown object.
176 */
177 virtual IIccArray* CreateArray(icArraySignature arrayTypeSig, CIccTagArray *pTagArray=NULL);
178
179 /**
180 * Function: GetArraySigName(arrayName, arrayTypeSig, bFindUnknown)
181 * Get display name of arrayTypeSig.
182 *
183 * Parameter(s):
184 * arrayName = string to put struct name into,
185 * arrayTypeSig = signature of the ICC struct type to get a name for
186 * bFindUnknown = fills arrayName if strutTypeSig is unknown
187 *
188 * Returns true if arraySig is recognized by the factory, false if the
189 * factory doesn't create arraySig arrays.
190 */
191 virtual bool GetArraySigName(std::string &arrayName, icArraySignature arrayTypeSig, bool bFindUnknown=true);
192
193 /**
194 * Function: GetArraySig(arrayName)
195 * Get signature associate with display name arrayName handler
196 *
197 * Parameter(s):
198 * arrayName = string to find signature for
199 *
200 * Returns true if arraySig is recognized by the factory, false if the
201 * factory doesn't create arraySig arrays.
202 */
203 virtual icArraySignature GetArraySig(const icChar *arrayName);
204};
205
206class CIccArrayCreator;
207
208typedef std::unique_ptr<CIccArrayCreator> CIccArrayCreatorPtr;
209
210/**
211 ***********************************************************************
212 * Class: CIccArrayCreator
213 *
214 * Purpose:
215 * CIccArrayCreator uses a singleton pattern to provide dynamically
216 * upgradeable IIccArrayObject derived object creation based on
217 * element signature.
218 ***********************************************************************
219 */
221{
222public:
224
225 /**
226 * Function: CreateArray(structTypeSig)
227 * Create a element of type structTypeSig.
228 *
229 * Parameter(s):
230 * structTypeSig = signature of the ICC element type for the element to
231 * be created
232 *
233 * Returns a new CIccProcessArray object of the given signature type.
234 * Each factory in the factoryStack is used until a factory supports the
235 * signature type.
236 */
237 static IIccArray* CreateArray(icArraySignature arrayTypeSig, CIccTagArray *pTagArray=NULL)
238 { return CIccArrayCreator::GetInstance()->DoCreateArray(arrayTypeSig, pTagArray); }
239
240 /**
241 * Function: GetArraySigName(structTypeSig)
242 * Get display name of structTypeSig.
243 *
244 * Parameter(s):
245 * arrayName = string to put struct name into
246 * arrayTypeSig = signature of the ICC struct type to get a name for
247 * bFillUnknown = flag to fill in arrayName if arryTypeSig is unknown
248 *
249 * Returns true if struct type is recognized by any factory, false if all
250 * factories do not create arrayTypeSig arrays. If arrayTypeSig is not
251 * recognized by any factories a suitable display name will be placed in
252 * arrayName if bFindUnkown is true (otherwise arrayName will be empty).
253 */
254 static bool GetArraySigName(std::string &arrayName, icArraySignature arrayTypeSig, bool bFillUnknown=true)
255 { return CIccArrayCreator::GetInstance()->DoGetArraySigName(arrayName, arrayTypeSig, bFillUnknown); }
256
257
258 /**
259 * Function: GetArraySig(arrayName)
260 * Get signature associate with display name arrayName handler
261 *
262 * Parameter(s):
263 * arrayName = string to find signature for
264 *
265 * Returns array signuture if arrayName arrays are recognized by any factory, 0 if all
266 * factories do not create arrayName arrays.
267 */
268 static icArraySignature GetArraySig(const icChar* arrayName)
269 { return CIccArrayCreator::GetInstance()->DoGetArraySig(arrayName); }
270
271 /**
272 * Function: PushFactory(pFactory)
273 * Add an IIccArrayFactory to the stack of element factories tracked by
274 * the system.
275 *
276 * Parameter(s):
277 * pFactory = pointer to an IIccArrayFactory object to add to the
278 * system. The pFactory must be created with new, and will be owned
279 * CIccArrayCreator until popped off the stack using PopFactory().
280 * Any factories not popped off will be taken care of properly on
281 * application shutdown.
282 *
283 */
284 static void PushFactory(IIccArrayFactory *pFactory)
285 { CIccArrayCreator::GetInstance()->CIccArrayCreator::DoPushFactory(pFactory); }
286
287 /**
288 * Function: PopFactory()
289 * Remove the top IIccArrayFactory from the stack of element factories
290 * tracked by the system.
291 *
292 * Parameter(s):
293 * None
294 *
295 * Returns the top IIccArrayFactory from the stack of element factories
296 * tracked by the system. The returned element factory is no longer
297 * owned by the system and needs to be deleted to avoid memory leaks.
298 *
299 * Note: The initial CIccBasicElemFactory cannot be popped off the stack.
300 */
303
304private:
305 /**Only GetInstance() can create the singleton*/
307
308 /**
309 * Function: GetInstance()
310 * Private static function to access singleton CiccArrayCreator Object.
311 *
312 * Parameter(s):
313 * None
314 *
315 * Returns the singleton CIccArrayCreator object. It will allocate
316 * a new one and push a single CIccSpecArray Factory object onto the
317 * factory stack if the singleton has not been initialized.
318 */
319 static CIccArrayCreator* GetInstance();
320
321 IIccArray* DoCreateArray(icArraySignature arrayTypeSig, CIccTagArray *pArray);
322 bool DoGetArraySigName(std::string &arrayName, icArraySignature arrayTypeSig, bool bFillUnknown=true);
323 icArraySignature DoGetArraySig(const icChar *arrayName);
324 void DoPushFactory(IIccArrayFactory *pFactory);
325 IIccArrayFactory* DoPopFactory(bool bAll=false);
326
328
330};
331
332#ifdef USEREFICCMAXNAMESPACE
333} //namespace refIccMAX
334#endif
335
336#endif //_ICCSTRUCTFACTORY_H
std::unique_ptr< CIccArrayCreator > CIccArrayCreatorPtr
std::list< IIccArrayFactory * > CIccArrayFactoryList
File: IccDefs.h
char icChar
Definition IccDefs.h:109
#define ICCPROFLIB_API
Class: CIccArrayCreator.
bool DoGetArraySigName(std::string &arrayName, icArraySignature arrayTypeSig, bool bFillUnknown=true)
icArraySignature DoGetArraySig(const icChar *arrayName)
static void PushFactory(IIccArrayFactory *pFactory)
Function: PushFactory(pFactory) Add an IIccArrayFactory to the stack of element factories tracked by ...
CIccArrayCreator()
Only GetInstance() can create the singleton.
static CIccArrayCreatorPtr theArrayCreator
IIccArray * DoCreateArray(icArraySignature arrayTypeSig, CIccTagArray *pArray)
CIccArrayFactoryList factoryStack
IIccArrayFactory * DoPopFactory(bool bAll=false)
static CIccArrayCreator * GetInstance()
Function: GetInstance() Private static function to access singleton CiccArrayCreator Object.
static IIccArrayFactory * PopFactory()
Function: PopFactory() Remove the top IIccArrayFactory from the stack of element factories tracked by...
static IIccArray * CreateArray(icArraySignature arrayTypeSig, CIccTagArray *pTagArray=NULL)
Function: CreateArray(structTypeSig) Create a element of type structTypeSig.
static bool GetArraySigName(std::string &arrayName, icArraySignature arrayTypeSig, bool bFillUnknown=true)
Function: GetArraySigName(structTypeSig) Get display name of structTypeSig.
static icArraySignature GetArraySig(const icChar *arrayName)
Function: GetArraySig(arrayName) Get signature associate with display name arrayName handler.
Class: CIccBasicArrayFactory.
Class: CIccTagArray.
Class: IIccArrayFactory.
virtual IIccArray * CreateArray(icArraySignature arrayTypeSig, CIccTagArray *pTagArray=NULL)=0
Function: CreateArray(arrayTypeSig) Create a element of type arrayTypeSig.
virtual ~IIccArrayFactory()
virtual icArraySignature GetArraySig(const icChar *arrayName)=0
Function: GetArraySig(arrayName) Get signature associate with display name arrayName handler.
virtual bool GetArraySigName(std::string &arrayName, icArraySignature arrayTypeSig, bool bFillUnknown)=0
Function: GeArraySigName(structTypeSig) Get display name of arrayTypeSig.
Class: IIccArray.
icArraySignature
Tag Array type signatures.