oaBaseCollection.h

Go to the documentation of this file.
00001 // *****************************************************************************
00002 // *****************************************************************************
00003 // oaBaseCollection.h
00004 //
00005 // This file contains the definitions for collections and iterators and their
00006 // supporting classes used in oaBase package.
00007 //
00008 // *****************************************************************************
00009 // Except as specified in the OpenAccess terms of use of Cadence or Silicon
00010 // Integration Initiative, this material may not be copied, modified,
00011 // re-published, uploaded, executed, or distributed in any way, in any medium,
00012 // in whole or in part, without prior written permission from Cadence.
00013 //
00014 //                Copyright 2002-2007 Cadence Design Systems, Inc.
00015 //                           All Rights Reserved.
00016 //
00017 //  $Author: icftcm $
00018 //  $Revision: #1 $
00019 //  $Date: 2010/08/09 $
00020 //  $State: Exp $
00021 // *****************************************************************************
00022 // *****************************************************************************
00023 
00024 
00025 
00026 #if !defined(oaBaseCollection_P)
00027 #define oaBaseCollection_P
00028 
00029 
00030 
00031 // *****************************************************************************
00032 // Nested includes
00033 // *****************************************************************************
00034 #include "oaGroup.h"
00035 #include "oaAppDef.h"
00036 #include "oaCollection.h"
00037 
00038 
00039 
00040 // *****************************************************************************
00041 // Declare and define types in the OpenAccess namespace.
00042 // *****************************************************************************
00043 BEGIN_OA_NAMESPACE
00044 
00045 
00046 
00047 // *****************************************************************************
00048 // Forward Class Declarations
00049 // *****************************************************************************
00050 template <class obj>
00051 class oaIter;
00052 class oaGroupTbl;
00053 class oaConstraint;
00054 class oaAppObjectDef;
00055 class oaAppObjectCollection;
00056 class oaGroupMemTbl;
00057 class oaConstraintGroup;
00058 class oaConstraintDef;
00059 class oaConstraintGroupMemTbl;
00060 class oaConstraintGroupTbl;
00061 class oaSimpleConstraint;
00062 class oaDatabase;
00063 class oaAppObject;
00064 class oaSession;
00065 class oaAppDataTbl;
00066 class oaGroup;
00067 class oaGroupDef;
00068 class oaGroupMember;
00069 class oaConstraintDef;
00070 class oaSession;
00071 class oaConstraintParamDef;
00072 class oaConstraintGroupDef;
00073 
00074 
00075 // *****************************************************************************
00076 // oaDatabaseCollection
00077 //
00078 // This is the base class for the collections of the open databases.
00079 // *****************************************************************************
00080 class OA_BASE_DLL_API oaDatabaseCollection {
00081 public:
00082                             oaDatabaseCollection(oaUInt4 dbIDIn);
00083                             oaDatabaseCollection(const oaDatabaseCollection &c);
00084 
00085     oaUInt4                 getCount() const;
00086     oaBoolean               isEmpty() const;
00087     oaBoolean               includes(const oaObject *database) const;
00088 
00089 protected:
00090     oaUInt4                 dbID;
00091 
00092     friend class oaDatabaseIter;
00093 };
00094 
00095 
00096 
00097 // *****************************************************************************
00098 // oaDatabaseIter
00099 //
00100 // This is the base class for the iterators of the open databases.
00101 // *****************************************************************************
00102 class OA_BASE_DLL_API oaDatabaseIter {
00103 public:
00104                             oaDatabaseIter(const oaDatabaseCollection &coll);
00105                             oaDatabaseIter(const oaDatabaseIter &iterIn);
00106 
00107     oaObject                *getNext();
00108     void                    reset();
00109 
00110 protected:
00111     oaUInt4                 dbID;
00112     oaUInt4                 index;
00113 };
00114 
00115 
00116 
00117 // *****************************************************************************
00118 // oaCollection<oaProp, oaObject>
00119 //
00120 // These are the specialized definitions of an oaCollection<> class and its
00121 // methods.
00122 // *****************************************************************************
00123 template <>
00124 class OA_BASE_DLL_API oaCollection<oaProp, oaObject> {
00125 public:
00126                             oaCollection(const oaObject *object);
00127                             oaCollection(const oaCollection<oaProp, oaObject> &c);
00128 
00129     oaUInt4                 getCount() const;
00130     oaBoolean               isEmpty() const;
00131     oaBoolean               includes(const oaProp *object) const;
00132 
00133 private:
00134     void                    *tbl;
00135     oaUInt4                 objDataType;
00136     oaUInt4                 objIndex;
00137     oaDomain                objDomain;
00138 
00139     friend class oaIter<oaProp>;
00140 };
00141 
00142 
00143 
00144 // *****************************************************************************
00145 // oaIter<oaProp>
00146 //
00147 // These are the definitions of a specialized oaIter<> class and its methods.
00148 // *****************************************************************************
00149 template <>
00150 class OA_BASE_DLL_API oaIter<oaProp> {
00151 public:
00152                             oaIter(const oaCollection<oaProp, oaObject> &c);
00153                             oaIter(const oaIter<oaProp> &iterIn);
00154 
00155     oaProp                  *getNext();
00156     void                    reset();
00157 
00158 private:
00159     void                    *tbl;
00160     oaUInt4                 index;
00161     oaUInt4                 objDataType;
00162     oaUInt4                 objIndex;
00163     oaDomain                objDomain;
00164 };
00165 
00166 
00167 
00168 // *****************************************************************************
00169 // oaCollection<oaGroupMember, oaObject>
00170 //
00171 // These are the specialized definitions of an oaCollection<> class and its
00172 // methods.
00173 // *****************************************************************************
00174 template <>
00175 class OA_BASE_DLL_API oaCollection<oaGroupMember, oaObject> {
00176 public:
00177                             oaCollection(const oaObject *object,
00178                                          oaUInt4        flagsIn = 0);
00179                             oaCollection(const oaCollection<oaGroupMember, oaObject> &c);
00180 
00181     oaUInt4                 getCount() const;
00182     oaBoolean               isEmpty() const;
00183     oaBoolean               includes(const oaGroupMember *object) const;
00184 
00185 private:
00186     void                    *tbl;
00187     oaUInt4                 flags;
00188     oaUInt4                 objDataType;
00189     oaUInt4                 objIndex;
00190     oaDomain                objDomain;
00191 
00192     friend class oaIter<oaGroupMember>;
00193 };
00194 
00195 
00196 
00197 // *****************************************************************************
00198 // oaIter<oaGroupMember>
00199 //
00200 // These are the definitions of a specialized oaIter<> class and its methods.
00201 // *****************************************************************************
00202 template <>
00203 class OA_BASE_DLL_API oaIter<oaGroupMember> {
00204 public:
00205                             oaIter(const oaCollection<oaGroupMember, oaGroup> &c);
00206                             oaIter(const oaCollection<oaGroupMember, oaObject> &c);
00207                             oaIter(const oaIter<oaGroupMember> &iterIn);
00208 
00209     oaGroupMember           *getNext();
00210     void                    reset();
00211 
00212 private:
00213     enum oaGroupMemIterType {
00214         oacGroupGroupMemIterType    = 0,
00215         oacObjectGroupMemIterType   = 1
00216     };
00217 
00218     void                    *tbl;
00219     void                    *assocTbl;
00220     oaGroupMemIterType      type;
00221     oaUInt4                 assocIndex;
00222     oaUInt4                 ownerDataType;
00223     oaUInt4                 ownerIndex;
00224     oaDomain                ownerDomain;
00225     oaUInt4                 flags;
00226 };
00227 
00228 
00229 
00230 // *****************************************************************************
00231 // oaGroupCollection
00232 //
00233 // This is the base class for group in database collections. The filter flags
00234 // are stored in domainFlags and the index into the name table is stored in
00235 // nameIndex for name based iterations.  If a def base iteration is intended
00236 // then the oacGroupIterGroupDef flag needs to be set in the domainFlags. The
00237 // session group def index will then be stored in defIndex.
00238 // *****************************************************************************
00239 class OA_BASE_DLL_API oaGroupCollection {
00240 public:
00241                             oaGroupCollection(const oaObject    *database,
00242                                               oaUInt4           domainFlags,
00243                                               oaUInt4           nameIndexIn);
00244                             oaGroupCollection(const oaGroupCollection &c);
00245 
00246     oaUInt4                 getCount() const;
00247     oaBoolean               isEmpty() const;
00248     oaBoolean               includes(const oaGroup *object) const;
00249 
00250 private:
00251     oaGroupTbl              *tbl;
00252     oaUInt4                 domainFlags;
00253     union {
00254         oaUInt4             nameIndex;
00255         oaUInt4             defIndex;
00256     };
00257 
00258     friend class oaIter<oaGroup>;
00259 };
00260 
00261 
00262 
00263 // *****************************************************************************
00264 // oaCollection<oaGroup, oaObject>
00265 //
00266 // These are the specialized definitions of an oaCollection<> class and its
00267 // methods.
00268 // *****************************************************************************
00269 template <>
00270 class OA_BASE_DLL_API oaCollection<oaGroup, oaObject> {
00271 public:
00272                             oaCollection(const oaObject *object);
00273                             oaCollection(const oaCollection<oaGroup, oaObject> &c);
00274 
00275     oaUInt4                 getCount() const;
00276     oaBoolean               isEmpty() const;
00277     oaBoolean               includes(const oaGroup *object) const;
00278 
00279 private:
00280     oaGroupTbl              *tbl;
00281     oaUInt4                 objDataType;
00282     oaUInt4                 objIndex;
00283     oaDomain                objDomain;
00284 
00285     friend class oaIter<oaGroup>;
00286 };
00287 
00288 
00289 
00290 // *****************************************************************************
00291 // oaIter<oaGroup>
00292 //
00293 // These are the definitions of a specialized oaIter<> class and its methods.
00294 // *****************************************************************************
00295 template <>
00296 class OA_BASE_DLL_API oaIter<oaGroup> {
00297 public:
00298                             oaIter(const oaGroupCollection &c);
00299                             oaIter(const oaCollection<oaGroup, oaObject> &c);
00300                             oaIter(const oaIter<oaGroup> &iterIn);
00301 
00302     oaGroup                 *getNext();
00303     void                    reset();
00304 
00305 private:
00306     enum oaGroupIterType {
00307         oacInDatabaseGroupIterType  = 0,
00308         oacByNameGroupIterType      = 1,
00309         oacObjectGroupIterType      = 2,
00310         oacEmptyGroupIterType       = 3,
00311         oacByDefGroupIterType       = 4
00312     };
00313 
00314     oaGroupTbl              *tbl;
00315     oaGroupMemTbl           *memTbl;
00316     oaGroupIterType         type;
00317     union {
00318         oaUInt4             nameIndex;
00319         oaUInt4             objIndex;
00320         oaUInt4             defIndex;
00321     };
00322     union {
00323         oaUInt4             domainFlags;
00324         oaUInt4             objDataType;
00325     };
00326     oaDomainEnum            objDomain;
00327     oaUInt4                 index;
00328 };
00329 
00330 
00331 
00332 // *****************************************************************************
00333 // oaConstraintCollection
00334 //
00335 // This is the base class for constraint database collections.
00336 // *****************************************************************************
00337 class OA_BASE_DLL_API oaConstraintCollection {
00338 public:
00339                             oaConstraintCollection(const oaObject *database);
00340                             oaConstraintCollection(const oaObject   *database,
00341                                                    oaUInt4          defIndex);
00342                             oaConstraintCollection(const oaConstraintCollection &c);
00343 
00344     oaUInt4                 getCount() const;
00345     oaBoolean               isEmpty() const;
00346     oaBoolean               includes(const oaConstraint *constraint) const;
00347 
00348     void                    *getTbl() const;
00349     oaBoolean               getIterAll() const;
00350     oaUInt4                 getDefIndex() const;
00351 
00352 protected:
00353     void                    *tbl;
00354     oaBoolean               iterAll;
00355     oaUInt4                 defIndex;
00356 
00357     friend class oaIter<oaConstraint>;
00358 };
00359 
00360 
00361 
00362 // *****************************************************************************
00363 // oaConstraintInGroupCollection
00364 //
00365 // This is the base class for constraint in constraint group collections.
00366 // *****************************************************************************
00367 class OA_BASE_DLL_API oaConstraintInGroupCollection {
00368 public:
00369                             oaConstraintInGroupCollection(const oaConstraintGroup   *group,
00370                                                           const oaConstraintDef     *def,
00371                                                           oaBoolean                 hardOnly);
00372                             oaConstraintInGroupCollection(const oaConstraintInGroupCollection &c);
00373 
00374     oaUInt4                 getCount() const;
00375     oaBoolean               isEmpty() const;
00376     oaBoolean               includes(const oaConstraint *object) const;
00377 
00378 protected:
00379     virtual oaBoolean       isMatch(const oaConstraintGroupMemTbl   *mTbl,
00380                                     oaUInt4                         mIndex,
00381                                     const oaConstraint              *obj = NULL) const;
00382 
00383     oaUInt4                 traverse(const oaConstraintGroupMemTbl  *memTbl,
00384                                      oaUInt4                        startIndex,
00385                                      oaBoolean                      stopOnFirst = false,
00386                                      const oaConstraint             *obj = NULL) const;
00387 
00388     oaConstraintGroupTbl    *gTbl;
00389     oaUInt4                 gIndex;
00390     oaUInt4                 defIndex;
00391     oaBoolean               hard;
00392 
00393     friend class oaConstraintInGroupIter;
00394 };
00395 
00396 
00397 
00398 // *****************************************************************************
00399 // oaCollection<oaConstraint, oaConstraintGroup>
00400 //
00401 // This is the specialization for all constraints in constraint group
00402 // collections.
00403 // *****************************************************************************
00404 template <>
00405 class OA_BASE_DLL_API oaCollection<oaConstraint, oaConstraintGroup> : public oaConstraintInGroupCollection {
00406 public:
00407                             oaCollection(const oaConstraintGroup    *group,
00408                                          const oaConstraintDef      *def,
00409                                          oaBoolean                  hardOnly);
00410                             oaCollection(const oaCollection<oaConstraint, oaConstraintGroup> &c);
00411 };
00412 
00413 
00414 
00415 // *****************************************************************************
00416 // oaCollection<oaSimpleConstraint, oaConstraintGroup>
00417 //
00418 // This is the specialization for simple constraints in constraint group
00419 // collections.
00420 // *****************************************************************************
00421 template <>
00422 class OA_BASE_DLL_API oaCollection<oaSimpleConstraint, oaConstraintGroup> : public oaConstraintInGroupCollection {
00423 public:
00424                             oaCollection(const oaConstraintGroup    *group,
00425                                          const oaConstraintDef      *def,
00426                                          oaBoolean                  hardOnly);
00427                             oaCollection(const oaCollection<oaSimpleConstraint, oaConstraintGroup> &c);
00428 };
00429 
00430 
00431 
00432 // *****************************************************************************
00433 // oaConstraintInGroupIter
00434 //
00435 // This is the definition of the base iterator for iterating over constraints
00436 // in a group.
00437 // *****************************************************************************
00438 class OA_BASE_DLL_API oaConstraintInGroupIter {
00439 public:
00440     virtual void            reset();
00441     virtual                 ~oaConstraintInGroupIter();
00442 
00443 protected:
00444                             oaConstraintInGroupIter(const oaConstraintInGroupCollection &c);
00445                             oaConstraintInGroupIter(const oaConstraintInGroupIter &iterIn);
00446                             oaConstraintInGroupIter();
00447 
00448     virtual oaBoolean       isMatch(const oaConstraintGroupMemTbl   *tbl,
00449                                     oaUInt4                         index) const;
00450 
00451     oaConstraint            *getNextInGroup();
00452 
00453     void                    findNext(oaUInt4 startIndex);
00454     void                    resize(oaUInt4 newSize);
00455 
00456     oaConstraintInGroupIter &operator=(const oaConstraintInGroupIter &iterIn);
00457 
00458     void                    *gTbl;
00459     oaUInt4                 gIndex;
00460     oaUInt4                 defIndex;
00461     oaBoolean               hard;
00462 
00463     void                    **memTbl;
00464     void                    *memIndex;
00465     oaUInt4                 stackSize;
00466     oaUInt4                 position;
00467     oaUInt4                 index;
00468 
00469     friend class oaConstraintInGroupCollection;
00470 };
00471 
00472 
00473 
00474 // *****************************************************************************
00475 // oaIter<oaConstraint>
00476 //
00477 // These are the definitions of a specialized oaIter<> class and its methods.
00478 // *****************************************************************************
00479 template <>
00480 class OA_BASE_DLL_API oaIter<oaConstraint> : public oaConstraintInGroupIter {
00481 public:
00482                             oaIter(const oaConstraintCollection &c);
00483                             oaIter(const oaCollection<oaConstraint, oaConstraintGroup> &c);
00484                             oaIter(const oaIter<oaConstraint> &iterIn);
00485 
00486     oaConstraint            *getNext();
00487     virtual void            reset();
00488 
00489 private:
00490     enum oaConstraintIterType {
00491         oacAllInDatabaseIterType    = 0,
00492         oacByConstraintDefIterType  = 1,
00493         oacAllInGroupIterType       = 2
00494     };
00495 
00496     void                    *tbl;
00497     oaConstraintIterType    type;
00498 };
00499 
00500 
00501 
00502 // *****************************************************************************
00503 // oaIter<oaSimpleConstraint>
00504 //
00505 // These are the definitions of a specialized oaIter<> class and its methods.
00506 // *****************************************************************************
00507 template <>
00508 class OA_BASE_DLL_API oaIter<oaSimpleConstraint> : public oaConstraintInGroupIter {
00509 public:
00510                             oaIter(const oaCollection<oaSimpleConstraint, oaConstraintGroup> &c);
00511                             oaIter(const oaIter<oaSimpleConstraint> &iterIn);
00512 
00513     oaSimpleConstraint      *getNext();
00514 };
00515 
00516 
00517 
00518 // *****************************************************************************
00519 // Explicit template instantiations
00520 // *****************************************************************************
00521 #if defined(OA_BASE_DLL_EXTERN)
00522 OA_BASE_DLL_EXTERN template
00523  class OA_BASE_DLL_API oaCollection<oaGroupMember, oaGroup>;
00524 OA_BASE_DLL_EXTERN template
00525  class OA_BASE_DLL_API oaCollection<oaConstraintParamDef, oaSession>;
00526 OA_BASE_DLL_EXTERN template
00527  class OA_BASE_DLL_API oaCollection<oaConstraintDef, oaSession>;
00528 OA_BASE_DLL_EXTERN template
00529  class OA_BASE_DLL_API oaCollection<oaGroupDef, oaSession>;
00530 OA_BASE_DLL_EXTERN template
00531  class OA_BASE_DLL_API oaCollection<oaConstraintGroupDef, oaSession>;
00532 #endif
00533 
00534 
00535 
00536 // *****************************************************************************
00537 // oaCollection<oaAppDef, oaObject>
00538 //
00539 // These are the specialized definitions of an oaCollection<> class and its
00540 // methods.
00541 // *****************************************************************************
00542 template <>
00543 class OA_BASE_DLL_API oaCollection<oaAppDef, oaObject> {
00544 public:
00545                             oaCollection(const oaObject *object);
00546                             oaCollection(const oaObject *object,
00547                                          oaUInt4        dtIndex,
00548                                          oaDomain       domain = oacNoDomain);
00549                             oaCollection(const oaCollection<oaAppDef, oaObject> &c);
00550 
00551     oaUInt4                 getCount() const;
00552     oaBoolean               isEmpty() const;
00553     oaBoolean               includes(const oaAppDef *object) const;
00554 
00555 private:
00556     oaAppDataTbl            *tbl;
00557     oaUInt4                 objDtIndex;
00558     oaUInt4                 objIndex;
00559     oaDomain                objDomain;
00560 
00561     friend class oaIter<oaAppDef>;
00562 };
00563 
00564 
00565 
00566 // *****************************************************************************
00567 // oaCollection<oaAppDef, oaSession>
00568 //
00569 // These are the specialized definitions of an oaCollection<> class and its
00570 // methods.
00571 // *****************************************************************************
00572 template <>
00573 class OA_BASE_DLL_API oaCollection<oaAppDef, oaSession> {
00574 public:
00575     oaUInt4                 getCount() const;
00576     oaBoolean               isEmpty() const;
00577 
00578     friend class oaIter<oaAppDef>;
00579 };
00580 
00581 
00582 
00583 // *****************************************************************************
00584 // oaIter<oaAppDef>
00585 //
00586 // These are the definitions of a specialized oaIter<> class and its methods.
00587 // *****************************************************************************
00588 template <>
00589 class OA_BASE_DLL_API oaIter<oaAppDef> {
00590 public:
00591                             oaIter(const oaCollection<oaAppDef, oaSession> &c);
00592                             oaIter(const oaCollection<oaAppDef, oaObject> &c);
00593                             oaIter(const oaIter<oaAppDef> &iterIn);
00594 
00595     oaAppDef                *getNext();
00596     void                    reset();
00597 
00598 private:
00599     oaAppDataTbl            *tbl;
00600     oaUInt4                 objIndex;
00601     oaUInt4                 objDtIndex;
00602     oaDomainEnum            objDomain;
00603     oaUInt4                 index;
00604 };
00605 
00606 
00607 
00608 // *****************************************************************************
00609 // oaAppObjectDefCollection
00610 //
00611 // This is the base class for appObjectDef collections in databases.
00612 // *****************************************************************************
00613 class OA_BASE_DLL_API oaAppObjectDefCollection {
00614 public:
00615                             oaAppObjectDefCollection(const oaObject *database);
00616                             oaAppObjectDefCollection(const oaAppObjectDefCollection &c);
00617 
00618     oaUInt4                 getCount() const;
00619     oaBoolean               isEmpty() const;
00620     oaBoolean               includes(const oaAppObjectDef *object) const;
00621 
00622 private:
00623     oaDatabase              *db;
00624 
00625     friend class oaIter<oaAppObjectDef>;
00626 };
00627 
00628 
00629 
00630 // *****************************************************************************
00631 // oaCollection<oaAppObjectDef, oaSession>
00632 //
00633 // These are the specialized definitions of an oaCollection<> class and its
00634 // methods.
00635 // *****************************************************************************
00636 template <>
00637 class OA_BASE_DLL_API oaCollection<oaAppObjectDef, oaSession> {
00638 public:
00639     oaUInt4                 getCount() const;
00640     oaBoolean               isEmpty() const;
00641 };
00642 
00643 
00644 
00645 // *****************************************************************************
00646 // oaIter<oaAppObjectDef>
00647 //
00648 // These are the definitions of a specialized oaIter<> class and its methods.
00649 // *****************************************************************************
00650 template <>
00651 class OA_BASE_DLL_API oaIter<oaAppObjectDef> {
00652 public:
00653                             oaIter(const oaAppObjectDefCollection &c);
00654                             oaIter(const oaCollection<oaAppObjectDef, oaSession> &c);
00655                             oaIter(const oaIter<oaAppObjectDef> &iterIn);
00656 
00657     oaAppObjectDef          *getNext();
00658     void                    reset();
00659 
00660 private:
00661     oaDatabase              *db;
00662     oaUInt4                 index;
00663 };
00664 
00665 
00666 
00667 // *****************************************************************************
00668 // oaCollection<oaAppObject>
00669 //
00670 // This is the base class for app objects in database collections.
00671 // *****************************************************************************
00672 class OA_BASE_DLL_API oaAppObjectCollection {
00673 public:
00674                             oaAppObjectCollection(const oaObject        *database,
00675                                                   const oaAppObjectDef  *def);
00676                             oaAppObjectCollection(const oaAppObjectCollection &c);
00677 
00678     oaUInt4                 getCount() const;
00679     oaBoolean               isEmpty() const;
00680     oaBoolean               includes(const oaAppObject *object) const;
00681 
00682 private:
00683     void                    *db;
00684     oaUInt4                 id;
00685 
00686     friend class oaIter<oaAppObject>;
00687 };
00688 
00689 
00690 
00691 // *****************************************************************************
00692 // oaIter<oaAppObject>
00693 //
00694 // These are the definitions of a specialized oaIter<> class and its methods.
00695 // *****************************************************************************
00696 template <>
00697 class OA_BASE_DLL_API oaIter<oaAppObject> {
00698 public:
00699                             oaIter(const oaAppObjectCollection &c);
00700                             oaIter(const oaIter<oaAppObject> &iterIn);
00701 
00702     oaAppObject             *getNext();
00703     void                    reset();
00704     void                    reset(const oaAppObjectCollection &c);
00705 
00706 private:
00707     void                    *db;
00708     void                    *tbl;
00709     oaUInt4                 id;
00710     oaUInt4                 index;
00711 };
00712 
00713 
00714 
00715 END_OA_NAMESPACE
00716 
00717 #endif

Return to top of page