00001 /*************************************************************************** 00002 * Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider, * 00003 * Matthias Hardt, Guido Madaus * 00004 * * 00005 * Copyright (C) 2007-2008 BerLinux Solutions GbR * 00006 * Stefan Schwarzer & Guido Madaus * 00007 * * 00008 * Copyright (C) 2009-2013 BerLinux Solutions GmbH * 00009 * * 00010 * Authors: * 00011 * Stefan Schwarzer <stefan.schwarzer@diskohq.org>, * 00012 * Matthias Hardt <matthias.hardt@diskohq.org>, * 00013 * Jens Schneider <jens.schneider@diskohq.org>, * 00014 * Guido Madaus <guido.madaus@diskohq.org>, * 00015 * Patrick Helterhoff <patrick.helterhoff@diskohq.org>, * 00016 * René Bählkow <rene.baehlkow@diskohq.org> * 00017 * * 00018 * This library is free software; you can redistribute it and/or * 00019 * modify it under the terms of the GNU Lesser General Public * 00020 * License version 2.1 as published by the Free Software Foundation. * 00021 * * 00022 * This library is distributed in the hope that it will be useful, * 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00025 * Lesser General Public License for more details. * 00026 * * 00027 * You should have received a copy of the GNU Lesser General Public * 00028 * License along with this library; if not, write to the * 00029 * Free Software Foundation, Inc., * 00030 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00031 **************************************************************************/ 00032 00033 #ifndef DATASOURCE_H_ 00034 #define DATASOURCE_H_ 00035 00036 #include <string> 00037 00038 using namespace std; 00039 00040 /** 00041 * @file datasource.h 00042 * 00043 * Header file for DataSource class. 00044 * 00045 * @ingroup mmstools 00046 */ 00047 00048 /** 00049 * Configures database settings. 00050 * 00051 * This class defines common settings for databases. 00052 * Be aware that not all databases need user/password or ip connection settings, so they may be ignored. 00053 */ 00054 class DataSource { 00055 00056 private: 00057 string dbms; /**< Defines the database management system to use ("SQLITE3", "FREETDS" or "MYSQL"). */ 00058 string address; /**< Defines the database ip address. */ 00059 unsigned int port; /**< Defines the database port. */ 00060 string dbName; /**< Defines the database name. */ 00061 string user; /**< Defines the username to access the database. */ 00062 string password; /**< Defines the password to access the database. */ 00063 00064 public: 00065 /** 00066 * Constructor for DataSource object. 00067 * 00068 * @note If dbms is an empty string, the default database 00069 * management system (SQLITE3) will be used. 00070 * 00071 * @param dbms database management system 00072 * (currently either "SQLITE3", "FREETDS" or "MYSQL") 00073 * @param dbName database name 00074 * @param address database ip address 00075 * @param port database port 00076 * @param user username to access database 00077 * @param password password to access database 00078 */ 00079 DataSource(const string dbms, 00080 const string dbName, 00081 const string address = "", 00082 const unsigned int port = 0, 00083 const string user = "", 00084 const string password = ""); 00085 00086 /** 00087 * Copy-constructor for DataSource object. 00088 * 00089 * @param d DataSource object to copy 00090 */ 00091 DataSource(const DataSource& d); 00092 00093 /** 00094 * Destructor for DataSource object. 00095 */ 00096 ~DataSource(); 00097 00098 /** 00099 * Sets database management system. 00100 * 00101 * @note If an empty string is provided, the default system 00102 * (SQLITE3) will be used. 00103 * 00104 * @param dbms database management system 00105 * (currently either "SQLITE3", "FREETDS" or "MYSQL" 00106 * 00107 * @see getDBMS() 00108 */ 00109 void setDBMS(const string dbms); 00110 00111 /** 00112 * Gets database management system. 00113 * 00114 * @note If it returns an empty string, sqlite3 will be used. 00115 * 00116 * @returns Either "", "SQLITE3", "FREETDS" or "MYSQL" 00117 * 00118 * @see setDBMS() 00119 */ 00120 const string getDBMS(); 00121 00122 /** 00123 * Sets the ip address for the database connection. 00124 * 00125 * @param address database ip address 00126 * 00127 * @see getAddress() 00128 * @see setPort() 00129 * @see getPort() 00130 */ 00131 void setAddress(const string address); 00132 00133 /** 00134 * Gets the ip address for the database connection. 00135 * 00136 * @returns ip address of database connection 00137 * 00138 * @see setAddress() 00139 * @see setPort() 00140 * @see getPort() 00141 */ 00142 const string getAddress(); 00143 00144 /** 00145 * Sets the port for the database connection. 00146 * 00147 * @param port database port 00148 * 00149 * @see getPort() 00150 * @see setAddress() 00151 * @see getAddress() 00152 */ 00153 void setPort(const unsigned int port); 00154 00155 /** 00156 * Gets the port for the database connection. 00157 * 00158 * @returns database connection port 00159 * 00160 * @see setPort() 00161 * @see setAddress() 00162 * @see getAddress() 00163 */ 00164 const unsigned int getPort(); 00165 00166 /** 00167 * Sets the database name. 00168 * 00169 * @param dbName database name 00170 * 00171 * @see getDatabaseName() 00172 */ 00173 void setDatabaseName(const string dbName); 00174 00175 /** 00176 * Gets the database name. 00177 * 00178 * @returns database name 00179 * 00180 * @see setDatabaseName() 00181 */ 00182 const string getDatabaseName(); 00183 00184 /** 00185 * Sets the user for database access. 00186 * 00187 * @param user user for database access 00188 * 00189 * @see getUser() 00190 * @see setPassword() 00191 * @see getPassword() 00192 */ 00193 void setUser(const string user); 00194 00195 /** 00196 * Gets the user for database access. 00197 * 00198 * @returns user for database access 00199 * 00200 * @see setUser() 00201 * @see setPassword() 00202 * @see getPassword() 00203 */ 00204 const string getUser(); 00205 00206 /** 00207 * Sets the password for database access. 00208 * 00209 * @param password password for database access 00210 * 00211 * @see getPassword() 00212 * @see setUser() 00213 * @see getUser() 00214 */ 00215 void setPassword(const string password); 00216 00217 /** 00218 * Gets the password for database access. 00219 * 00220 * @returns password for database access 00221 * 00222 * @see setPassword() 00223 * @see setUser() 00224 * @see getUser() 00225 */ 00226 const string getPassword(); 00227 }; 00228 00229 #endif /*DATASOURCE_H_*/