get rid of global functions :
getDataBase() -> DataBase::getDB()
This commit is contained in:
parent
b7bd1e19a4
commit
f47f6b92e5
|
@ -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;
|
/*! \function Technology* DataBase::getTechnology () const;
|
||||||
* \return the Technology if it exists, else \NULL.
|
* \return the Technology if it exists, else \NULL.
|
||||||
*/
|
*/
|
||||||
|
@ -51,18 +57,6 @@
|
||||||
* \return the root Library if it exists, else \NULL.
|
* \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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// \}
|
// \}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Hurricane {
|
||||||
// DataBase implementation
|
// DataBase implementation
|
||||||
// ****************************************************************************************************
|
// ****************************************************************************************************
|
||||||
|
|
||||||
static DataBase* DATA_BASE = NULL;
|
DataBase* DataBase::_db = NULL;
|
||||||
|
|
||||||
DataBase::DataBase()
|
DataBase::DataBase()
|
||||||
// *****************
|
// *****************
|
||||||
|
@ -28,7 +28,7 @@ DataBase::DataBase()
|
||||||
_technology(NULL),
|
_technology(NULL),
|
||||||
_rootLibrary(NULL)
|
_rootLibrary(NULL)
|
||||||
{
|
{
|
||||||
if (DATA_BASE)
|
if (_db)
|
||||||
throw Error("Can't create " + _TName("DataBase") + " : already exists");
|
throw Error("Can't create " + _TName("DataBase") + " : already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ void DataBase::_postCreate()
|
||||||
{
|
{
|
||||||
Inherit::_postCreate();
|
Inherit::_postCreate();
|
||||||
|
|
||||||
DATA_BASE = this;
|
_db = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataBase::_preDestroy()
|
void DataBase::_preDestroy()
|
||||||
|
@ -60,7 +60,7 @@ void DataBase::_preDestroy()
|
||||||
if (_technology) _technology->destroy();
|
if (_technology) _technology->destroy();
|
||||||
UpdateSession::close();
|
UpdateSession::close();
|
||||||
|
|
||||||
DATA_BASE = NULL;
|
_db = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
string DataBase::_getString() const
|
string DataBase::_getString() const
|
||||||
|
@ -83,14 +83,10 @@ Record* DataBase::_getRecord() const
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****************************************************************************************************
|
DataBase* DataBase::getDB()
|
||||||
// Generic functions
|
// ************************
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
DataBase* getDataBase()
|
|
||||||
// ********************
|
|
||||||
{
|
{
|
||||||
return DATA_BASE;
|
return _db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ class DataBase : public DBo {
|
||||||
// Attributes
|
// Attributes
|
||||||
// **********
|
// **********
|
||||||
|
|
||||||
|
private: static DataBase* _db;
|
||||||
private: Technology* _technology;
|
private: Technology* _technology;
|
||||||
private: Library* _rootLibrary;
|
private: Library* _rootLibrary;
|
||||||
|
|
||||||
|
@ -65,18 +66,10 @@ class DataBase : public DBo {
|
||||||
|
|
||||||
public: Technology* getTechnology() const {return _technology;};
|
public: Technology* getTechnology() const {return _technology;};
|
||||||
public: Library* getRootLibrary() const {return _rootLibrary;};
|
public: Library* getRootLibrary() const {return _rootLibrary;};
|
||||||
|
public: static DataBase* getDB();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Generic functions
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
DataBase* getDataBase();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // End of Hurricane namespace.
|
} // End of Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
gentry->setChecked ( false );
|
gentry->setChecked ( false );
|
||||||
|
|
||||||
DataBase* database = getDataBase();
|
DataBase* database = DataBase::getDB();
|
||||||
if ( database ) {
|
if ( database ) {
|
||||||
Technology* technology = database->getTechnology();
|
Technology* technology = database->getTechnology();
|
||||||
if ( technology ) {
|
if ( technology ) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ extern "C" {
|
||||||
DataBase* db = NULL;
|
DataBase* db = NULL;
|
||||||
|
|
||||||
HTRY
|
HTRY
|
||||||
db = getDataBase ();
|
db = DataBase::getDB ();
|
||||||
if ( db == NULL )
|
if ( db == NULL )
|
||||||
PyErr_SetString ( HurricaneError, "DataBase has not been created yet" );
|
PyErr_SetString ( HurricaneError, "DataBase has not been created yet" );
|
||||||
HCATCH
|
HCATCH
|
||||||
|
|
Loading…
Reference in New Issue