File: gqbQueryObjs.h

package info (click to toggle)
pgadmin3 1.20.0~beta2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 73,704 kB
  • ctags: 18,591
  • sloc: cpp: 193,786; ansic: 18,736; sh: 5,154; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (195 lines) | stat: -rw-r--r-- 4,875 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// gqbQueryObjs.h - All objects used by a model of a query in the MVC Pattern model.
//
//////////////////////////////////////////////////////////////////////////

#ifndef GQBQUERYOBJS_H
#define GQBQUERYOBJS_H

// wxWindows headers
#include <wx/wx.h>
#include <wx/textctrl.h>

// App headers
#include "gqb/gqbTable.h"
#include "gqb/gqbColumn.h"
#include "gqb/gqbObjectCollection.h"

#define MAXRECTANGLES 10

class gqbQueryObject;
class gqbQueryJoin;

// GQB-TODO: Add all kinds of joins
enum type_Join
{
    _equally,
    _lesser,
    _greater,
    _equlesser,
    _equgreater

};

// Collection of main Query Objects [Tables]
class gqbQueryObjs : public gqbObjectCollection
{
public:
	gqbQueryObjs();								// No destructor, the base destructor destroy collection
	// the unique dynamic object in this class
	void addTable(gqbQueryObject *mtable);		// Uses alias to only allow operations I want to do it.
	void removeTable(gqbQueryObject *mtable);
	gqbIteratorBase *createQueryIterator();
	gqbIteratorBase *createDownQueryIterator();
	int tablesCount();
	void removeAllQueryObjs();
};

// Collection of main Table Objects [Columns] have joins too but in a new variable
class gqbQueryObject : public gqbObjectCollection
{
public:
	gqbQueryObject(gqbTable *table);
	~gqbQueryObject();
	gqbTable *parent;
	wxPoint position;
	void setSelected(bool value);
	bool getSelected();
	void setWidth(int value);
	int getWidth();
	void setHeight(int value);
	int getHeight();
	void removeColumn(gqbColumn *column);		// Used only as synonym for gqbObjectCollection removeObject
	void addColumn(gqbColumn *column);			// Used only as synonym for gqbObjectCollection addObject
	int getColumnIndex(gqbColumn *column);
	bool existsColumn(gqbColumn *column);
	gqbIteratorBase *createQueryTableIterator();
	gqbIteratorBase *createJoinsIterator();
	gqbIteratorBase *createRegJoinsIterator();
	gqbQueryJoin *addJoin(gqbQueryObject *owner, gqbQueryObject *observable, gqbColumn *source, gqbColumn *destination, type_Join kind);
	void removeJoin(gqbQueryJoin *join, bool unRegister);
	void registerJoin(gqbQueryJoin *join);
	void unregisterJoin(gqbQueryJoin *join, bool removeIt);
	bool getHaveJoins();
	bool getHaveRegJoins();
	void setAlias(wxString name)
	{
		alias = name;
	};
	wxString getAlias()
	{
		return alias;
	};

private:
	bool selected;
	wxString alias;
	int width;
	int height;
	bool haveJoins, haveRegisteredJoins;
	gqbCollection *joinsCollection, *registeredCollection;
	gqbArrayCollection *implementationj, *implementationr ;

};

// A Join Object
class gqbQueryJoin : public gqbObject
{
public:
	gqbQueryJoin(gqbQueryObject *_owner, gqbQueryObject *_destination, gqbColumn *sourceCol, gqbColumn *destCol, type_Join joinKind);
	void setKindofJoin(type_Join join);
	type_Join getKindofJoin();
	gqbQueryObject *getSourceQTable();
	gqbQueryObject *getDestQTable();
	gqbColumn *getDCol();
	gqbColumn *getSCol();
	wxString getSourceTable();
	wxString getDestTable();
	wxString getSourceCol();
	wxString getDestCol();
	void setSourceAnchor(wxPoint pt);
	void setDestAnchor(wxPoint pt);
	wxPoint &getSourceAnchor();
	wxPoint &getDestAnchor();
	void setSelected(bool value);
	bool getSelected();
	void setAnchorsUsed(wxPoint pt);
	wxPoint &getAnchorsUsed();

private:
	bool selected;
	type_Join kindofJoin;
	gqbColumn *sCol, *dCol;
	gqbQueryObject *owner, *destination;
	wxPoint sAnchor, dAnchor;         // The source/destination anchor points of the join (for same join)
	wxPoint anchorsUsed;
};

// A Restriction Object
class gqbQueryRestriction : public gqbObject
{
public:
	gqbQueryRestriction();
	wxString &getLeft()
	{
		return leftPart;
	};
	wxString &getRestriction()
	{
		return restriction;
	};
	wxString &getValue_s()
	{
		return value_s;
	};
	wxString &getConnector()
	{
		return connector;
	};
	void setLeft(const wxString &value)
	{
		leftPart = value;
	};
	void setRestriction(const wxString &value)
	{
		restriction = value;
	};
	void setValue_s(const wxString &value)
	{
		value_s = value;
	};
	void setConnector(const wxString &value)
	{
		connector = value;
	};

private:
	wxString leftPart;
	wxString restriction;
	wxString value_s;
	wxString connector;
};

// Collection of restrictions for a where clause
class gqbRestrictions : public gqbObjectCollection
{
public:
	gqbRestrictions();
	~gqbRestrictions();

	void addRestriction(gqbQueryRestriction *r);
	void removeRestriction(gqbQueryRestriction *r);
	void deleteAllRestrictions();
	gqbIteratorBase *createRestrictionsIterator();
	void addRestrictionAt(gqbQueryRestriction *r, int index);
	int restrictionsCount();
	gqbQueryRestriction *getRestrictionAt(int index);

};
#endif