| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2014 Eran Ifrah |
| 5 |
// file name : table.h |
| 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 |
#ifndef TABLE_H |
| 27 |
#define TABLE_H |
| 28 |
|
| 29 |
#include <wx/wx.h> |
| 30 |
#include <wx/dblayer/include/DatabaseResultSet.h> |
| 31 |
#include <wx/wxxmlserializer/XmlSerializer.h> |
| 32 |
#include "column.h" |
| 33 |
#include "constraint.h" |
| 34 |
#include "IDbAdapter.h" |
| 35 |
// ------------------------------------------------- |
| 36 |
// Trida databazove tabulky |
| 37 |
// ------------------------------------------------- |
| 38 |
/*! \brief Class representing one database table */ |
| 39 |
class Table : public xsSerializable { |
| 40 |
protected: |
| 41 |
wxString m_name; |
| 42 |
wxString m_parentName; |
| 43 |
IDbAdapter* m_pDbAdapter; |
| 44 |
int m_rowCount; |
| 45 |
bool m_isSaved; |
| 46 |
bool m_isView; |
| 47 |
|
| 48 |
void initSerializable(); |
| 49 |
|
| 50 |
public: |
| 51 |
XS_DECLARE_CLONABLE_CLASS(Table); |
| 52 |
/*! \brief Default consturctors */ |
| 53 |
Table(); |
| 54 |
Table(const Table& obj); |
| 55 |
Table(IDbAdapter* dbAdapter,const wxString& tableName, const wxString& parentName, bool isView); |
| 56 |
/*! \brief Default destructor*/ |
| 57 |
virtual ~Table(); |
| 58 |
/*! \brief Return table name */ |
| 59 |
wxString GetName() { return this->m_name; } |
| 60 |
/*! \brief Return parent name, usually dbName */ |
| 61 |
wxString GetParentName() { return this->m_parentName; } |
| 62 |
/*! \brief Reload children db structure. */ |
| 63 |
void RefreshChildren(); |
| 64 |
/*! \brief Set table name */ |
| 65 |
void SetName(const wxString& name) ; |
| 66 |
|
| 67 |
/*! \brief DEPRECATED. Return row count */ |
| 68 |
int GetRowCount() { return this->m_rowCount; } |
| 69 |
/*! \brief DEPRECATED. Check if table modifications are saved */ |
| 70 |
bool IsSaved() { return this->m_isSaved; } |
| 71 |
/*! \brief Add column */ |
| 72 |
void AddColumn(Column* col) { this->AddChild(col); } |
| 73 |
/*! \brief Add constraint */ |
| 74 |
void AddConstraint(Constraint* cont) { this->AddChild(cont); } |
| 75 |
/*! \brief Return first talbe column */ |
| 76 |
Column* GetFristColumn() { return (Column*) GetFirstChild( CLASSINFO(Column)); } |
| 77 |
/*! \brief Return connected dbAdapter. */ |
| 78 |
IDbAdapter* GetDbAdapter() { return m_pDbAdapter; } |
| 79 |
/*! \brief Is true, if table object was construted on view base. This feature is usisng in code generating. */ |
| 80 |
bool IsView() { return m_isView; } |
| 81 |
/*! \brief Set view parameter. More info in IsView() */ |
| 82 |
void SetView(bool view) { m_isView = view; } |
| 83 |
}; |
| 84 |
|
| 85 |
#endif // TABLE_H |