Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccTagFactory.h
Go to the documentation of this file.
1/** @file
2 File: IccTagFactory.h
3
4 Contains: Header for implementation of CIccTagFactory 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) 2005 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// -Oct 30, 2005
69// A CIccTagCreator singleton class has been added to provide general
70// support for dynamically creating tag classes using a tag signature.
71// Prototype and private tag type support can be added to the system
72// by pushing additional IIccTagFactory based objects to the
73// singleton CIccTagCreator object.
74//
75//////////////////////////////////////////////////////////////////////
76
77#ifndef _ICCTAGFACTORY_H
78#define _ICCTAGFACTORY_H
79
80#include "IccDefs.h"
81#include <memory>
82#include <list>
83#include <string>
84
85//CIccTag factory support
86#ifdef USEREFICCMAXNAMESPACE
87namespace refIccMAX {
88#endif
89
90class CIccTag;
91
92/**
93 ***********************************************************************
94 * Class: IIccTagFactory
95 *
96 * Purpose:
97 * IIccTagFactory is a factory pattern interface for CIccTag creation.
98 * This class is pure virtual.
99 ***********************************************************************
100 */
102{
103public:
104 virtual ~IIccTagFactory() {}
105
106 /**
107 * Function: CreateTag(tagTypeSig)
108 * Create a tag of type tagTypeSig.
109 *
110 * Parameter(s):
111 * tagTypeSig = signature of the ICC tag type for the tag to be created
112 *
113 * Returns a new CIccTag object of the given signature type. If the tag
114 * factory doesn't support creation of tags of type tagTypeSig then it
115 * should return NULL.
116 */
117 virtual CIccTag* CreateTag(icTagTypeSignature tagTypeSig)=0;
118
119 /**
120 * Function: GetTagSigName(tagSig)
121 * Get display name of tagSig.
122 *
123 * Parameter(s):
124 * tagSig = signature of the ICC tag to get a name for
125 *
126 * Returns pointer to string containing name of tag if tag is recognized
127 * by the factory, NULL if the factory doesn't create tagSig tags.
128 */
129 virtual const icChar* GetTagSigName(icTagSignature tagSig)=0;
130
131 /**
132 * Function: GetTagNameSig(szTagName)
133 * Get signature from tag display name.
134 *
135 * Parameter(s):
136 * szTagName = name of tag
137 *
138 * Returns tag signature of tag if tag name is recognized
139 * by the factory, icSigUnknownTag if the tag name is not recognized.
140 */
141 virtual icTagSignature GetTagNameSig(const icChar *szTagName) = 0;
142
143 /**
144 * Function: GetTagTypeSigName(tagTypeSig)
145 * Get display name of tagTypeSig.
146 *
147 * Parameter(s):
148 * tagTypeSig = signature of the ICC tag type to get a name for
149 *
150 * Returns pointer to string containing name of tag type if tag is recognized
151 * by the factory, NULL if the factory doesn't create tagTypeSig tags.
152 */
153 virtual const icChar* GetTagTypeSigName(icTagTypeSignature tagTypeSig)=0;
154
155 /**
156 * Function: GetTagTypeNameSig(szTypeName)
157 * Get signature based on display name of tag type.
158 *
159 * Parameter(s):
160 * szTypeName = name of the ICC tag type to get a signature for
161 *
162 * Returns tag type signature of tag type name if type name is recognized
163 * by the factory, icSigUnknownType if the type name is not recognized.
164 */
165 virtual icTagTypeSignature GetTagTypeNameSig(const icChar* szTypeName) = 0;
166
167};
168
169
170//A CIccTagFactoryList is used by CIccTagCreator to keep track of tag
171//creation factories
172typedef std::list<IIccTagFactory*> CIccTagFactoryList;
173
174
175/**
176 ***********************************************************************
177 * Class: CIccSpecTagFactory
178 *
179 * Purpose:
180 * CIccSpecTagFactory provides creation of CIccTag's defined by the ICC profile
181 * specification. The CIccTagCreator always creates a CIccSpecTagFactory.
182 ***********************************************************************
183 */
185{
186public:
187 /**
188 * Function: CreateTag(tagTypeSig)
189 * Create a tag of type tagTypeSig.
190 *
191 * Parameter(s):
192 * tagTypeSig = signature of the ICC tag type for the tag to be created
193 *
194 * Returns a new CIccTag object of the given signature type.
195 * Unrecognized tagTypeSig's will be created as a CIccTagUnknown object.
196 */
197 virtual CIccTag* CreateTag(icTagTypeSignature tagSig);
198
199 /**
200 * Function: GetTagSigName(tagSig)
201 * Get display name of tagSig.
202 *
203 * Parameter(s):
204 * tagName = string to put tag name into,
205 * tagSig = signature of the ICC tag type to get a name for
206 *
207 * Returns pointer to string containing name of tag if tag is recognized
208 * by the factory, NULL if the factory doesn't create tagSig tags.
209 */
210 virtual const icChar* GetTagSigName(icTagSignature tagSig);
211
212 /**
213 * Function: GetTagNameSig(szTagName)
214 * Get signature from tag display name.
215 *
216 * Parameter(s):
217 * szTagName = name of tag
218 *
219 * Returns tag signature of tag if tag name is recognized
220 * by the factory, icSigUnknownTag if the tag name is not recognized.
221 */
222 virtual icTagSignature GetTagNameSig(const icChar *szTagName);
223
224 /**
225 * Function: GetTagTypeSigName(tagTypeSig)
226 * Get display name of tagTypeSig.
227 *
228 * Parameter(s):
229 * tagName = string to put tag name into,
230 * tagTypeSig = signature of the ICC tag type to get a name for
231 *
232 * Returns pointer to string containing name of tag type if tag is recognized
233 * by the factory, NULL if the factory doesn't create tagTypeSig tags.
234 */
235 virtual const icChar* GetTagTypeSigName(icTagTypeSignature tagTypeSig);
236
237 /**
238 * Function: GetTagTypeNameSig(szTypeName)
239 * Get signature based on display name of tag type.
240 *
241 * Parameter(s):
242 * szTypeName = name of the ICC tag type to get a signature for
243 *
244 * Returns tag type signature of tag type name if type name is recognized
245 * by the factory, icSigUnknownType if the type name is not recognized.
246 */
247 virtual icTagTypeSignature GetTagTypeNameSig(const icChar* szTypeName);
248};
249
250class CIccTagCreator;
251
252typedef std::unique_ptr<CIccTagCreator> CIccTagCreatorPtr;
253
254/**
255 ***********************************************************************
256 * Class: CIccTagCreator
257 *
258 * Purpose:
259 * CIccTagCreator uses a singleton pattern to provide dynamically
260 * upgradeable CIccTag derived object creation based on tag signature.
261 ***********************************************************************
262 */
264{
265public:
267
268 /**
269 * Function: CreateTag(tagTypeSig)
270 * Create a tag of type tagTypeSig.
271 *
272 * Parameter(s):
273 * tagTypeSig = signature of the ICC tag type for the tag to be created
274 *
275 * Returns a new CIccTag object of the given signature type.
276 * Each factory in the factoryStack is used until a factory supports the
277 * signature type.
278 */
280 { return CIccTagCreator::GetInstance()->DoCreateTag(tagTypeSig); }
281
282 /**
283 * Function: GetTagSigName(tagSig)
284 * Get display name of tagSig.
285 *
286 * Parameter(s):
287 * tagSig = signature of the ICC tag to get a name for
288 *
289 * Returns ptr to string containing name of tag type if it is recognized
290 * by any factory, NULL if all factories do not create tagTypeSig tags.
291 */
292 static const icChar* GetTagSigName(icTagSignature tagTypeSig)
293 { return CIccTagCreator::GetInstance()->DoGetTagSigName(tagTypeSig); }
294
295
296 /**
297 * Function: GetTagNameSig(szTagName)
298 * Get signature from tag display name.
299 *
300 * Parameter(s):
301 * szTagName = name of tag
302 *
303 * Returns tag signature of tag if tag name is recognized
304 * by the factory, icSigUnknownTag if the tag name is not recognized.
305 */
310
311
312 /**
313 * Function: GetTagTypeSigName(tagTypeSig)
314 * Get display name of tagTypeSig.
315 *
316 * Parameter(s):
317 * tagTypeSig = signature of the ICC tag type to get a name for
318 *
319 * Returns ptr to string containing name of tag type if it is recognized by
320 * any factory, NULL if all factories do not create tagTypeSig tags.
321 */
323 { return CIccTagCreator::GetInstance()->DoGetTagTypeSigName(tagTypeSig); }
324
325 /**
326 * Function: GetTagTypeNameSig(szTypeName)
327 * Get signature based on display name of tag type.
328 *
329 * Parameter(s):
330 * szTypeName = name of the ICC tag type to get a signature for
331 *
332 * Returns tag type signature of tag type name if type name is recognized
333 * by the factory, icSigUnknownType if the type name is not recognized.
334 */
339
340 /**
341 * Function: PushFactory(pFactory)
342 * Add an IIccTagFactory to the stack of tag factories tracked by the system.
343 *
344 * Parameter(s):
345 * pFactory = pointer to an IIccTagFactory object to add to the system.
346 * The pFactory must be created with new, and will be owned CIccTagCreator
347 * until popped off the stack using PopFactory(). Any factories not
348 * popped off will be taken care of properly on application shutdown.
349 *
350 */
351 static void PushFactory(IIccTagFactory *pFactory)
352 { CIccTagCreator::GetInstance()->CIccTagCreator::DoPushFactory(pFactory); }
353
354 /**
355 * Function: PopFactory()
356 * Remove the top IIccTagFactory from the stack of tag factories tracked by the system.
357 *
358 * Parameter(s):
359 * None
360 *
361 * Returns the top IIccTagFactory from the stack of tag factories tracked by the system.
362 * The returned tag factory is no longer owned by the system and needs to be deleted
363 * to avoid memory leaks.
364 *
365 * Note: The initial CIccSpecTagFactory cannot be popped off the stack.
366 */
369
370private:
371 /**Only GetInstance() can create the signleton*/
373
374 /**
375 * Function: GetInstance()
376 * Private static function to access singleton CiccTagCreator Object.
377 *
378 * Parameter(s):
379 * None
380 *
381 * Returns the singleton CIccTagCreator object. It will allocate
382 * a new one and push a single CIccSpecTag Factory object onto the factory
383 * stack if the singleton has not been intialized.
384 */
385 static CIccTagCreator* GetInstance();
386
387 CIccTag* DoCreateTag(icTagTypeSignature tagTypeSig);
388 const icChar *DoGetTagSigName(icTagSignature tagSig);
389 icTagSignature DoGetTagNameSig(const icChar *szName);
390 const icChar *DoGetTagTypeSigName(icTagTypeSignature tagTypeSig);
391 icTagTypeSignature DoGetTagTypeNameSig(const icChar *szName);
392 void DoPushFactory(IIccTagFactory *pFactory);
393 IIccTagFactory* DoPopFactory(bool bAll=false);
394
396
398};
399
400#ifdef USEREFICCMAXNAMESPACE
401} //namespace refIccMAX
402#endif
403
404#endif //_ICCTAGFACTORY_H
File: IccDefs.h
char icChar
Definition IccDefs.h:109
const icChar * szName
std::unique_ptr< CIccTagCreator > CIccTagCreatorPtr
std::list< IIccTagFactory * > CIccTagFactoryList
icTagTypeSignature
Class: CIccSpecTagFactory.
Class: CIccTagCreator.
static IIccTagFactory * PopFactory()
Function: PopFactory() Remove the top IIccTagFactory from the stack of tag factories tracked by the s...
icTagSignature DoGetTagNameSig(const icChar *szName)
static CIccTag * CreateTag(icTagTypeSignature tagTypeSig)
Function: CreateTag(tagTypeSig) Create a tag of type tagTypeSig.
icTagTypeSignature DoGetTagTypeNameSig(const icChar *szName)
static CIccTagCreatorPtr theTagCreator
IIccTagFactory * DoPopFactory(bool bAll=false)
static icTagTypeSignature GetTagTypeNameSig(const icChar *szName)
Function: GetTagTypeNameSig(szTypeName) Get signature based on display name of tag type.
CIccTagFactoryList factoryStack
static const icChar * GetTagSigName(icTagSignature tagTypeSig)
Function: GetTagSigName(tagSig) Get display name of tagSig.
static CIccTagCreator * GetInstance()
Function: GetInstance() Private static function to access singleton CiccTagCreator Object.
const icChar * DoGetTagSigName(icTagSignature tagSig)
static icTagSignature GetTagNameSig(const icChar *szName)
Function: GetTagNameSig(szTagName) Get signature from tag display name.
CIccTagCreator()
Only GetInstance() can create the signleton.
static const icChar * GetTagTypeSigName(icTagTypeSignature tagTypeSig)
Function: GetTagTypeSigName(tagTypeSig) Get display name of tagTypeSig.
const icChar * DoGetTagTypeSigName(icTagTypeSignature tagTypeSig)
static void PushFactory(IIccTagFactory *pFactory)
Function: PushFactory(pFactory) Add an IIccTagFactory to the stack of tag factories tracked by the sy...
CIccTag * DoCreateTag(icTagTypeSignature tagTypeSig)
Class: CIccTag.
Class: IIccTagFactory.
virtual CIccTag * CreateTag(icTagTypeSignature tagTypeSig)=0
Function: CreateTag(tagTypeSig) Create a tag of type tagTypeSig.
virtual ~IIccTagFactory()
virtual const icChar * GetTagTypeSigName(icTagTypeSignature tagTypeSig)=0
Function: GetTagTypeSigName(tagTypeSig) Get display name of tagTypeSig.
virtual icTagSignature GetTagNameSig(const icChar *szTagName)=0
Function: GetTagNameSig(szTagName) Get signature from tag display name.
virtual const icChar * GetTagSigName(icTagSignature tagSig)=0
Function: GetTagSigName(tagSig) Get display name of tagSig.
virtual icTagTypeSignature GetTagTypeNameSig(const icChar *szTypeName)=0
Function: GetTagTypeNameSig(szTypeName) Get signature based on display name of tag type.
icTagSignature
public tags and sizes