Debian Codegraph @

DatabaseExplorer/constraint.h

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : constraint.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 CONSTRAINT_H
27 #define CONSTRAINT_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
34 /*! \brief Class representing one table constraint. */
35 class Constraint : public xsSerializable {
36
37 public:
38 /*! \brief Constraint type enum */
39 enum constraintType {
40 primaryKey,
41 foreignKey,
42 noKey
43 };
44 /*! \brief Constraint action enum */
45 enum constraintAction {
46 restrict,
47 cascade,
48 setNull,
49 noAction
50 };
51
52 XS_DECLARE_CLONABLE_CLASS(Constraint);
53 /*! \brief Default constructors */
54 Constraint();
55 Constraint(const Constraint& obj);
56 Constraint(const wxString& name, const wxString& localColumn, constraintType type, constraintAction onDelete, constraintAction onUpdate);
57 /*! \brief Default destructors */
58 virtual ~Constraint();
59
60 /*! \brief Set local column name */
61 void SetLocalColumn(const wxString & localColumn) {
62 this->m_localColumn = localColumn;
63 }
64 /*! \brief Set constraint name */
65 void SetName(const wxString & name) {
66 this->m_name = name;
67 }
68 /*! \brief Set reference column name */
69 void SetRefCol(const wxString & refCol) {
70 this->m_refCol = refCol;
71 }
72 /*! \brief Set reference table name */
73 void SetRefTable(const wxString & refTable) {
74 this->m_refTable = refTable;
75 }
76 /*! \brief Set constraint type */
77 void SetType(constraintType type) {
78 this->m_type = type;
79 }
80 /*! \brief Set action OnDelete */
81 void SetOnDelete(constraintAction onDelete) {
82 this->m_onDelete = onDelete;
83 }
84 /*! \brief Set action OnUpdate */
85 void SetOnUpdate(constraintAction onUpdate) {
86 this->m_onUpdate = onUpdate;
87 }
88 /*! \brief Get action OnDelete */
89 constraintAction GetOnDelete() const {
90 return m_onDelete;
91 }
92 /*! \brief Get action OnUpdate */
93 constraintAction GetOnUpdate() const {
94 return m_onUpdate;
95 }
96 /*! \brief Get local column name */
97 const wxString & GetLocalColumn() const {
98 return m_localColumn;
99 }
100 /*! \brief Get constraint name */
101 const wxString & GetName() const {
102 return m_name;
103 }
104 /*! \brief Get reference column name */
105 const wxString & GetRefCol() const {
106 return m_refCol;
107 }
108 /*! \brief Get reference table name */
109 const wxString & GetRefTable() const {
110 return m_refTable;
111 }
112 /*! \brief Get constraint type */
113 constraintType GetType() const {
114 return m_type;
115 }
116
117 protected:
118 constraintType m_type;
119 wxString m_name;
120 wxString m_localColumn;
121 wxString m_refTable;
122 wxString m_refCol;
123 constraintAction m_onDelete;
124 constraintAction m_onUpdate;
125
126 void InitSerializable();
127 };
128
129 #endif // CONSTRAINT_H