00001 // ***************************************************************************** 00002 // ***************************************************************************** 00003 // oaCommonIBase.h 00004 // 00005 // This file contains the definition for base interface class. 00006 // 00007 // IBase 00008 // This is the base class for the interface classes. 00009 // 00010 // IFactory 00011 // This is the abstract factory. This factory is implemented by the plug-in 00012 // and is used to create instances of the interface objects as needed. 00013 // 00014 // IException 00015 // This is an abstract class which can be used by the plug-in 00016 // implementation to pass an exception back to the application side. 00017 // 00018 // IString 00019 // This is a simple string interface. 00020 // 00021 // IIter 00022 // This is a templated abstract class used to iterate generic collections. 00023 // The template parameter determines the type of object being served from 00024 // the iterator. Typically, a typedef will be used to define a specific 00025 // expansion of the interface, followed by a declaration of that 00026 // expansion's interface id (the template doesn't have an id, since it 00027 // doesn't define a specific expansion of the interface). For Example: 00028 // 00029 // typedef IIter<IBase*> IBaseIter; 00030 // extern OA_COMMON_DLL_API const Guid IID_IBaseIter; 00031 // 00032 // defines the specific expansion and interface id of an iterator for the 00033 // IBase interface pointer. 00034 // 00035 // The implementor of an iterator based on an expansion of IIter can use 00036 // any appropriate collection class as long as it can be accessed using an 00037 // "iterator" or "enumerator" pattern. 00038 // For example, if the following interfaces are defined: 00039 // 00040 // class IFoo : public IBase { 00041 // void doStuff() = 0; 00042 // }; 00043 // extern OA_COMMON_DLL_API const Guid IID_IFoo; 00044 // 00045 // typedef IIter<IFoo*> IFooIter; 00046 // extern OA_COMMON_DLL_API const Guid IID_IFooIter; 00047 // 00048 // Then an example of client code using this interface would be: 00049 // 00050 // IFooIter *it = someContainer->getItems(); 00051 // IFoo *obj; 00052 // while (it->next(obj)) { 00053 // obj->doStuff(); 00054 // obj->release(); 00055 // } 00056 // 00057 // ISequence 00058 // This is a templated abstract class that extends the funtionality found 00059 // on the IIter to add the ability to modify the underlying collection. 00060 // These functions all operate relative to the "current" element. That is, 00061 // "insert" will insert an elememt before the current elememt while 00062 // "append" inserts it *after* the current element. The "remove" method 00063 // will remove the current element from the collection (and set the 00064 // "current" element to the previous element - so that calling "next" will 00065 // have the effect of going to the element that would have been next if 00066 // "remove" hadn't been called. The "replace" function will replace the 00067 // current element with the one passed in. The partial specialization of 00068 // ISequence is purly an optimization so that sequences of pointers (such 00069 // as interface pointers, which will likely represent the bulk of usage) 00070 // will be passed in as "Type *" rather than "const Type *&". 00071 // The template considerations work identially to the IIter as described 00072 // above. 00073 // 00074 // IBaseIter 00075 // This is a particular expansion of the IIter interface to iterate 00076 // pointers to components via their IBase interfaces. 00077 // 00078 // IBaseSequence 00079 // This is a particular expansion of the ISequence interface to handle 00080 // pointers to components via their IBase interfaces. 00081 // 00082 // ISecureStringCopy 00083 // This is a class used to provide a secure string copy. 00084 // ***************************************************************************** 00085 // Except as specified in the OpenAccess terms of use of Cadence or Silicon 00086 // Integration Initiative, this material may not be copied, modified, 00087 // re-published, uploaded, executed, or distributed in any way, in any medium, 00088 // in whole or in part, without prior written permission from Cadence. 00089 // 00090 // Copyright 2002-2009 Cadence Design Systems, Inc. 00091 // All Rights Reserved. 00092 // 00093 // $Author: icftcm $ 00094 // $Revision: #1 $ 00095 // $Date: 2010/08/09 $ 00096 // $State: Exp $ 00097 // ***************************************************************************** 00098 // ***************************************************************************** 00099 00100 00101 00102 #if !defined(oaCommonIBase_P) 00103 #define oaCommonIBase_P 00104 00105 00106 00107 // ***************************************************************************** 00108 // Nested includes 00109 // ***************************************************************************** 00110 #include "oaCommonTypes.h" 00111 00112 00113 // ***************************************************************************** 00114 // Declare and define types in the oaCommon namespace 00115 // ***************************************************************************** 00116 BEGIN_OA_COMMON_NAMESPACE 00117 00118 USE_OA_NAMESPACE 00119 00120 // ***************************************************************************** 00121 // IBase 00122 // ***************************************************************************** 00123 extern OA_COMMON_DLL_API const Guid IID_IBase; 00124 00125 class OA_COMMON_DLL_API IBase { 00126 public: 00127 enum Status { 00128 cOK = 0, 00129 cFail = 1, 00130 cNoInterface = 2, 00131 cNotFound = 3, 00132 cLibraryNotFound = 4, 00133 cSymbolNotFound = 5, 00134 cNotImplemented = 6, 00135 cOutOfMemory = 7, 00136 cInvalidArg = 8, 00137 cNoAggregation = 9, 00138 cErrorInRegFile = 10, 00139 cClassNotRegistered = 11, 00140 cIncompatible = 12 00141 }; 00142 00143 00144 virtual long queryInterface(const Guid &id, 00145 void **iPtr) = 0; 00146 virtual unsigned long addRef() = 0; 00147 virtual unsigned long release() = 0; 00148 00149 static const Guid &getId(); 00150 00151 static bool s_refCountDisabled; 00152 }; 00153 00154 00155 00156 // ***************************************************************************** 00157 // IFactory 00158 // ***************************************************************************** 00159 extern OA_COMMON_DLL_API const Guid IID_IFactory; 00160 00161 class OA_COMMON_DLL_API IFactory : public IBase { 00162 public: 00163 virtual oa::oaUInt4 createInstance(IBase *reserved, 00164 const Guid &id, 00165 void **iPtr) = 0; 00166 00167 static const Guid &getId(); 00168 }; 00169 00170 00171 00172 // ***************************************************************************** 00173 // ICompatiblity 00174 // ***************************************************************************** 00175 extern OA_COMMON_DLL_API const Guid IID_ICompatibility; 00176 00177 class OA_COMMON_DLL_API ICompatibility : public IBase { 00178 public: 00179 virtual bool validate() = 0; 00180 00181 static const Guid &getId(); 00182 }; 00183 00184 00185 00186 // ***************************************************************************** 00187 // IException 00188 // ***************************************************************************** 00189 class OA_COMMON_DLL_API IException { 00190 public: 00191 virtual oa::oaUInt4 getMsgId() const = 0; 00192 virtual const char *getMsg() const = 0; 00193 }; 00194 00195 00196 00197 // ***************************************************************************** 00198 // IPlugInException 00199 // ***************************************************************************** 00200 class OA_COMMON_DLL_API IPlugInException : public IException { 00201 public: 00202 virtual oa::oaUInt4 getStatus() const = 0; 00203 }; 00204 00205 00206 00207 // ***************************************************************************** 00208 // IString 00209 // ***************************************************************************** 00210 extern OA_COMMON_DLL_API const Guid IID_IString; 00211 00212 class OA_COMMON_DLL_API IString : public IBase { 00213 public: 00214 virtual const char *str() = 0; 00215 00216 static const Guid &getId(); 00217 }; 00218 00219 00220 00221 // ***************************************************************************** 00222 // IIter 00223 // ***************************************************************************** 00224 template<class T, const Guid *G> 00225 class IIter : public IBase { 00226 public: 00227 typedef T Type; 00228 typedef T IType; 00229 00230 virtual bool next(T &objOut) = 0; 00231 virtual void reset() = 0; 00232 00233 static const Guid &getId(); 00234 }; 00235 00236 00237 00238 // ***************************************************************************** 00239 // IIter 00240 // ***************************************************************************** 00241 template<class T, const Guid *G> 00242 class IIter<T*, G> : public IBase { 00243 public: 00244 typedef T *Type; 00245 typedef T IType; 00246 00247 virtual bool next(T *&objOut) = 0; 00248 virtual void reset() = 0; 00249 00250 static const Guid &getId(); 00251 }; 00252 00253 00254 00255 // ***************************************************************************** 00256 // ISequence 00257 // ***************************************************************************** 00258 template<class T, const Guid *SeqId, const Guid *IterId> 00259 class ISequence : public IIter<T, IterId> { 00260 public: 00261 typedef T SType; 00262 00263 virtual oa::oaUInt4 count() = 0; 00264 virtual void insert(const T &objIn) = 0; 00265 virtual void append(const T &objIn) = 0; 00266 virtual void remove() = 0; 00267 virtual void replace(const T &objIn) = 0; 00268 00269 static const Guid &getId(); 00270 }; 00271 00272 00273 00274 // ***************************************************************************** 00275 // ISequence 00276 // ***************************************************************************** 00277 template<class T, const Guid *SeqId, const Guid *IterId> 00278 class ISequence<T*, SeqId, IterId> : public IIter<T*, IterId> { 00279 public: 00280 typedef T SType; 00281 00282 virtual oa::oaUInt4 count() = 0; 00283 virtual void insert(T *objIn) = 0; 00284 virtual void append(T *objIn) = 0; 00285 virtual void remove() = 0; 00286 virtual void replace(T *objIn) = 0; 00287 00288 static const Guid &getId(); 00289 }; 00290 00291 00292 00293 // ***************************************************************************** 00294 // IBaseIter 00295 // ***************************************************************************** 00296 extern OA_COMMON_DLL_API const Guid IID_IBaseIter; 00297 typedef IIter<IBase*, &IID_IBaseIter> IBaseIter; 00298 00299 00300 00301 // ***************************************************************************** 00302 // IBaseSequence 00303 // ***************************************************************************** 00304 extern OA_COMMON_DLL_API const Guid IID_IBaseSequence; 00305 typedef ISequence<IBase*, &IID_IBaseSequence, &IID_IBaseIter> IBaseSequence; 00306 00307 00308 00309 // ***************************************************************************** 00310 // ISecureStringCopy 00311 // ***************************************************************************** 00312 class OA_COMMON_DLL_API ISecureStringCopy { 00313 public: 00314 static void copy(oaChar *strDest, 00315 const oaChar *strSrc, 00316 oaUInt4 maxLength); 00317 00318 }; 00319 00320 00321 00322 END_OA_COMMON_NAMESPACE 00323 00324 #endif
Copyright © 2002 - 2010 Cadence Design Systems, Inc.
All Rights Reserved.