| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeDBConnectionsPool.h
Go to the documentation of this file.

    00001 #ifndef TDK_DB_CONNECTIONSPOOL_H
    00002 #define TDK_DB_CONNECTIONSPOOL_H
    00003
    00004 //STL include files
    00005 #include <iostream>
    00006 #include <map>
    00007 #include <string>
    00008 #include <vector>
    00009
    00010 //TerraLib include files
    00011 #include "TeSingleton.h"
    00012 #include "TeDatabaseFactoryParams.h"
    00013 #include "TeException.h"
    00014
    00015 //foward declarations
    00016 class TeDatabase;
    00017
    00018 class TL_DLL TeDBConnectionsPool : public TeSingleton<TeDBConnectionsPool>
    00019 {
    00020 public:
    00021
    00022            ~TeDBConnectionsPool();
    00023
    00024            TeDatabase* getDatabase(std::string& dbmsName, std::string& dbName,
    00025                             std::string& host, std::string& user,
    00026                             std::string& passwd, int& portNumber);
    00027
    00028 public:
    00029
    00030     TeDatabase* getDatabase(const int& dbIdx);
    00031
    00032     int getDatabaseIdx(TeDatabase* db);
    00033
    00034            void clear();
    00035
    00036     void saveExternalDBConnection(TeDatabase* mainDb, TeDatabase* externalDb);
    00037
    00038            void loadExternalDBConnections(TeDatabase* mainDb);
    00039
    00040            void deleteExternalDBConnection(TeDatabase* mainDb, const int& externalDbId);
    00041
    00042            std::vector<int> getConnectionsIdVector();
    00043
    00044     static void createDBConnectionTable(TeDatabase* db);
    00045
    00046            bool getConnectionInfo(TeDatabase* mainDb,
    00047                                                                                                    const int& connId,
    00048                                                                                                    std::string& hostName,
    00049                                                                                                    std::string& dbmsName,
    00050                                                                                                    std::string& dbName,
    00051                                                                                                    std::string& userName,
    00052                                                                                                    std::string& password,
    00053                                                                                                    int& port);
    00054
    00055 private:
    00056
    00057            void insertDatabase(TeDatabase* db, const int& dbId);
    00058
    00059            void removeDatabase(const int& dbId);
    00060
    00061            std::string getDbKey(const TeDatabaseFactoryParams& dbParams) const;
    00062
    00063            void verifyDbParams(std::string& dbmsName, std::string& dbName,
    00064                                                                                           std::string& host, std::string& user,
    00065                                                                                           std::string& passwd, int& portNumber);
    00066
    00067            TeDatabaseFactoryParams asFactoryParams(const std::string& dbmsName,
    00068                                                                                                                          const std::string& dbName,
    00069                                                                                                                          const std::string& host, const std::string& user,
    00070                                                                                                                          const std::string& passwd, const int& portNumber);
    00071
    00072     std::map<std::string, int> _dbConns;
    00073     std::map<int, TeDatabase*> _dbs;
    00074 };
    00075
    00076 #endif //TDK_DB_CONNECTIONSPOOL_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines