Debian Codegraph @

DatabaseExplorer/column.h

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : column.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 COLUMN_H
27 #define COLUMN_H
28
29 #include <wx/wx.h>
30 #include <wx/dblayer/include/DatabaseResultSet.h>
31 #include <wx/wxxmlserializer/XmlSerializer.h>
32 #include "IDbAdapter.h"
33 #include "IDbType.h"
34
35 // ------------------------------------------------
36 // Trida databazoveho sloupecku
37 // -------------------------------------------------
38 /*! \brief Class representing one table column */
39 class Column : public xsSerializable {
40 protected:
41 wxString m_name;
42 wxString m_parentName;
43
44 IDbType* m_pType;
45 void initSerializable();
46
47 public:
48 // -------------------------------------------------
49 // Konstruktor
50 // -------------------------------------------------
51 XS_DECLARE_CLONABLE_CLASS(Column);
52 /*! \brief Default constuctor*/
53 Column();
54 Column(const Column& obj);
55 Column(const wxString& name,
56 const wxString& parentName,
57 IDbType* type);
58 /*! \brief Default destruktor */
59 virtual ~Column();
60
61 wxString FormatName() {
62 wxString typeDesc;
63 if(m_pType) {
64 typeDesc << m_pType->GetTypeName();
65 if(m_pType->GetSize()) {
66 typeDesc << wxT(" (") << m_pType->GetSize() << wxT(")");
67 }
68 }
69
70 typeDesc.Trim().Trim(false);
71 if(typeDesc.IsEmpty())
72 typeDesc << wxT("<UNKNOWN>");
73
74 wxString formattedName = wxString::Format( wxT("%s : %s"), GetName().c_str(), typeDesc.c_str());
75 return formattedName;
76 }
77
78 /*! \brief Retrun column name */
79 wxString GetName() { return this->m_name; }
80 /*! \brief Set column name */
81 void SetName(const wxString& name) { this->m_name = name; }
82 /*! \brief Return parent name (table) */
83 wxString GetParentName() { return this->m_parentName; }
84
85 /*! \brief Return IDbType */
86 IDbType* GetType(){ return this->m_pType; }
87 /*! \brief Set IDbType */
88 void SetType(IDbType* pType ) { this->m_pType = pType; }
89
90 /*! \brief Function for column editing. */
91 void Edit(wxString& name,
92 wxString& parentName,
93 IDbType* type);
94
95 };
96
97 #endif // COLUMN_H