Ilwis-Objects  1.0
GIS and Remote Sensing framework for data access and processing
 All Classes Functions Enumerations Pages
mastercatalog.h
1 #ifndef MASTERCATALOG_H
2 #define MASTERCATALOG_H
3 
4 #include <QMultiMap>
5 #include <QSqlQuery>
6 #include <set>
7 #include "Kernel_global.h"
8 
9 namespace Ilwis {
10 
11 class Resource;
12 class CatalogConnector;
13 
14 typedef std::shared_ptr<IlwisObject> ESPIlwisObject;
22 class KERNELSHARED_EXPORT MasterCatalog
23 {
24  friend KERNELSHARED_EXPORT MasterCatalog* mastercatalog();
25 
26 public:
30  MasterCatalog();
31 
32  ~MasterCatalog();
33 
39  bool prepare();
40 
47  bool addContainer(const QUrl &location);
48 
54  bool addItems(const std::vector<Ilwis::Resource> &items);
55 
56 
62  bool removeItems(const QList<Resource> &items);
63 
71  quint64 url2id(const QUrl& url, IlwisTypes tp) const;
72 
81  Resource name2Resource(const QString& name, IlwisTypes tp = itUNKNOWN) const;
82 
89  Resource id2Resource(quint64 iid) const;
90 
99  quint64 name2id(const QString& name, IlwisTypes tp= itUNKNOWN) const;
100 
106  IlwisTypes id2type(quint64 id) const;
107 
112  quint64 createId() const;
113 
118  void registerObject(ESPIlwisObject &data);
119 
125  bool isRegistered(quint64 id) const;
126 
132  bool unregister(quint64);
133 
141  //TODO select language, finish docu
142  std::vector<Resource> select(const QUrl& resource, const QString& selection) const;
143 
152  QUrl name2url(const QString &name, IlwisTypes tp=itUNKNOWN) const;
153 
160  ESPIlwisObject get(const QUrl &resource, IlwisTypes type) const;
161 
167  ESPIlwisObject get(quint64 id) const;
168 
176  bool contains(const QUrl &url, IlwisTypes type) const;
177 
178  bool usesContainers(const QUrl &scheme) const;
179  void addContainerException(const QString& scheme);
180 
181 #ifdef QT_DEBUG
182  quint32 lookupSize() const { return _lookup.size(); }
183  void dumpLookup() const;
184  quint32 usecount(quint64 id);
185 
186 #endif
187 private:
188  static MasterCatalog *_masterCatalog;
189  quint64 _baseid;
190  QHash<quint64, ESPIlwisObject> _lookup;
191  std::set<QUrl> _catalogs;
192  std::set<uint> _knownHashes;
193  std::set<QString> _containerExceptions; // for some schemes the mastercatelog shouldnt try to find containers as they dont make sense;
194 
195 
196 };
197 
198 //typedef QHash<IlwisResource, QList<CatalogCreate> > CatalogCollection;
199 
200 KERNELSHARED_EXPORT MasterCatalog* mastercatalog();
201 
202 }
203 
204 
205 
206 
207 
208 
209 #endif // MASTERCATALOG_H