00001 // ***************************************************************************** 00002 // ***************************************************************************** 00003 // oaCommonFactory.h 00004 // 00005 // This file contains the definition of the Factory and FactoryBase classes. The 00006 // Factory class is used to implement the getClassObject entry function for 00007 // components. This implementation is hidden inside a shared library. The 00008 // FactoryBase class is the base class for the Factory class and it contains the 00009 // table of all existing Factory template instances. 00010 // 00011 // ***************************************************************************** 00012 // Except as specified in the OpenAccess terms of use of Cadence or Silicon 00013 // Integration Initiative, this material may not be copied, modified, 00014 // re-published, uploaded, executed, or distributed in any way, in any medium, 00015 // in whole or in part, without prior written permission from Cadence. 00016 // 00017 // Copyright 2002-2005 Cadence Design Systems, Inc. 00018 // All Rights Reserved. 00019 // 00020 // $Author: icftcm $ 00021 // $Revision: #1 $ 00022 // $Date: 2010/08/09 $ 00023 // $State: Exp $ 00024 // ***************************************************************************** 00025 // ***************************************************************************** 00026 00027 00028 00029 #if !defined(oaCommonFactory_P) 00030 #define oaCommonFactory_P 00031 00032 00033 00034 // ***************************************************************************** 00035 // Nested includes 00036 // ***************************************************************************** 00037 #include "oaCommonIBase.h" 00038 00039 00040 00041 // ***************************************************************************** 00042 // Declare and define types in the oaCommon namespace 00043 // ***************************************************************************** 00044 BEGIN_OA_COMMON_NAMESPACE 00045 00046 00047 00048 // ***************************************************************************** 00049 // Forward declare 00050 // ***************************************************************************** 00051 class FactoryBaseMap; 00052 00053 00054 00055 // ***************************************************************************** 00056 // FactoryBase 00057 // ***************************************************************************** 00058 class OA_COMMON_DLL_PVT FactoryBase : public IFactory { 00059 public: 00060 virtual long queryInterface(const Guid &idIn, 00061 void **iPtr); 00062 virtual unsigned long addRef(); 00063 virtual unsigned long release(); 00064 00065 static oa::oaUInt4 getClassObject(const char *classID, 00066 const Guid &interfaceID, 00067 void **ptr); 00068 00069 protected: 00070 FactoryBase(); 00071 00072 static void insertFactory(const char *classID, 00073 FactoryBase *factory); 00074 static void eraseFactory(FactoryBase *factory); 00075 00076 private: 00077 oa::oaUInt4 refCount; 00078 00079 static FactoryBaseMap *factories; 00080 }; 00081 00082 00083 00084 // ***************************************************************************** 00085 // Factory 00086 // ***************************************************************************** 00087 template<class T> 00088 class Factory : public FactoryBase { 00089 public: 00090 Factory(const char *classID); 00091 00092 oa::oaUInt4 createInstance(IBase *reserved, 00093 const Guid &interfaceID, 00094 void **ptr); 00095 ~Factory(); 00096 }; 00097 00098 00099 00100 END_OA_COMMON_NAMESPACE 00101 00102 #endif
Copyright © 2002 - 2010 Cadence Design Systems, Inc.
All Rights Reserved.