Aimsun Next Scripting  22
Public Member Functions | Static Public Member Functions | List of all members
GKDataBaseInfo Class Reference

Public Member Functions

 GKDataBaseInfo ()
 
bool useProjectDB () const
 
void setUseProjectDB (bool value)
 
bool isAutomatic () const
 
void setAutomatic (bool value)
 
bool isAutomaticallyCreated () const
 
void setAutomaticallyCreated (bool value)
 
void setDatabaseName (const QString &)
 
void setUserName (const QString &)
 
void setPassword (const QString &)
 
void setHostName (const QString &)
 
void setDriverName (const QString &)
 
void setPort (int)
 
QString getDatabaseName (GKModel *model) const
 
const QString & getUserName () const
 
const QString & getPassword () const
 
const QString & getHostName () const
 
const QString & getDriverName () const
 
int getPort () const
 
QString toString (bool withPasswd=false) const
 
void fromString (const QString &urlStr)
 
bool isEmpty () const
 
void clear ()
 
bool checkConnection (QString &errorString) const
 
bool checkWritetable (GKModel *model, QString &errorString) const
 
bool isComplete () const
 
bool isFileBased () const
 

Static Public Member Functions

static bool driverIsFileBased (const QString &driver)
 
static bool driverNeedsLogin (const QString &driver)
 

Detailed Description

Some components of Aimsun can store data in external (to Aimsun database) databases. For example OD matrices (GKODMatrix using GKModel::setDatabase) or Aimsun Next Simulators statistical data. This class hold the information about the database to use.

To ask Aimsun Model to use a ODBC database you will:

GKModel *model;
info.setDatabaseName( "MY DATASOURCE NAME" );
info.setDriverName( "QODBC3" );
model->setDatabase( info );
This class holds information about a database using in Aimsun Next.
Definition: GKDataBaseInfo.sip:40
void setDriverName(const QString &)
void setDatabaseName(const QString &)
This class contains all the objects in a model.
Definition: GKModel.sip:62

The database can be automatic (false by default). In this case Aimsun Next will create and manage the database for the user without asking for a file. The supported automatic ones are SQLite (MAC OS X, Linux, Windows) and Access (Windows). In Windows, the user can select the driver to use.

Constructor & Destructor Documentation

◆ GKDataBaseInfo()

GKDataBaseInfo::GKDataBaseInfo ( )

Member Function Documentation

◆ checkConnection()

bool GKDataBaseInfo::checkConnection ( QString &  errorString) const

Checks that the database can be opened. It will open and then close the db. errorStr will report any error.

◆ checkWritetable()

bool GKDataBaseInfo::checkWritetable ( GKModel model,
QString &  errorString 
) const

Checks that the database is writable. It will open, create a table, do an insert and then close the db. errorStr will report any error.

◆ clear()

void GKDataBaseInfo::clear ( )

Reset this object.

◆ driverIsFileBased()

static bool GKDataBaseInfo::driverIsFileBased ( const QString &  driver)
static

Helper function: returns true if the given driver is file-based (currently Access and SQLite))

◆ driverNeedsLogin()

static bool GKDataBaseInfo::driverNeedsLogin ( const QString &  driver)
static

Helper function: returns true if the given driver needs server and login data (currently anything not being Access & SQLite)

◆ fromString()

void GKDataBaseInfo::fromString ( const QString &  urlStr)

Parses the string and constructs the GKDataBaseInfo object. The string must be compliant with the format used by toString() function.

◆ getDatabaseName()

QString GKDataBaseInfo::getDatabaseName ( GKModel model) const

Database name. If using QODBC3, the datasource name. If Access or SQLite the file. A model is required when using the automatic mode.

◆ getDriverName()

const QString & GKDataBaseInfo::getDriverName ( ) const

Type of database. Possible values are:

  • QODBC3
  • QSQLITE
  • ACCESS
  • Any other supported by the installed Qt sqldrivers

◆ getHostName()

const QString & GKDataBaseInfo::getHostName ( ) const

Host name where the database is. Some databases doesn't require a host name (Access, SQLite, ODBC connections to Access or SQLite).

◆ getPassword()

const QString & GKDataBaseInfo::getPassword ( ) const

Password. Some databases doesn't require a password (Access for example). Note: password data is not encripted

◆ getPort()

int GKDataBaseInfo::getPort ( ) const

TCP/IP port where the database listener is. Some databases doesn't require a port (Access, SQLite, ODBC connections to Access or SQLite).

◆ getUserName()

const QString & GKDataBaseInfo::getUserName ( ) const

Password. Some databases doesn't require a password (Access for example). Note: password data is not encripted

◆ isAutomatic()

bool GKDataBaseInfo::isAutomatic ( ) const

Automatic database?

◆ isAutomaticallyCreated()

bool GKDataBaseInfo::isAutomaticallyCreated ( ) const

Create the database automatically using the current name (is isAutomatic the name will be set too)

◆ isComplete()

bool GKDataBaseInfo::isComplete ( ) const

Checks if the object has all the required data to connect to the database. For file-based drivers, this means checking if the file is defined. For server-based driver, the server and login data are also mandatory.

◆ isEmpty()

bool GKDataBaseInfo::isEmpty ( ) const

Returns true if is empty (no db name)

◆ isFileBased()

bool GKDataBaseInfo::isFileBased ( ) const

◆ setAutomatic()

void GKDataBaseInfo::setAutomatic ( bool  value)

Automatic database?

◆ setAutomaticallyCreated()

void GKDataBaseInfo::setAutomaticallyCreated ( bool  value)

Create the database automatically using the current name (is isAutomatic the name will be set too)

◆ setDatabaseName()

void GKDataBaseInfo::setDatabaseName ( const QString &  )

Database name. If using QODBC3, the datasource name. If Access or SQLite the file.

◆ setDriverName()

void GKDataBaseInfo::setDriverName ( const QString &  )

Type of database. Possible values are:

  • QODBC3
  • QSQLITE
  • ACCESS
  • Any other supported by the installed Qt sqldrivers

◆ setHostName()

void GKDataBaseInfo::setHostName ( const QString &  )

Host name where the database is. Some databases doesn't require a host name (Access, SQLite, ODBC connections for Access or SQLite).

◆ setPassword()

void GKDataBaseInfo::setPassword ( const QString &  )

Password. Some databases doesn't require a password (Access for example). Note: password data is not encripted

◆ setPort()

void GKDataBaseInfo::setPort ( int  )

TCP/IP port where the database listener is. Some databases doesn't require a port (Access, SQLite, ODBC connections to Access or SQLite).

◆ setUseProjectDB()

void GKDataBaseInfo::setUseProjectDB ( bool  value)

If true, use the project DB instead of this DB

◆ setUserName()

void GKDataBaseInfo::setUserName ( const QString &  )

User name. Some databases doesn't require a user name (Access for example).

◆ toString()

QString GKDataBaseInfo::toString ( bool  withPasswd = false) const

Returns a string representation of this object as a URL. The format is the following:

  • For server-based DBs: "driver://user[:pass]@server:port/schema"
  • for file-based DB's: "driver://user[:pass]@filepath"
Parameters
withPasswdif true, the password will also be included in the string

◆ useProjectDB()

bool GKDataBaseInfo::useProjectDB ( ) const

If true, use the project DB instead of this DB

© Aimsun SLU
Aimsun ®