SampleICC Main srcforge
Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

IccTagFactory.h

Go to the documentation of this file.
00001 
00012 /*
00013  * The ICC Software License, Version 0.1
00014  *
00015  *
00016  * Copyright (c) 2005 The International Color Consortium. All rights 
00017  * reserved.
00018  *
00019  * Redistribution and use in source and binary forms, with or without
00020  * modification, are permitted provided that the following conditions
00021  * are met:
00022  *
00023  * 1. Redistributions of source code must retain the above copyright
00024  *    notice, this list of conditions and the following disclaimer. 
00025  *
00026  * 2. Redistributions in binary form must reproduce the above copyright
00027  *    notice, this list of conditions and the following disclaimer in
00028  *    the documentation and/or other materials provided with the
00029  *    distribution.
00030  *
00031  * 3. The end-user documentation included with the redistribution,
00032  *    if any, must include the following acknowledgment:  
00033  *       "This product includes software developed by the
00034  *        The International Color Consortium (www.color.org)"
00035  *    Alternately, this acknowledgment may appear in the software itself,
00036  *    if and wherever such third-party acknowledgments normally appear.
00037  *
00038  * 4. In the absence of prior written permission, the names "ICC" and "The
00039  *    International Color Consortium" must not be used to imply that the
00040  *    ICC organization endorses or promotes products derived from this
00041  *    software.
00042  *
00043  *
00044  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00045  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00046  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00047  * DISCLAIMED.  IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
00048  * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00049  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00050  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00051  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00052  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00053  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00054  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00055  * SUCH DAMAGE.
00056  * ====================================================================
00057  *
00058  * This software consists of voluntary contributions made by many
00059  * individuals on behalf of the The International Color Consortium. 
00060  *
00061  *
00062  * Membership in the ICC is encouraged when this software is used for
00063  * commercial purposes. 
00064  *
00065  *  
00066  * For more information on The International Color Consortium, please
00067  * see <http://www.color.org/>.
00068  *  
00069  * 
00070  */
00071 
00073 // HISTORY:
00074 //
00075 // -Oct 30, 2005 
00076 //  A CIccTagCreator singleton class has been added to provide general
00077 //  support for dynamically creating tag classes using a tag signature.
00078 //  Prototype and private tag type support can be added to the system
00079 //  by pushing additional IIccTagFactory based objects to the 
00080 //  singleton CIccTagCreator object.
00081 //
00083 
00084 #ifndef _ICCTAGFACTORY_H
00085 #define _ICCTAGFACTORY_H
00086 
00087 #include "IccDefs.h"
00088 #include <memory>
00089 #include <list>
00090 #include <string>
00091 
00092 //CIccTag factory support
00093 #ifdef USESAMPLEICCNAMESPACE
00094 namespace sampleICC {
00095 #endif
00096 
00097 class CIccTag;
00098 
00108 class IIccTagFactory 
00109 {
00110 public:
00111   virtual ~IIccTagFactory() {}
00112 
00124   virtual CIccTag* CreateTag(icTagTypeSignature tagTypeSig)=0;
00125 
00136   virtual const icChar* GetTagSigName(icTagSignature tagSig)=0;
00137 
00148   virtual const icChar* GetTagTypeSigName(icTagTypeSignature tagTypeSig)=0;
00149 };
00150 
00151 
00152 //A CIccTagFactoryList is used by CIccTagCreator to keep track of tag
00153 //creation factories
00154 typedef std::list<IIccTagFactory*> CIccTagFactoryList;
00155 
00156 
00166 class CIccSpecTagFactory : public IIccTagFactory
00167 {
00168 public:
00179   virtual CIccTag* CreateTag(icTagTypeSignature tagSig);
00180 
00192   virtual const icChar* GetTagSigName(icTagSignature tagSig);
00193 
00205   virtual const icChar* GetTagTypeSigName(icTagTypeSignature tagTypeSig);
00206 };
00207 
00208 class CIccTagCreator;
00209 
00210 typedef std::auto_ptr<CIccTagCreator> CIccTagCreatorPtr;
00211 
00221 class CIccTagCreator 
00222 {
00223 public:
00224   ~CIccTagCreator();
00225 
00237   static CIccTag* CreateTag(icTagTypeSignature tagTypeSig)
00238       { return CIccTagCreator::GetInstance()->DoCreateTag(tagTypeSig); }
00239 
00250   static const icChar* GetTagSigName(icTagSignature tagTypeSig)
00251       { return CIccTagCreator::GetInstance()->DoGetTagSigName(tagTypeSig); }
00252 
00253 
00264   static const icChar* GetTagTypeSigName(icTagTypeSignature tagTypeSig)
00265       { return CIccTagCreator::GetInstance()->DoGetTagTypeSigName(tagTypeSig); }
00266 
00278   static void PushFactory(IIccTagFactory *pFactory)
00279       { CIccTagCreator::GetInstance()->CIccTagCreator::DoPushFactory(pFactory); }
00280 
00294   static IIccTagFactory* PopFactory()
00295       { return CIccTagCreator::GetInstance()->DoPopFactory(); }
00296 
00297 private:
00299   CIccTagCreator() { }
00300 
00312   static CIccTagCreator* GetInstance();
00313 
00314   CIccTag* DoCreateTag(icTagTypeSignature tagTypeSig);
00315   const icChar *DoGetTagSigName(icTagSignature tagSig);
00316   const icChar *DoGetTagTypeSigName(icTagTypeSignature tagTypeSig);
00317   void DoPushFactory(IIccTagFactory *pFactory);
00318   IIccTagFactory* DoPopFactory(bool bAll=false);
00319 
00320   static CIccTagCreatorPtr theTagCreator; 
00321 
00322   CIccTagFactoryList factoryStack;
00323 };
00324 
00325 #ifdef USESAMPLEICCNAMESPACE
00326 } //namespace sampleICC
00327 #endif
00328 
00329 #endif //_ICCTAGFACTORY_H

Generated on Tue Jun 26 17:51:43 2007 for IccProfLib by  doxygen 1.3.9.1