Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccStructFactory.h
Go to the documentation of this file.
1/** @file
2 File: IccStructFactory.h
3
4 Contains: Header for implementation of CIccStructFactory 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// -Jun 10, 2011
69// A CIccStructCreator singleton class has been added to provide general
70// support for dynamically creating struct object classes using a signature.
71// Prototype and private struct type support can be added to the system
72// by pushing additional IIccStructFactory based objects to the
73// singleton CIccStructCreator object.
74//
75/////////////////////////////////////////////////////////////////////
76
77#ifndef _ICCSTRUCTFACTORY_H
78#define _ICCSTRUCTFACTORY_H
79
80#include "IccDefs.h"
81#include <memory>
82#include <list>
83
84//CIccProcessStruct factory support
85#ifdef USEREFICCMAXNAMESPACE
86namespace refIccMAX {
87#endif
88
89class IIccStruct;
90class CIccTagStruct;
91
92/**
93 ***********************************************************************
94 * Class: IIccStructFactory
95 *
96 * Purpose:
97 * IIccStructFactory is a factory pattern interface for CIccProcessStruct
98 * creation.
99 * This class is pure virtual.
100 ***********************************************************************
101 */
103{
104public:
106
107 /**
108 * Function: CreateStruct(structTypeSig)
109 * Create a element of type structTypeSig.
110 *
111 * Parameter(s):
112 * structTypeSig = signature of the ICC element type for the element to
113 * be created
114 *
115 * Returns a new IIStructObject object of the given signature type.
116 * If the element factory doesn't support creation of structs of type
117 * structTypeSig then it should return NULL.
118 */
119 virtual IIccStruct* CreateStruct(icStructSignature structTypeSig, CIccTagStruct *pTagStruct=NULL)=0;
120
121 /**
122 * Function: GeStructSigName(structTypeSig)
123 * Get display name of structTypeSig.
124 *
125 * Parameter(s):
126 * structName = string to put element name into,
127 * structTypeSig = signature of the ICC element type to get a name for
128 * bFindUnknown = flag to indicate structName should be filled with unknown_sig name, (empty if false)
129 *
130 * Returns true if struct type is recognized by the factory, false if
131 * the factory doesn't create structTypeSig elements.
132 */
133 virtual bool GetStructSigName(std::string &structName, icStructSignature structTypeSig, bool bFindUnknown)=0;
134
135 /**
136 * Function: GetStructSig(structName)
137 * Get signature of structure from display name.
138 *
139 * Parameter(s):
140 * structName = struct display name
141 *
142 * Returns signature of structure if it is recognized by the factory, 0 if the
143 * factory doesn't create structures with such a display name.
144 */
145 virtual icStructSignature GetStructSig(const icChar *structName)=0;
146};
147
148
149//A CIccStructFactoryList is used by CIccStructCreator to keep track of element
150//creation factories
151typedef std::list<IIccStructFactory*> CIccStructFactoryList;
152
153
154/**
155 ***********************************************************************
156 * Class: CIccBasicStructFactory
157 *
158 * Purpose:
159 * CIccBasicStructFactory provides creation of CIccProcessStruct's
160 * defined by the ICC profile specification. The CIccStructCreator always
161 * creates a CIccBasicElemFactory.
162 ***********************************************************************
163 */
165{
166public:
167 /**
168 * Function: CreateStruct(structTypeSig)
169 * Create a struct object of type structTypeSig.
170 *
171 * Parameter(s):
172 * structTypeSig = signature of the ICC struct type for the struct to be created
173 *
174 * Returns a new CIccProcessStruct object of the given signature type.
175 * Unrecognized structTypeSig's will be created as a CIccStructUnknown object.
176 */
177 virtual IIccStruct* CreateStruct(icStructSignature structSig, CIccTagStruct *pTagStruct=NULL);
178
179 /**
180 * Function: GetStructSigName(structTypeSig)
181 * Get display name of structTypeSig.
182 *
183 * Parameter(s):
184 * structName = string to put struct name into,
185 * structTypeSig = signature of the ICC struct type to get a name for
186 *
187 * Returns true if struct type is recognized by the factory, false if the
188 * factory doesn't create structTypeSig structs.
189 */
190 virtual bool GetStructSigName(std::string &structName, icStructSignature structTypeSig, bool bFindUnknown=false);
191
192 /**
193 * Function: GetStructSig(structName)
194 * Get signature of structure from display name.
195 *
196 * Parameter(s):
197 * structName = struct display name
198 *
199 * Returns signature of structure if it is recognized by the factory, 0 if the
200 * factory doesn't create structures with such a display name.
201 */
202 virtual icStructSignature GetStructSig(const icChar *structName);
203};
204
206
207typedef std::unique_ptr<CIccStructCreator> CIccStructCreatorPtr;
208
209/**
210 ***********************************************************************
211 * Class: CIccStructCreator
212 *
213 * Purpose:
214 * CIccStructCreator uses a singleton pattern to provide dynamically
215 * upgradeable IIccStructObject derived object creation based on
216 * element signature.
217 ***********************************************************************
218 */
220{
221public:
223
224 /**
225 * Function: CreateStruct(structTypeSig)
226 * Create a element of type structTypeSig.
227 *
228 * Parameter(s):
229 * structTypeSig = signature of the ICC element type for the element to
230 * be created
231 *
232 * Returns a new CIccProcessStruct object of the given signature type.
233 * Each factory in the factoryStack is used until a factory supports the
234 * signature type.
235 */
236 static IIccStruct* CreateStruct(icStructSignature structTypeSig, CIccTagStruct *pTagStruct)
237 { return CIccStructCreator::GetInstance()->DoCreateStruct(structTypeSig, pTagStruct); }
238
239 /**
240 * Function: GetStructSigName(structTypeSig)
241 * Get display name of structTypeSig.
242 *
243 * Parameter(s):
244 * structName = string to put struct name into
245 * structTypeSig = signature of the ICC struct type to get a name for
246 * bFillUnknown = flag to indicate structName is filled if not found
247 *
248 * Returns true if struct type is recognized by any factory, false if all
249 * factories do not create structTypeSig structs. If struct type is not
250 * recognized by any factories a suitable display name will be placed in
251 * structName if bFillUknown is true.
252 */
253 static bool GetStructSigName(std::string &structName, icStructSignature structTypeSig, bool bFillUnknown=true)
254 { return CIccStructCreator::GetInstance()->DoGetStructSigName(structName, structTypeSig, bFillUnknown); }
255
256 /**
257 * Function: GetStructSig(structName)
258 * Get signature of structure from display name.
259 *
260 * Parameter(s):
261 * structName = struct display name
262 *
263 * Returns signature of structure if it is recognized by any factory, 0 if the
264 * all the factories don't create a structure with such a display name.
265 */
266 static icStructSignature GetStructSig(const icChar *structName)
267 {
269 }
270
271 /**
272 * Function: PushFactory(pFactory)
273 * Add an IIccStructFactory to the stack of element factories tracked by
274 * the system.
275 *
276 * Parameter(s):
277 * pFactory = pointer to an IIccStructFactory object to add to the
278 * system. The pFactory must be created with new, and will be owned
279 * CIccStructCreator 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(IIccStructFactory *pFactory)
285 { CIccStructCreator::GetInstance()->CIccStructCreator::DoPushFactory(pFactory); }
286
287 /**
288 * Function: PopFactory()
289 * Remove the top IIccStructFactory from the stack of element factories
290 * tracked by the system.
291 *
292 * Parameter(s):
293 * None
294 *
295 * Returns the top IIccStructFactory 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 CiccStructCreator Object.
311 *
312 * Parameter(s):
313 * None
314 *
315 * Returns the singleton CIccStructCreator object. It will allocate
316 * a new one and push a single CIccSpecStruct Factory object onto the
317 * factory stack if the singleton has not been intialized.
318 */
319 static CIccStructCreator* GetInstance();
320
321 IIccStruct* DoCreateStruct(icStructSignature structTypeSig, CIccTagStruct *pTagStruct=NULL);
322 bool DoGetStructSigName(std::string &structName, icStructSignature structTypeSig, bool bFillUnknown=true);
323 icStructSignature DoGetStructSig(const char *structName);
324 void DoPushFactory(IIccStructFactory *pFactory);
325 IIccStructFactory* DoPopFactory(bool bAll=false);
326
328
330};
331
332#ifdef USEREFICCMAXNAMESPACE
333} //namespace refIccMAX
334#endif
335
336#endif //_ICCSTRUCTFACTORY_H
File: IccDefs.h
char icChar
Definition IccDefs.h:109
#define ICCPROFLIB_API
std::unique_ptr< CIccStructCreator > CIccStructCreatorPtr
std::list< IIccStructFactory * > CIccStructFactoryList
Class: CIccBasicStructFactory.
Class: CIccStructCreator.
static bool GetStructSigName(std::string &structName, icStructSignature structTypeSig, bool bFillUnknown=true)
Function: GetStructSigName(structTypeSig) Get display name of structTypeSig.
IIccStructFactory * DoPopFactory(bool bAll=false)
CIccStructCreator()
Only GetInstance() can create the singleton.
static CIccStructCreator * GetInstance()
Function: GetInstance() Private static function to access singleton CiccStructCreator Object.
static CIccStructCreatorPtr theStructCreator
static icStructSignature GetStructSig(const icChar *structName)
Function: GetStructSig(structName) Get signature of structure from display name.
icStructSignature DoGetStructSig(const char *structName)
static IIccStruct * CreateStruct(icStructSignature structTypeSig, CIccTagStruct *pTagStruct)
Function: CreateStruct(structTypeSig) Create a element of type structTypeSig.
CIccStructFactoryList factoryStack
IIccStruct * DoCreateStruct(icStructSignature structTypeSig, CIccTagStruct *pTagStruct=NULL)
bool DoGetStructSigName(std::string &structName, icStructSignature structTypeSig, bool bFillUnknown=true)
static void PushFactory(IIccStructFactory *pFactory)
Function: PushFactory(pFactory) Add an IIccStructFactory to the stack of element factories tracked by...
static IIccStructFactory * PopFactory()
Function: PopFactory() Remove the top IIccStructFactory from the stack of element factories tracked b...
Class: CIccTagStruct.
Class: IIccStructFactory.
virtual IIccStruct * CreateStruct(icStructSignature structTypeSig, CIccTagStruct *pTagStruct=NULL)=0
Function: CreateStruct(structTypeSig) Create a element of type structTypeSig.
virtual icStructSignature GetStructSig(const icChar *structName)=0
Function: GetStructSig(structName) Get signature of structure from display name.
virtual bool GetStructSigName(std::string &structName, icStructSignature structTypeSig, bool bFindUnknown)=0
Function: GeStructSigName(structTypeSig) Get display name of structTypeSig.
Class: IIccStruct.
icStructSignature
Tag Structure type signatures.