This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
/
gqbObjectCollection.cpp
112 lines (83 loc) · 2.5 KB
/
gqbObjectCollection.cpp
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
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// gqbObjectCollection.cpp - A Collection of simple GQB objects
//
//////////////////////////////////////////////////////////////////////////
// App headers
#include "pgAdmin3.h"
// wxWindows headers
#include <wx/wx.h>
// App headers
#include "gqb/gqbObject.h"
#include "gqb/gqbObjectCollection.h"
#include "gqb/gqbCollection.h"
#include "gqb/gqbArrayCollection.h"
gqbObjectCollection::gqbObjectCollection(wxString name, wxTreeItemData *owner, pgConn *connection, OID oid)
: gqbObject(name, owner, connection, oid)
{
// Create the concrete implementation of the Collection, right now only one implementation not need parameter
implementation = new gqbArrayCollection();
// Create the collection using the concrete implementation
// use the array implementation of the collection
objectsCollection = new gqbCollection(implementation);
}
gqbObjectCollection::~gqbObjectCollection()
{
if(objectsCollection) // Implementation is deleted when delete the collection & shouldn't be deleted again
delete objectsCollection;
}
void gqbObjectCollection::addObject(gqbObject *object)
{
objectsCollection->addItem(object);
}
void gqbObjectCollection::removeObject(gqbObject *object)
{
objectsCollection->removeItem(object);
}
gqbIteratorBase *gqbObjectCollection::createIterator()
{
return objectsCollection->createIterator();
}
gqbIteratorBase *gqbObjectCollection::createDownIterator()
{
return objectsCollection->createDownIterator();
}
int gqbObjectCollection::countObjects()
{
return objectsCollection->count();
}
gqbObject *gqbObjectCollection::getObjectAtIndex(int index)
{
return objectsCollection->getItemAt(index);
}
bool gqbObjectCollection::existsObject(gqbObject *object)
{
return objectsCollection->existsObject(object);
}
// Remove all objects from collection without deleting each one.
void gqbObjectCollection::removeAll()
{
objectsCollection->removeAll();
}
int gqbObjectCollection::indexObject(gqbObject *object)
{
return objectsCollection->getIndex(object);
}
void gqbObjectCollection::insertObjectAt(gqbObject *object, int index)
{
objectsCollection->insertAtIndex(object, index);
}
int gqbObjectCollection::getCount()
{
return objectsCollection->count();
}
// Remove & delete all objects
void gqbObjectCollection::deleteAll()
{
objectsCollection->deleteAll();
}