Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccMpeFactory.h
Go to the documentation of this file.
1/** @file
2 File: IccMpeFactory.h
3
4 Contains: Header for implementation of CIccMpeFactory 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// -Feb 4, 2006
69// A CIccMpeCreator singleton class has been added to provide general
70// support for dynamically creating element classes using a element signature.
71// Prototype and private element type support can be added to the system
72// by pushing additional IIccMpeFactory based objects to the
73// singleton CIccMpeCreator object.
74//
75// -Nov 6, 2006
76// Merged into release
77//
78//////////////////////////////////////////////////////////////////////
79
80#ifndef _ICCMPEFACTORY_H
81#define _ICCMPEFACTORY_H
82
83#include "IccDefs.h"
84#include <memory>
85#include <list>
86
87//CIccProcessElement factory support
88#ifdef USEREFICCMAXNAMESPACE
89namespace refIccMAX {
90#endif
91
93
94/**
95 ***********************************************************************
96 * Class: IIccMpeFactory
97 *
98 * Purpose:
99 * IIccMpeFactory is a factory pattern interface for CIccProcessElement
100 * creation.
101 * This class is pure virtual.
102 ***********************************************************************
103 */
105{
106public:
107 virtual ~IIccMpeFactory() {}
108
109 /**
110 * Function: CreateElement(elemTypeSig)
111 * Create a element of type elemTypeSig.
112 *
113 * Parameter(s):
114 * elemTypeSig = signature of the ICC element type for the element to
115 * be created
116 *
117 * Returns a new CIccProcessElement object of the given signature type.
118 * If the element factory doesn't support creation of elements of type
119 * elemTypeSig then it should return NULL.
120 */
122
123 /**
124 * Function: GetElementSigName(elemTypeSig)
125 * Get display name of elemTypeSig.
126 *
127 * Parameter(s):
128 * elemName = string to put element name into,
129 * elemTypeSig = signature of the ICC element type to get a name for
130 *
131 * Returns true if element type is recognized by the factory, false if
132 * the factory doesn't create elemTypeSig elements.
133 */
134 virtual bool GetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)=0;
135};
136
137
138//A CIccMpeFactoryList is used by CIccMpeCreator to keep track of element
139//creation factories
140typedef std::list<IIccMpeFactory*> CIccMpeFactoryList;
141
142
143/**
144 ***********************************************************************
145 * Class: CIccBasicMpeFactory
146 *
147 * Purpose:
148 * CIccBasicMpeFactory provides creation of CIccProcessElement's
149 * defined by the ICC profile specification. The CIccMpeCreator always
150 * creates a CIccBasicElemFactory.
151 ***********************************************************************
152 */
154{
155public:
156 /**
157 * Function: CreateElement(elemTypeSig)
158 * Create a element of type elemTypeSig.
159 *
160 * Parameter(s):
161 * elemTypeSig = signature of the ICC element type for the element to be created
162 *
163 * Returns a new CIccProcessElement object of the given signature type.
164 * Unrecognized elemTypeSig's will be created as a CIccProcessElementUnknown object.
165 */
166 virtual CIccMultiProcessElement* CreateElement(icElemTypeSignature elementSig);
167
168 /**
169 * Function: GetElementSigName(elemTypeSig)
170 * Get display name of elemTypeSig.
171 *
172 * Parameter(s):
173 * elemName = string to put element name into,
174 * elemTypeSig = signature of the ICC element type to get a name for
175 *
176 * Returns true if element type is recognized by the factory, false if the
177 * factory doesn't create elemTypeSig elements.
178 */
179 virtual bool GetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig);
180};
181
182class CIccMpeCreator;
183
184typedef std::unique_ptr<CIccMpeCreator> CIccMpeCreatorPtr;
185
186/**
187 ***********************************************************************
188 * Class: CIccMpeCreator
189 *
190 * Purpose:
191 * CIccMpeCreator uses a singleton pattern to provide dynamically
192 * upgradeable CIccProcessElement derived object creation based on
193 * element signature.
194 ***********************************************************************
195 */
197{
198public:
200
201 /**
202 * Function: CreateElement(elemTypeSig)
203 * Create a element of type elemTypeSig.
204 *
205 * Parameter(s):
206 * elemTypeSig = signature of the ICC element type for the element to
207 * be created
208 *
209 * Returns a new CIccProcessElement object of the given signature type.
210 * Each factory in the factoryStack is used until a factory supports the
211 * signature type.
212 */
215
216 /**
217 * Function: GetElementSigName(elemTypeSig)
218 * Get display name of elemTypeSig.
219 *
220 * Parameter(s):
221 * elemName = string to put element name into
222 * elemTypeSig = signature of the ICC element type to get a name for
223 *
224 * Returns true if element type is recognized by any factory, false if all
225 * factories do not create elemTypeSig elements. If element type is not
226 * recognized by any factories a suitable display name will be placed in
227 * elemName.
228 */
229 static bool GetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)
230 { return CIccMpeCreator::GetInstance()->DoGetElementSigName(elemName, elemTypeSig); }
231
232 /**
233 * Function: PushFactory(pFactory)
234 * Add an IIccMpeFactory to the stack of element factories tracked by
235 * the system.
236 *
237 * Parameter(s):
238 * pFactory = pointer to an IIccMpeFactory object to add to the
239 * system. The pFactory must be created with new, and will be owned
240 * CIccMpeCreator until popped off the stack using PopFactory().
241 * Any factories not popped off will be taken care of properly on
242 * application shutdown.
243 *
244 */
245 static void PushFactory(IIccMpeFactory *pFactory)
246 { CIccMpeCreator::GetInstance()->CIccMpeCreator::DoPushFactory(pFactory); }
247
248 /**
249 * Function: PopFactory()
250 * Remove the top IIccMpeFactory from the stack of element factories
251 * tracked by the system.
252 *
253 * Parameter(s):
254 * None
255 *
256 * Returns the top IIccMpeFactory from the stack of element factories
257 * tracked by the system. The returned element factory is no longer
258 * owned by the system and needs to be deleted to avoid memory leaks.
259 *
260 * Note: The initial CIccBasicElemFactory cannot be popped off the stack.
261 */
264
265private:
266 /**Only GetInstance() can create the singleton*/
268
269 /**
270 * Function: GetInstance()
271 * Private static function to access singleton CiccElementCreator Object.
272 *
273 * Parameter(s):
274 * None
275 *
276 * Returns the singleton CIccMpeCreator object. It will allocate
277 * a new one and push a single CIccSpecElement Factory object onto the
278 * factory stack if the singleton has not been intialized.
279 */
280 static CIccMpeCreator* GetInstance();
281
282 CIccMultiProcessElement* DoCreateElement(icElemTypeSignature elemTypeSig);
283 bool DoGetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig);
284 void DoPushFactory(IIccMpeFactory *pFactory);
285 IIccMpeFactory* DoPopFactory(bool bAll=false);
286
288
290};
291
292#ifdef USEREFICCMAXNAMESPACE
293} //namespace refIccMAX
294#endif
295
296#endif //_ICCMPEFACTORY_H
File: IccDefs.h
std::unique_ptr< CIccMpeCreator > CIccMpeCreatorPtr
std::list< IIccMpeFactory * > CIccMpeFactoryList
#define ICCPROFLIB_API
Class: CIccBasicMpeFactory.
Class: CIccMpeCreator.
IIccMpeFactory * DoPopFactory(bool bAll=false)
static void PushFactory(IIccMpeFactory *pFactory)
Function: PushFactory(pFactory) Add an IIccMpeFactory to the stack of element factories tracked by th...
CIccMultiProcessElement * DoCreateElement(icElemTypeSignature elemTypeSig)
static CIccMpeCreatorPtr theElementCreator
CIccMpeCreator()
Only GetInstance() can create the singleton.
CIccMpeFactoryList factoryStack
static CIccMultiProcessElement * CreateElement(icElemTypeSignature elemTypeSig)
Function: CreateElement(elemTypeSig) Create a element of type elemTypeSig.
static bool GetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)
Function: GetElementSigName(elemTypeSig) Get display name of elemTypeSig.
static IIccMpeFactory * PopFactory()
Function: PopFactory() Remove the top IIccMpeFactory from the stack of element factories tracked by t...
bool DoGetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)
static CIccMpeCreator * GetInstance()
Function: GetInstance() Private static function to access singleton CiccElementCreator Object.
Class: CIccMultiProcessElement.
Definition IccTagMPE.h:146
Class: IIccMpeFactory.
virtual ~IIccMpeFactory()
virtual CIccMultiProcessElement * CreateElement(icElemTypeSignature elemTypeSig)=0
Function: CreateElement(elemTypeSig) Create a element of type elemTypeSig.
virtual bool GetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)=0
Function: GetElementSigName(elemTypeSig) Get display name of elemTypeSig.
icElemTypeSignature
Multi-Processing Element type signatures.