Debian Codegraph @

DatabaseExplorer/dbconnection.cpp

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : dbconnection.cpp
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 #include "dbconnection.h"
27
28 XS_IMPLEMENT_CLONABLE_CLASS(DbConnection,xsSerializable);
29
30 DbConnection::DbConnection()
31 {
32 m_pDbAdapter = NULL;
33 }
34 DbConnection::DbConnection(IDbAdapter* dbAdapter, const wxString& serverName)
35 {
36 m_serverName = serverName;
37 m_pDbAdapter = dbAdapter;
38 Load();
39 }
40
41 DbConnection::DbConnection(const DbConnection& obj) : xsSerializable(obj)
42 {
43 m_serverName = obj.m_serverName;
44 m_pDbAdapter = obj.m_pDbAdapter;
45 }
46 DbConnection::~DbConnection()
47 {
48 if (m_pDbAdapter) {
49 delete m_pDbAdapter;
50 m_pDbAdapter = NULL;
51 }
52 }
53
54 void DbConnection::Load()
55 {
56 if (m_pDbAdapter)
57 if (m_pDbAdapter->CanConnect()){
58 m_pDbAdapter->GetDatabases(this);
59 }
60 }
61 void DbConnection::RefreshChildren()
62 {
63 GetChildrenList().DeleteContents(true);
64 GetChildrenList().Clear();
65 Load();
66 }
67