Debian Codegraph @

DatabaseExplorer/ClassGenerateDialog.h

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : ClassGenerateDialog.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 CLASSGENERATEDIALOG_H
27 #define CLASSGENERATEDIALOG_H
28
29 #include "GUI.h" // Base class: _ClassGenerateDialog
30 #include "ErdTable.h"
31 #include "ErdView.h"
32 #include "table.h"
33 #include "IDbAdapter.h"
34 #include "wx/wxxmlserializer/XmlSerializer.h"
35 #include <wx/textfile.h>
36 #include <wx/stdpaths.h>
37 #include <wx/init.h>
38 #include <wx/hashmap.h>
39
40 #include "../Interfaces/imanager.h"
41 #include "../Plugin/VirtualDirectorySelectorDlg.h"
42 #include "../Plugin/project.h"
43 #include "../Plugin/workspace.h"
44
45 WX_DECLARE_STRING_HASH_MAP(wxString, TemplateMap);
46
47 /*! \brief Dialog for generating classes which are used for database acces. */
48 class ClassGenerateDialog : public _ClassGenerateDialog
49 {
50
51 public:
52 /*! \brief Defautl constructor. */
53 ClassGenerateDialog(wxWindow* parent, IDbAdapter* dbAdapter, xsSerializable* pItems, IManager* pMgr);
54
55 /*! \brief Return string with type name on UNIVERSAL TYPE base */
56 wxString GetTypeName(IDbType::UNIVERSAL_TYPE type);
57 /*! \brief Return string with type name in result format on UNIVERSAL TYPE base */
58 wxString GetResTypeName(IDbType::UNIVERSAL_TYPE type);
59 /*! \brief Return string with type name in Debea format on UNIVERSAL TYPE base */
60 wxString GetDebeaBinding(Column* pCol);
61 /*! \brief Return row for filling table row attribute. */
62 wxString GetFillData(Column* pCol, int colIndex);
63 /*! \brief Return string with type name on UNIVERSAL TYPE base */
64 wxString GetResultFunction(IDbType::UNIVERSAL_TYPE type);
65 /*! \brief Return string with type name in function parameter format on UNIVERSAL TYPE base */
66 wxString GetParamTypeName(IDbType::UNIVERSAL_TYPE type);
67 /*! \brief Return string with type name in add function format on UNIVERSAL TYPE base */
68 wxString GetAddParamFunction(IDbType::UNIVERSAL_TYPE type);
69
70 /*! \brief Function for generating classes for selected table. It call GenerateFile function two times. Fist time
71 * for generate .h, second time for generate .cpp file. */
72 bool GenerateClass(Table* pTab, const wxString& path);
73
74 /*! \brief Function for generating file for selected table. */
75 bool GenerateFile(Table* pTab, wxTextFile& htmpFile, wxString& hFile, const wxString& classItemName,
76 const wxString& classItemDef, const wxString& classColName, const wxString& classTableName,
77 const wxString& classUtilName);
78 /*! \brief Format text file */
79 void FormatFile(wxString& content, const wxFileName& filename);
80
81 virtual void OnCancelClick(wxCommandEvent& event);
82
83 /*! \brief Function for generating classes for all tables. It call GenerateClass() function for each table. */
84 virtual void OnGenerateClick(wxCommandEvent& event);
85 virtual void OnBtnBrowseClick(wxCommandEvent& event);
86
87 virtual ~ClassGenerateDialog();
88
89 protected:
90 TemplateMap m_mapTemplateFiles;
91 IDbAdapter* m_pDbAdapter;
92 xsSerializable* m_pItems;
93 IManager* m_mgr;
94
95 wxString classTableName;
96 wxString classItemName;
97 wxString classItemDef;
98 wxString classColName;
99 wxString classUtilName;
100 };
101
102 #endif // CLASSGENERATEDIALOG_H