oaCMObject.h

Go to the documentation of this file.
00001 // ****************************************************************************
00002 // ****************************************************************************
00003 // oaCMObject.h
00004 //
00005 // This file contains the definition of the object references and object entry
00006 // classes which are used in the CMS system, as well as their containers and
00007 // visitors.
00008 //
00009 //  oaCMStringEntry
00010 //      This class represents an entry in the string table. Each entry object
00011 //      contains a string.
00012 //
00013 //  oaCMObjectStateEntry
00014 //      This class represents an entry in the object state table. Each entry
00015 //      object contains an object state.
00016 //
00017 //  oaCMStringTbl
00018 //      This class contains string entry objects.
00019 //
00020 //  oaCMObjectStateTbl
00021 //      This class contains object state entry objects.
00022 //
00023 //  oaCMObjectRef
00024 //      This is a object reference which has life-time management
00025 //      functionality.
00026 //
00027 //  oaCMDatabaseRef
00028 //      This is a object reference in which the object is a database.
00029 //
00030 //  oaCMObjectIDRef
00031 //      This is a object reference in which the object can be identified by
00032 //      a single attribute, usually a name.
00033 //
00034 //  oaCMObjectStateRef
00035 //      This is a object reference in which the object can be identified by
00036 //      a state which is a compound --- a collection of attributes and
00037 //      relationships. These objects do not have a single attribute to identify
00038 //      them.
00039 //
00040 //  oaCMObjectVisitor
00041 //      oaCMObject classes supports visitor pattern for various actions on
00042 //      them. This is the interface for the visitor, which is capable of
00043 //      visiting concrete oaCMObject nodes. It can be derived to define
00044 //      specific actions.
00045 //
00046 // ****************************************************************************
00047 // Except as specified in the OpenAccess terms of use of Cadence or Silicon
00048 // Integration Initiative, this material may not be copied, modified,
00049 // re-published, uploaded, executed, or distributed in any way, in any medium,
00050 // in whole or in part, without prior written permission from Cadence.
00051 //
00052 //                Copyright 2007 Cadence Design Systems, Inc.
00053 //                           All Rights Reserved.
00054 //
00055 //  $Author: priyav
00056 //  $Revision:
00057 //  $Date: 2007/04/25
00058 //  $State:
00059 // ****************************************************************************
00060 // ****************************************************************************
00061 
00062 
00063 
00064 #if !defined(oaCMObject_P)
00065 #define oaCMObject_P
00066 
00067 
00068 
00069 // ****************************************************************************
00070 // Nested includes
00071 // ****************************************************************************
00072 #include <list>
00073 #include <map>
00074 #include "srBase.h"
00075 #include "srVisitor.h"
00076 #include "oaCMBaseTypes.h"
00077 #include "oaTimeStamp.h"
00078 
00079 
00080 
00081 // *****************************************************************************
00082 // Declare and define types in the OpenAccess namespace.
00083 // *****************************************************************************
00084 BEGIN_OA_NAMESPACE
00085 
00086 
00087 
00088 // *****************************************************************************
00089 // Forward Public Class Declarations
00090 // *****************************************************************************
00091 class oaCMObjectRefTbl;
00092 class oaCMDatabaseTbl;
00093 class oaCMStringTbl;
00094 class oaCMObjectStateTbl;
00095 class oaCMDatabaseRef;
00096 class oaChangeSetBase;
00097 
00098 
00099 
00100 // ****************************************************************************
00101 // oaCMStringEntry
00102 // ****************************************************************************
00103 class OA_CM_DLL_API oaCMStringEntry : public sr::srBase {
00104 public:
00105     typedef oaCMStringEntry *SPtr;
00106 
00107                             oaCMStringEntry(const oaString  &string,
00108                                             oaCMStringTbl   *tbl,
00109                                             oaTimeStamp     timeStamp);
00110     virtual                 ~oaCMStringEntry();
00111 
00112     const char              *getString() const;
00113     oaTimeStamp             getTimeStamp() const;
00114 
00115     virtual void            accept(sr::srVisitorMgr &visitor);
00116 
00117 private:
00118     oaCMStringTbl           *m_tbl;
00119     oaString                m_string;
00120     oaTimeStamp             m_timeStamp;
00121 };
00122 
00123 
00124 
00125 // ****************************************************************************
00126 // oaCMObjectStateEntry
00127 // ****************************************************************************
00128 class OA_CM_DLL_API oaCMObjectStateEntry : public sr::srObjectState {
00129 public:
00130     typedef oaCMObjectStateEntry    *SPtr;
00131 
00132                                     oaCMObjectStateEntry(const sd::sdObject     *def,
00133                                                          const AttributeMap     &attributes,
00134                                                          const RelationshipMap  &relationships,
00135                                                          oaCMObjectStateTbl     *tbl,
00136                                                          oaTimeStamp            timeStamp);
00137     virtual                         ~oaCMObjectStateEntry();
00138 
00139     oaTimeStamp                     getTimeStamp() const;
00140 
00141 private:
00142     oaCMObjectStateTbl              *m_tbl;
00143     oaTimeStamp                     m_timeStamp;
00144 
00145     friend class oaCMObjectRef;
00146 };
00147 
00148 
00149 
00150 // ****************************************************************************
00151 // oaCMStringTbl
00152 // ****************************************************************************
00153 class OA_CM_DLL_API oaCMStringTbl {
00154 public:
00155     typedef std::map<std::string, oaCMStringEntry*>::const_iterator StringEntryConstIter;
00156     typedef std::map<std::string, oaCMStringEntry*>::iterator       StringEntryIter;
00157 
00158                                                                     oaCMStringTbl();
00159                                                                     ~oaCMStringTbl();
00160 
00161     StringEntryConstIter                                            begin() const;
00162     StringEntryConstIter                                            end() const;
00163 
00164     oaCMStringEntry::SPtr                                           find(const oaString &str) const;
00165 
00166     void                                                            cleanup(oaTimeStamp timeStamp);
00167 
00168 private:
00169     void                                                            add(oaCMStringEntry *str);
00170     void                                                            remove(oaCMStringEntry *str);
00171 
00172     std::map<std::string, oaCMStringEntry*>                         m_strings;
00173 
00174     friend class oaCMStringEntry;
00175 };
00176 
00177 
00178 
00179 // ****************************************************************************
00180 // oaCMObjectStateTbl class
00181 // ****************************************************************************
00182 class OA_CM_DLL_API oaCMObjectStateTbl {
00183 public:
00184     typedef std::list<oaCMObjectStateEntry*>::const_iterator    ObjectStateEntryConstIter;
00185     typedef std::list<oaCMObjectStateEntry*>::iterator          ObjectStateEntryIter;
00186 
00187                                                                 oaCMObjectStateTbl();
00188                                                                 ~oaCMObjectStateTbl();
00189 
00190     ObjectStateEntryConstIter                                   begin() const;
00191     ObjectStateEntryConstIter                                   end() const;
00192 
00193     void                                                        cleanup(oaTimeStamp timeStamp);
00194 
00195 private:
00196     void                                                        add(oaCMObjectStateEntry *state);
00197     void                                                        remove(oaCMObjectStateEntry *state);
00198 
00199     std::list<oaCMObjectStateEntry*>                            m_states;
00200 
00201     friend class oaCMObjectStateEntry;
00202 };
00203 
00204 
00205 
00206 // ****************************************************************************
00207 // oaCMObjectRef
00208 // ****************************************************************************
00209 class OA_CM_DLL_API oaCMObjectRef : public sr::srObjectRef {
00210 public:
00211     typedef oaCMObjectRef   *SPtr;
00212     typedef oaCMDatabaseRef *DatabaseSPtr;
00213 
00214     virtual void            passivate();
00215     virtual void            activate();
00216 
00217     virtual DatabaseSPtr    getDatabase() const = 0;
00218 
00219     oaBoolean               isAlive() const;
00220     oaBoolean               isNew() const;
00221     oaTimeStamp             getTimeStamp() const;
00222 
00223     void                    setIsNew(oaBoolean isNew);
00224 
00225 protected:
00226                             oaCMObjectRef(const sd::sdObject    *def,
00227                                           void                  *object,
00228                                           oaTimeStamp           timeStamp,
00229                                           oaBoolean             isNew = false);
00230     virtual                 ~oaCMObjectRef();
00231 
00232 private:
00233                             oaCMObjectRef(const oaCMObjectRef &copy);
00234     oaCMObjectRef           &operator=(const oaCMObjectRef &rhs);
00235 
00236     oaBoolean               m_alive;
00237     oaBoolean               m_isNew;
00238     oaTimeStamp             m_timeStamp;
00239 
00240     friend class oaCMObjectRefTbl;
00241 };
00242 
00243 
00244 
00245 // ****************************************************************************
00246 // oaCMDatabaseRef
00247 // ****************************************************************************
00248 class OA_CM_DLL_API oaCMDatabaseRef : public oaCMObjectRef {
00249 public:
00250     typedef oaCMDatabaseRef         *SPtr;
00251 
00252                                     oaCMDatabaseRef(const sd::sdObject  *def,
00253                                                     void                *object,
00254                                                     oaCMDatabaseTbl     *tbl,
00255                                                     oaTimeStamp         timeStamp,
00256                                                     oaBoolean           isNew = false);
00257     virtual                         ~oaCMDatabaseRef();
00258 
00259     virtual void                    accept(sr::srVisitorMgr &visitor);
00260 
00261     virtual void                    passivate();
00262     virtual void                    activate();
00263 
00264     virtual oaCMDatabaseRef::SPtr   getDatabase() const;
00265     oaCMObjectStateEntry::SPtr      getState() const;
00266 
00267     void                            setState(oaCMObjectStateEntry::SPtr state);
00268 
00269 private:
00270                                     oaCMDatabaseRef(const oaCMDatabaseRef &copy);
00271     oaCMDatabaseRef                 &operator=(const oaCMDatabaseRef &rhs);
00272 
00273     oaCMDatabaseTbl                 *m_tbl;
00274     oaCMObjectStateEntry::SPtr      m_state;
00275 };
00276 
00277 
00278 
00279 // ****************************************************************************
00280 // oaCMObjectIDRef
00281 // ****************************************************************************
00282 class OA_CM_DLL_API oaCMObjectIDRef : public oaCMObjectRef {
00283 public:
00284     typedef oaCMObjectIDRef         *SPtr;
00285 
00286                                     oaCMObjectIDRef(const sd::sdObject  *def,
00287                                                     void                *object,
00288                                                     oaCMObjectRefTbl    *tbl,
00289                                                     oaTimeStamp         timeStamp,
00290                                                     oaBoolean           isNew = false,
00291                                                     oaCMObjectRef::SPtr scope = NULL);
00292     virtual                         ~oaCMObjectIDRef();
00293 
00294     virtual void                    accept(sr::srVisitorMgr &visitor);
00295 
00296     virtual void                    passivate();
00297     virtual void                    activate();
00298 
00299     virtual oaCMDatabaseRef::SPtr   getDatabase() const;
00300     oaCMObjectRef::SPtr             getScope() const;
00301 
00302     oaCMStringEntry::SPtr           getName() const;
00303     void                            setName(oaCMStringEntry::SPtr name);
00304 
00305 private:
00306                                     oaCMObjectIDRef(const oaCMObjectIDRef &copy);
00307     oaCMObjectIDRef                 &operator=(const oaCMObjectIDRef &rhs);
00308 
00309     oaCMObjectRefTbl                *m_tbl;
00310     oaCMStringEntry::SPtr           m_name;
00311     oaCMObjectRef::SPtr             m_scope;
00312 };
00313 
00314 
00315 
00316 // ****************************************************************************
00317 // oaCMObjectStateRef
00318 // ****************************************************************************
00319 class OA_CM_DLL_API oaCMObjectStateRef : public oaCMObjectRef {
00320 public:
00321     typedef oaCMObjectStateRef      *SPtr;
00322 
00323                                     oaCMObjectStateRef(const sd::sdObject   *def,
00324                                                        void                 *object,
00325                                                        oaCMObjectRefTbl     *tbl,
00326                                                        oaTimeStamp          timeStamp,
00327                                                        oaBoolean            isNew = false,
00328                                                        oaCMObjectRef::SPtr  scope = NULL);
00329     virtual                         ~oaCMObjectStateRef();
00330 
00331     virtual void                    accept(sr::srVisitorMgr &visitor);
00332     virtual void                    passivate();
00333     virtual void                    activate();
00334 
00335     virtual oaCMDatabaseRef::SPtr   getDatabase() const;
00336     oaCMObjectRef::SPtr             getScope() const;
00337 
00338     oaCMObjectStateEntry::SPtr      getState() const;
00339     oaCMObjectStateEntry::SPtr      setState(oaCMObjectStateEntry::SPtr state);
00340 
00341 private:
00342                                     oaCMObjectStateRef(const oaCMObjectStateRef &copy);
00343     oaCMObjectStateRef              &operator=(const oaCMObjectStateRef &rhs);
00344 
00345     oaCMObjectRefTbl                *m_tbl;
00346     oaCMObjectStateEntry::SPtr      m_state;
00347     oaCMObjectRef::SPtr             m_scope;
00348 };
00349 
00350 
00351 
00352 // ****************************************************************************
00353 // oaCMObjectVisitor
00354 // ****************************************************************************
00355 class OA_CM_DLL_API oaCMObjectVisitor : public virtual sr::srVisitor {
00356 public:
00357     using                   sr::srVisitor::visit;
00358 
00359     virtual                 ~oaCMObjectVisitor();
00360 
00361     virtual void            visit(oaCMObjectIDRef *node) = 0;
00362     virtual void            visit(oaCMDatabaseRef *node) = 0;
00363     virtual void            visit(oaCMObjectStateRef *node) = 0;
00364 };
00365 
00366 
00367 
00368 // ****************************************************************************
00369 // oaCMDatabaseTbl
00370 // ****************************************************************************
00371 class OA_CM_DLL_API oaCMDatabaseTbl {
00372 public:
00373     typedef std::list<oaCMDatabaseRef*>::const_iterator         DatabaseRefConstIter;
00374     typedef std::list<oaCMDatabaseRef*>::iterator               DatabaseRefIter;
00375 
00376                                                                 oaCMDatabaseTbl();
00377     virtual                                                     ~oaCMDatabaseTbl();
00378 
00379     oaCMDatabaseRef::SPtr                                       find(void *database) const;
00380 
00381     void                                                        onPassivate(oaCMDatabaseRef::SPtr ref);
00382     void                                                        onActivate(oaCMDatabaseRef::SPtr ref);
00383 
00384     DatabaseRefConstIter                                        begin() const;
00385     DatabaseRefConstIter                                        end() const;
00386 
00387 private:
00388     void                                                        add(oaCMDatabaseRef *ref);
00389     void                                                        remove(oaCMDatabaseRef *ref);
00390 
00391     typedef std::map<void*, oaCMDatabaseRef*>::const_iterator   MapConstIter;
00392 
00393     std::map<void*, oaCMDatabaseRef*>                           m_activeDatabases;
00394     std::list<oaCMDatabaseRef*>                                 m_allDatabases;
00395 
00396     friend class oaCMDatabaseRef;
00397 };
00398 
00399 
00400 
00401 // ****************************************************************************
00402 // oaCMObjectRefTbl
00403 // ****************************************************************************
00404 class OA_CM_DLL_API oaCMObjectRefTbl {
00405 public:
00406     typedef std::list<oaCMObjectRef*>::const_iterator       ObjectRefConstIter;
00407     typedef std::list<oaCMObjectRef*>::iterator             ObjectRefIter;
00408 
00409                                                             oaCMObjectRefTbl(oaCMDatabaseRef::SPtr database);
00410                                                             ~oaCMObjectRefTbl();
00411 
00412     oaCMObjectRef::SPtr                                     find(void *obj) const;
00413 
00414     void                                                    onPassivate(oaCMObjectRef::SPtr ref);
00415     void                                                    onActivate(oaCMObjectRef::SPtr ref);
00416 
00417     oaCMDatabaseRef::SPtr                                   getDatabase() const;
00418 
00419     ObjectRefConstIter                                      begin() const;
00420     ObjectRefConstIter                                      end() const;
00421 
00422     void                                                    cleanup(oaTimeStamp timeStamp);
00423 
00424 private:
00425     typedef std::map<void*, oaCMObjectRef*>::const_iterator MapConstIter;
00426 
00427     void                                                    add(oaCMObjectRef *ref);
00428     void                                                    remove(oaCMObjectRef *ref);
00429 
00430     oaCMDatabaseRef                                         *m_database;
00431     std::map<void*, oaCMObjectRef*>                         m_activeRefs;
00432     std::list<oaCMObjectRef*>                               m_allRefs;
00433 
00434     friend class oaCMObjectIDRef;
00435     friend class oaCMObjectStateRef;
00436 };
00437 
00438 
00439 
00440 END_OA_NAMESPACE
00441 
00442 #endif

Return to top of page