OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
data.hpp
Go to the documentation of this file.
1 #ifndef CSM_WOLRD_DATA_H
2 #define CSM_WOLRD_DATA_H
3 
4 #include <map>
5 #include <vector>
6 
7 #include <boost/filesystem/path.hpp>
8 
9 #include <QObject>
10 #include <QModelIndex>
11 
31 
33 
35 
36 #include "../doc/stage.hpp"
37 
38 #include "idcollection.hpp"
39 #include "nestedidcollection.hpp"
40 #include "universalid.hpp"
41 #include "cell.hpp"
42 #include "land.hpp"
43 #include "landtexture.hpp"
44 #include "refidcollection.hpp"
45 #include "refcollection.hpp"
46 #include "infocollection.hpp"
47 #include "nestedinfocollection.hpp"
48 #include "pathgrid.hpp"
49 #include "metadata.hpp"
50 #ifndef Q_MOC_RUN
51 #include "subcellcollection.hpp"
52 #endif
53 
54 class QAbstractItemModel;
55 
56 namespace VFS
57 {
58  class Manager;
59 }
60 
61 namespace Fallback
62 {
63  class Map;
64 }
65 
66 namespace ESM
67 {
68  class ESMReader;
69  struct Dialogue;
70 }
71 
72 namespace CSMWorld
73 {
74  class ResourcesManager;
75  class Resources;
76 
77  class Data : public QObject
78  {
79  Q_OBJECT
80 
113  std::vector<QAbstractItemModel *> mModels;
114  std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
116  const ESM::Dialogue *mDialogue; // last loaded dialogue
117  bool mBase;
118  bool mProject;
119  std::map<std::string, std::map<ESM::RefNum, std::string> > mRefLoadCache;
121 
122  boost::shared_ptr<Resource::ResourceSystem> mResourceSystem;
123 
124  std::vector<boost::shared_ptr<ESM::ESMReader> > mReaders;
125 
126  std::map<std::string, int> mContentFileNames;
127 
128  // not implemented
129  Data (const Data&);
130  Data& operator= (const Data&);
131 
132  void addModel (QAbstractItemModel *model, UniversalId::Type type,
133  bool update = true);
134 
135  static void appendIds (std::vector<std::string>& ids, const CollectionBase& collection,
136  bool listDeleted);
138 
139  static int count (RecordBase::State state, const CollectionBase& collection);
140 
141  public:
142 
143  Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir);
144 
145  virtual ~Data();
146 
147  const VFS::Manager* getVFS() const;
148 
149  const Fallback::Map* getFallbackMap() const;
150 
151  boost::shared_ptr<Resource::ResourceSystem> getResourceSystem();
152 
153  boost::shared_ptr<const Resource::ResourceSystem> getResourceSystem() const;
154 
155  const IdCollection<ESM::Global>& getGlobals() const;
156 
158 
160 
162 
163  const IdCollection<ESM::Skill>& getSkills() const;
164 
166 
167  const IdCollection<ESM::Class>& getClasses() const;
168 
170 
172 
174 
175  const IdCollection<ESM::Race>& getRaces() const;
176 
178 
179  const IdCollection<ESM::Sound>& getSounds() const;
180 
182 
183  const IdCollection<ESM::Script>& getScripts() const;
184 
186 
187  const IdCollection<ESM::Region>& getRegions() const;
188 
190 
192 
194 
195  const IdCollection<ESM::Spell>& getSpells() const;
196 
198 
199  const IdCollection<ESM::Dialogue>& getTopics() const;
200 
202 
204 
206 
207  const InfoCollection& getTopicInfos() const;
208 
210 
211  const InfoCollection& getJournalInfos() const;
212 
214 
215  const IdCollection<Cell>& getCells() const;
216 
218 
219  const RefIdCollection& getReferenceables() const;
220 
222 
223  const RefCollection& getReferences() const;
224 
226 
227  const IdCollection<ESM::Filter>& getFilters() const;
228 
230 
232 
234 
236 
238 
240 
242 
243  const IdCollection<CSMWorld::Land>& getLand() const;
244 
246 
248 
250 
252 
254 
256 
258 
260 
262 
264 
266 
268  const Resources& getResources (const UniversalId& id) const;
269 
270  const MetaData& getMetaData() const;
271 
272  void setMetaData (const MetaData& metaData);
273 
279 
280  void merge();
282 
283  int startLoading (const boost::filesystem::path& path, bool base, bool project);
289 
290  bool continueLoading (CSMDoc::Messages& messages);
292 
293  bool hasId (const std::string& id) const;
294 
295  std::vector<std::string> getIds (bool listDeleted = true) const;
299 
300  int count (RecordBase::State state) const;
302 
303  signals:
304 
305  void idListChanged();
306 
307  private slots:
308 
309  void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
310 
311  void rowsChanged (const QModelIndex& parent, int start, int end);
312  };
313 }
314 
315 #endif
NestedIdCollection< ESM::Spell > mSpells
Definition: data.hpp:92
IdCollection< ESM::MagicEffect > mMagicEffects
Definition: data.hpp:97
Data(const Data &)
static void appendIds(std::vector< std::string > &ids, const CollectionBase &collection, bool listDeleted)
Append all IDs from collection to ids.
Definition: data.cpp:45
const IdCollection< ESM::MagicEffect > & getMagicEffects() const
Definition: data.cpp:818
const IdCollection< ESM::Sound > & getSounds() const
Definition: data.cpp:627
const IdCollection< ESM::SoundGenerator > & getSoundGens() const
Definition: data.cpp:808
static const struct @2 signals[]
boost::shared_ptr< Resource::ResourceSystem > mResourceSystem
Definition: data.hpp:122
std::vector< std::string > getIds(bool listDeleted=true) const
Definition: data.cpp:1190
IdCollection< ESM::BodyPart > mBodyParts
Definition: data.hpp:96
const ESM::Dialogue * mDialogue
Definition: data.hpp:116
Definition: esmreader.hpp:21
const IdCollection< ESM::Class > & getClasses() const
Definition: data.cpp:597
const IdCollection< ESM::Faction > & getFactions() const
Definition: data.cpp:607
IdCollection< ESM::GameSetting > mGmsts
Definition: data.hpp:83
const RefCollection & getReferences() const
Definition: data.cpp:738
NestedIdCollection< ESM::Faction > mFactions
Definition: data.hpp:86
const IdCollection< ESM::Script > & getScripts() const
Definition: data.cpp:637
void idListChanged()
const Resources & getResources(const UniversalId &id) const
Throws an exception, if id does not match a resources list.
Definition: data.cpp:848
IdCollection< ESM::Skill > mSkills
Definition: data.hpp:84
void addModel(QAbstractItemModel *model, UniversalId::Type type, bool update=true)
Definition: data.cpp:24
InfoCollection mJournalInfos
Definition: data.hpp:103
contains settings imported from the Morrowind INI file.
Definition: fallback.hpp:12
IdCollection< ESM::Sound > mSounds
Definition: data.hpp:88
Type
Definition: universalid.hpp:40
bool mBase
Definition: data.hpp:117
const IdCollection< ESM::Global > & getGlobals() const
Definition: data.cpp:567
const IdCollection< ESM::Filter > & getFilters() const
Definition: data.cpp:748
int mReaderIndex
Definition: data.hpp:120
IdCollection< ESM::DebugProfile > mDebugProfiles
Definition: data.hpp:99
Definition: resourcesmanager.hpp:16
const IdCollection< ESM::StartScript > & getStartScripts() const
Definition: data.cpp:838
boost::shared_ptr< Resource::ResourceSystem > getResourceSystem()
Definition: data.cpp:557
IdCollection< ESM::Filter > mFilters
Definition: data.hpp:109
const ResourcesManager & mResourcesManager
Definition: data.hpp:111
Single-type record collection.
Definition: collection.hpp:44
Definition: infocollection.hpp:14
const SubCellCollection< Pathgrid > & getPathgrids() const
Definition: data.cpp:828
Definition: messages.hpp:38
const Fallback::Map * mFallbackMap
Definition: data.hpp:112
NestedIdCollection< ESM::Race > mRaces
Definition: data.hpp:87
Definition: loaddial.hpp:21
std::vector< QAbstractItemModel * > mModels
Definition: data.hpp:113
NestedIdCollection< ESM::BirthSign > mBirthsigns
Definition: data.hpp:91
const IdCollection< ESM::Enchantment > & getEnchantments() const
Definition: data.cpp:758
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: data.cpp:1218
State
Definition: record.hpp:10
NestedIdCollection< ESM::Enchantment > mEnchantments
Definition: data.hpp:95
const IdCollection< ESM::BodyPart > & getBodyParts() const
Definition: data.cpp:768
IdCollection< LandTexture > mLandTextures
Definition: data.hpp:105
IdCollection< ESM::Global > mGlobals
Definition: data.hpp:82
IdCollection< ESM::StartScript > mStartScripts
Definition: data.hpp:101
const InfoCollection & getTopicInfos() const
Definition: data.cpp:698
NestedIdCollection< ESM::Region > mRegions
Definition: data.hpp:90
RefCollection mRefs
Definition: data.hpp:108
ESM::ESMReader * mReader
Definition: data.hpp:115
const VFS::Manager * getVFS() const
Definition: data.cpp:1229
QAbstractItemModel * getTableModel(const UniversalId &id)
Definition: data.cpp:864
const IdCollection< ESM::Race > & getRaces() const
Definition: data.cpp:617
Data & operator=(const Data &)
Definition: metadata.hpp:14
Definition: resources.hpp:17
const IdCollection< ESM::Spell > & getSpells() const
Definition: data.cpp:667
int startLoading(const boost::filesystem::path &path, bool base, bool project)
Definition: data.cpp:891
const IdCollection< ESM::Dialogue > & getJournals() const
Definition: data.cpp:688
Definition: nestedinfocollection.hpp:16
RefIdCollection mReferenceables
Definition: data.hpp:107
Definition: data.hpp:77
const IdCollection< Cell > & getCells() const
Definition: data.cpp:718
IdCollection< ESM::SoundGenerator > mSoundGens
Definition: data.hpp:100
void setMetaData(const MetaData &metaData)
Definition: data.cpp:858
Definition: refidcollection.hpp:40
bool hasId(const std::string &id) const
Definition: data.cpp:1141
FromType
Definition: to_utf8.hpp:11
IdCollection< Land > mLand
Definition: data.hpp:106
std::vector< boost::shared_ptr< ESM::ESMReader > > mReaders
Definition: data.hpp:124
SubCellCollection< Pathgrid > mPathgrids
Definition: data.hpp:98
const IdCollection< ESM::Skill > & getSkills() const
Definition: data.cpp:587
static int count(RecordBase::State state, const CollectionBase &collection)
Definition: data.cpp:53
const IdCollection< ESM::BirthSign > & getBirthsigns() const
Definition: data.cpp:657
NestedIdCollection< Cell > mCells
Definition: data.hpp:104
const IdCollection< ESM::Region > & getRegions() const
Definition: data.cpp:647
IdCollection< ESM::Class > mClasses
Definition: data.hpp:85
const InfoCollection & getJournalInfos() const
Definition: data.cpp:708
std::map< std::string, int > mContentFileNames
Definition: data.hpp:126
void rowsChanged(const QModelIndex &parent, int start, int end)
Definition: data.cpp:1224
const Fallback::Map * getFallbackMap() const
Definition: data.cpp:1234
std::map< std::string, std::map< ESM::RefNum, std::string > > mRefLoadCache
Definition: data.hpp:119
Base class for record collections.
Definition: collectionbase.hpp:23
bool mProject
Definition: data.hpp:118
Single type collection of top level records that are associated with cells.
Definition: pathgridcheck.hpp:12
IdCollection< ESM::Dialogue > mJournals
Definition: data.hpp:94
const MetaData & getMetaData() const
Definition: data.cpp:853
const IdCollection< ESM::GameSetting > & getGmsts() const
Definition: data.cpp:577
std::map< UniversalId::Type, QAbstractItemModel * > mModelIndex
Definition: data.hpp:114
const IdCollection< CSMWorld::LandTexture > & getLandTextures() const
Definition: data.cpp:798
void merge()
Merge modified into base.
Definition: data.cpp:886
const IdCollection< ESM::DebugProfile > & getDebugProfiles() const
Definition: data.cpp:778
The main class responsible for loading files from a virtual file system.
Definition: manager.hpp:20
ToUTF8::Utf8Encoder mEncoder
Definition: data.hpp:81
IdCollection< ESM::Dialogue > mTopics
Definition: data.hpp:93
Definition: to_utf8.hpp:25
IdCollection< ESM::Script > mScripts
Definition: data.hpp:89
NestedInfoCollection mTopicInfos
Definition: data.hpp:102
const IdCollection< CSMWorld::Land > & getLand() const
Definition: data.cpp:788
Collection< MetaData > mMetaData
Definition: data.hpp:110
const IdCollection< ESM::Dialogue > & getTopics() const
Definition: data.cpp:678
const RefIdCollection & getReferenceables() const
Definition: data.cpp:728
bool continueLoading(CSMDoc::Messages &messages)
Definition: data.cpp:936
References in cells.
Definition: refcollection.hpp:18
virtual ~Data()
Definition: data.cpp:549
Definition: universalid.hpp:12