QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RResourceList.h
Go to the documentation of this file.
1 #ifndef RRESOURCELIST_H
2 #define RRESOURCELIST_H
3 
4 #include <QString>
5 #include <QMap>
6 #include <QFileInfo>
7 
8 #include "RS.h"
9 
15 template <class T>
17 public:
18 // void init() {
19 // }
20 
21  void uninit() {
22  QMapIterator<QString, T*> it(resMap);
23 
24  while (it.hasNext()) {
25  it.next();
26  delete it.value();
27  }
28 
29  resMap.clear();
30  }
31 
35  QStringList getNames() {
36  return resMap.keys();
37  }
38 
43  T* get(const QString& resName) {
44  if (!RS::mapContainsCaseInsensitive(resMap, resName)) {
46  return get(resSubstitutionMap.value(resName));
47  }
48  return NULL;
49  }
50 
51  T* res = RS::mapValueCaseInsensitive(resMap, resName);
52  if (res==NULL) {
53  qWarning("RResourceList::get: list contains NULL resource.");
54  Q_ASSERT(false);
55  return NULL;
56  }
57 
58  if (!res->isLoaded()) {
59  res->load();
60  }
61 
62  return res;
63  }
64 
65 public:
66  QMap<QString, T*> resMap;
67  QMap<QString, QString> resSubstitutionMap;
68 };
69 
70 //template <class T> QMap<QString, T*> RResourceList<T>::resMap;
71 //template <class T> QMap<QString, QString> RResourceList<T>::resSubstitutionMap;
72 
73 #endif