From f47f6b92e5b57ef34112cc90656a6f50efc79182 Mon Sep 17 00:00:00 2001 From: Christophe Alexandre Date: Fri, 13 Jun 2008 15:58:55 +0000 Subject: [PATCH] get rid of global functions : getDataBase() -> DataBase::getDB() --- hurricane/doc/hurricane/DataBase.dox | 18 ++++++------------ hurricane/src/hurricane/DataBase.cpp | 18 +++++++----------- hurricane/src/hurricane/hurricane/DataBase.h | 11 ++--------- hurricane/src/hviewer/Palette.cpp | 2 +- hurricane/src/isobar/PyDataBase.cpp | 2 +- 5 files changed, 17 insertions(+), 34 deletions(-) diff --git a/hurricane/doc/hurricane/DataBase.dox b/hurricane/doc/hurricane/DataBase.dox index a79d32ff..4635dd67 100644 --- a/hurricane/doc/hurricane/DataBase.dox +++ b/hurricane/doc/hurricane/DataBase.dox @@ -43,6 +43,12 @@ */ // \{ + /*! \function DataBase* DataBase::getDB (); + * This static function returns the current + * DataBase, if it has been created and not destroyed, + * else \NULL. + */ + /*! \function Technology* DataBase::getTechnology () const; * \return the Technology if it exists, else \NULL. */ @@ -51,18 +57,6 @@ * \return the root Library if it exists, else \NULL. */ - // \} - - - /*! \addtogroup Generalities - * \{ - */ - - /*! \function DataBase* getDataBase (); - * This global generic function returns the current - * DataBase, if it has been created and not destroyed, - * else \NULL. - */ // \} diff --git a/hurricane/src/hurricane/DataBase.cpp b/hurricane/src/hurricane/DataBase.cpp index 514518a9..29d4238a 100644 --- a/hurricane/src/hurricane/DataBase.cpp +++ b/hurricane/src/hurricane/DataBase.cpp @@ -20,7 +20,7 @@ namespace Hurricane { // DataBase implementation // **************************************************************************************************** -static DataBase* DATA_BASE = NULL; +DataBase* DataBase::_db = NULL; DataBase::DataBase() // ***************** @@ -28,7 +28,7 @@ DataBase::DataBase() _technology(NULL), _rootLibrary(NULL) { - if (DATA_BASE) + if (_db) throw Error("Can't create " + _TName("DataBase") + " : already exists"); } @@ -47,7 +47,7 @@ void DataBase::_postCreate() { Inherit::_postCreate(); - DATA_BASE = this; + _db = this; } void DataBase::_preDestroy() @@ -60,7 +60,7 @@ void DataBase::_preDestroy() if (_technology) _technology->destroy(); UpdateSession::close(); - DATA_BASE = NULL; + _db = NULL; } string DataBase::_getString() const @@ -83,14 +83,10 @@ Record* DataBase::_getRecord() const return record; } -// **************************************************************************************************** -// Generic functions -// **************************************************************************************************** - -DataBase* getDataBase() -// ******************** +DataBase* DataBase::getDB() +// ************************ { - return DATA_BASE; + return _db; } diff --git a/hurricane/src/hurricane/hurricane/DataBase.h b/hurricane/src/hurricane/hurricane/DataBase.h index 5621ce6b..49a7ecbc 100644 --- a/hurricane/src/hurricane/hurricane/DataBase.h +++ b/hurricane/src/hurricane/hurricane/DataBase.h @@ -34,6 +34,7 @@ class DataBase : public DBo { // Attributes // ********** + private: static DataBase* _db; private: Technology* _technology; private: Library* _rootLibrary; @@ -65,18 +66,10 @@ class DataBase : public DBo { public: Technology* getTechnology() const {return _technology;}; public: Library* getRootLibrary() const {return _rootLibrary;}; + public: static DataBase* getDB(); }; - -// **************************************************************************************************** -// Generic functions -// **************************************************************************************************** - -DataBase* getDataBase(); - - - } // End of Hurricane namespace. diff --git a/hurricane/src/hviewer/Palette.cpp b/hurricane/src/hviewer/Palette.cpp index 2c1451a9..73eb0b19 100644 --- a/hurricane/src/hviewer/Palette.cpp +++ b/hurricane/src/hviewer/Palette.cpp @@ -63,7 +63,7 @@ namespace Hurricane { } gentry->setChecked ( false ); - DataBase* database = getDataBase(); + DataBase* database = DataBase::getDB(); if ( database ) { Technology* technology = database->getTechnology(); if ( technology ) { diff --git a/hurricane/src/isobar/PyDataBase.cpp b/hurricane/src/isobar/PyDataBase.cpp index 4e0c9e4b..4872b47c 100644 --- a/hurricane/src/isobar/PyDataBase.cpp +++ b/hurricane/src/isobar/PyDataBase.cpp @@ -89,7 +89,7 @@ extern "C" { DataBase* db = NULL; HTRY - db = getDataBase (); + db = DataBase::getDB (); if ( db == NULL ) PyErr_SetString ( HurricaneError, "DataBase has not been created yet" ); HCATCH