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 
36 
37 #include "../doc/stage.hpp"
38 
39 #include "actoradapter.hpp"
40 #include "idcollection.hpp"
41 #include "nestedidcollection.hpp"
42 #include "universalid.hpp"
43 #include "cell.hpp"
44 #include "land.hpp"
45 #include "landtexture.hpp"
46 #include "refidcollection.hpp"
47 #include "refcollection.hpp"
48 #include "infocollection.hpp"
49 #include "nestedinfocollection.hpp"
50 #include "pathgrid.hpp"
51 #include "resourcesmanager.hpp"
52 #include "metadata.hpp"
53 #ifndef Q_MOC_RUN
54 #include "subcellcollection.hpp"
55 #endif
56 
57 class QAbstractItemModel;
58 
59 namespace VFS
60 {
61  class Manager;
62 }
63 
64 namespace Fallback
65 {
66  class Map;
67 }
68 
69 namespace ESM
70 {
71  class ESMReader;
72  struct Dialogue;
73 }
74 
75 namespace CSMWorld
76 {
77  class ResourcesManager;
78  class Resources;
79 
80  class Data : public QObject
81  {
82  Q_OBJECT
83 
114  std::unique_ptr<ActorAdapter> mActorAdapter;
116  std::vector<QAbstractItemModel *> mModels;
117  std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
119  const ESM::Dialogue *mDialogue; // last loaded dialogue
120  bool mBase;
121  bool mProject;
122  std::map<std::string, std::map<ESM::RefNum, std::string> > mRefLoadCache;
124 
125  bool mFsStrict;
127  std::vector<std::string> mArchives;
128  std::unique_ptr<VFS::Manager> mVFS;
130  std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
131 
132  std::vector<std::shared_ptr<ESM::ESMReader> > mReaders;
133 
134  std::map<std::string, int> mContentFileNames;
135 
136  // not implemented
137  Data (const Data&);
138  Data& operator= (const Data&);
139 
140  void addModel (QAbstractItemModel *model, UniversalId::Type type,
141  bool update = true);
142 
143  static void appendIds (std::vector<std::string>& ids, const CollectionBase& collection,
144  bool listDeleted);
146 
147  static int count (RecordBase::State state, const CollectionBase& collection);
148 
149  void loadFallbackEntries();
150 
151  public:
152 
153  Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
154  const std::vector<std::string>& archives, const Fallback::Map* fallback,
155  const boost::filesystem::path& resDir);
156 
157  virtual ~Data();
158 
159  const VFS::Manager* getVFS() const;
160 
161  const Fallback::Map* getFallbackMap() const;
162 
163  std::shared_ptr<Resource::ResourceSystem> getResourceSystem();
164 
165  std::shared_ptr<const Resource::ResourceSystem> getResourceSystem() const;
166 
167  const IdCollection<ESM::Global>& getGlobals() const;
168 
170 
172 
174 
175  const IdCollection<ESM::Skill>& getSkills() const;
176 
178 
179  const IdCollection<ESM::Class>& getClasses() const;
180 
182 
184 
186 
187  const IdCollection<ESM::Race>& getRaces() const;
188 
190 
191  const IdCollection<ESM::Sound>& getSounds() const;
192 
194 
195  const IdCollection<ESM::Script>& getScripts() const;
196 
198 
199  const IdCollection<ESM::Region>& getRegions() const;
200 
202 
204 
206 
207  const IdCollection<ESM::Spell>& getSpells() const;
208 
210 
211  const IdCollection<ESM::Dialogue>& getTopics() const;
212 
214 
216 
218 
219  const InfoCollection& getTopicInfos() const;
220 
222 
223  const InfoCollection& getJournalInfos() const;
224 
226 
227  const IdCollection<Cell>& getCells() const;
228 
230 
231  const RefIdCollection& getReferenceables() const;
232 
234 
235  const RefCollection& getReferences() const;
236 
238 
239  const IdCollection<ESM::Filter>& getFilters() const;
240 
242 
244 
246 
248 
250 
252 
254 
255  const IdCollection<CSMWorld::Land>& getLand() const;
256 
258 
260 
262 
264 
266 
268 
270 
272 
274 
276 
278 
280  const Resources& getResources (const UniversalId& id) const;
281 
282  const MetaData& getMetaData() const;
283 
284  void setMetaData (const MetaData& metaData);
285 
291 
292  const ActorAdapter* getActorAdapter() const;
293 
295 
296  void merge();
298 
299  int startLoading (const boost::filesystem::path& path, bool base, bool project);
305 
306  bool continueLoading (CSMDoc::Messages& messages);
308 
309  bool hasId (const std::string& id) const;
310 
311  std::vector<std::string> getIds (bool listDeleted = true) const;
315 
316  int count (RecordBase::State state) const;
318 
319  signals:
320 
321  void idListChanged();
322 
323  void assetTablesChanged();
324 
325  private slots:
326 
327  void assetsChanged();
328 
329  void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
330 
331  void rowsChanged (const QModelIndex& parent, int start, int end);
332  };
333 }
334 
335 #endif
NestedIdCollection< ESM::Spell > mSpells
Definition: data.hpp:95
IdCollection< ESM::MagicEffect > mMagicEffects
Definition: data.hpp:100
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:47
const IdCollection< ESM::MagicEffect > & getMagicEffects() const
Definition: data.cpp:849
const IdCollection< ESM::Sound > & getSounds() const
Definition: data.cpp:658
const IdCollection< ESM::SoundGenerator > & getSoundGens() const
Definition: data.cpp:839
std::vector< std::string > getIds(bool listDeleted=true) const
Definition: data.cpp:1245
IdCollection< ESM::BodyPart > mBodyParts
Definition: data.hpp:99
const ESM::Dialogue * mDialogue
Definition: data.hpp:119
std::shared_ptr< Resource::ResourceSystem > mResourceSystem
Definition: data.hpp:130
Definition: esmreader.hpp:21
const IdCollection< ESM::Class > & getClasses() const
Definition: data.cpp:628
Files::PathContainer mDataPaths
Definition: data.hpp:126
const IdCollection< ESM::Faction > & getFactions() const
Definition: data.cpp:638
IdCollection< ESM::GameSetting > mGmsts
Definition: data.hpp:86
const RefCollection & getReferences() const
Definition: data.cpp:769
bool mFsStrict
Definition: data.hpp:125
NestedIdCollection< ESM::Faction > mFactions
Definition: data.hpp:89
std::vector< std::string > mArchives
Definition: data.hpp:127
const IdCollection< ESM::Script > & getScripts() const
Definition: data.cpp:668
void idListChanged()
const Resources & getResources(const UniversalId &id) const
Throws an exception, if id does not match a resources list.
Definition: data.cpp:879
IdCollection< ESM::Skill > mSkills
Definition: data.hpp:87
static const struct @8 signals[]
void addModel(QAbstractItemModel *model, UniversalId::Type type, bool update=true)
Definition: data.cpp:26
InfoCollection mJournalInfos
Definition: data.hpp:106
contains settings imported from the Morrowind INI file.
Definition: fallback.hpp:12
IdCollection< ESM::Sound > mSounds
Definition: data.hpp:91
Type
Definition: universalid.hpp:40
bool mBase
Definition: data.hpp:120
const IdCollection< ESM::Global > & getGlobals() const
Definition: data.cpp:598
const IdCollection< ESM::Filter > & getFilters() const
Definition: data.cpp:779
int mReaderIndex
Definition: data.hpp:123
IdCollection< ESM::DebugProfile > mDebugProfiles
Definition: data.hpp:102
Definition: resourcesmanager.hpp:16
const IdCollection< ESM::StartScript > & getStartScripts() const
Definition: data.cpp:869
IdCollection< ESM::Filter > mFilters
Definition: data.hpp:112
Single-type record collection.
Definition: collection.hpp:78
Definition: infocollection.hpp:14
const SubCellCollection< Pathgrid > & getPathgrids() const
Definition: data.cpp:859
Definition: messages.hpp:38
const Fallback::Map * mFallbackMap
Definition: data.hpp:115
NestedIdCollection< ESM::Race > mRaces
Definition: data.hpp:90
const ActorAdapter * getActorAdapter() const
Definition: data.cpp:917
std::shared_ptr< Resource::ResourceSystem > getResourceSystem()
Definition: data.cpp:588
Definition: loaddial.hpp:21
std::vector< QAbstractItemModel * > mModels
Definition: data.hpp:116
NestedIdCollection< ESM::BirthSign > mBirthsigns
Definition: data.hpp:94
const IdCollection< ESM::Enchantment > & getEnchantments() const
Definition: data.cpp:789
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: data.cpp:1310
State
Definition: record.hpp:10
NestedIdCollection< ESM::Enchantment > mEnchantments
Definition: data.hpp:98
const IdCollection< ESM::BodyPart > & getBodyParts() const
Definition: data.cpp:799
IdCollection< LandTexture > mLandTextures
Definition: data.hpp:108
IdCollection< ESM::Global > mGlobals
Definition: data.hpp:85
IdCollection< ESM::StartScript > mStartScripts
Definition: data.hpp:104
const InfoCollection & getTopicInfos() const
Definition: data.cpp:729
NestedIdCollection< ESM::Region > mRegions
Definition: data.hpp:93
RefCollection mRefs
Definition: data.hpp:111
ESM::ESMReader * mReader
Definition: data.hpp:118
const VFS::Manager * getVFS() const
Definition: data.cpp:1321
QAbstractItemModel * getTableModel(const UniversalId &id)
Definition: data.cpp:895
const IdCollection< ESM::Race > & getRaces() const
Definition: data.cpp:648
Data & operator=(const Data &)
Definition: metadata.hpp:14
void assetsChanged()
Definition: data.cpp:1273
Definition: resources.hpp:17
const IdCollection< ESM::Spell > & getSpells() const
Definition: data.cpp:698
int startLoading(const boost::filesystem::path &path, bool base, bool project)
Definition: data.cpp:932
std::vector< std::shared_ptr< ESM::ESMReader > > mReaders
Definition: data.hpp:132
void assetTablesChanged()
const IdCollection< ESM::Dialogue > & getJournals() const
Definition: data.cpp:719
Definition: nestedinfocollection.hpp:16
RefIdCollection mReferenceables
Definition: data.hpp:110
Definition: data.hpp:80
const IdCollection< Cell > & getCells() const
Definition: data.cpp:749
IdCollection< ESM::SoundGenerator > mSoundGens
Definition: data.hpp:103
void setMetaData(const MetaData &metaData)
Definition: data.cpp:889
Definition: refidcollection.hpp:40
bool hasId(const std::string &id) const
Definition: data.cpp:1196
FromType
Definition: to_utf8.hpp:11
IdCollection< Land > mLand
Definition: data.hpp:109
SubCellCollection< Pathgrid > mPathgrids
Definition: data.hpp:101
const IdCollection< ESM::Skill > & getSkills() const
Definition: data.cpp:618
ResourcesManager mResourcesManager
Definition: data.hpp:129
static int count(RecordBase::State state, const CollectionBase &collection)
Definition: data.cpp:55
const IdCollection< ESM::BirthSign > & getBirthsigns() const
Definition: data.cpp:688
NestedIdCollection< Cell > mCells
Definition: data.hpp:107
const IdCollection< ESM::Region > & getRegions() const
Definition: data.cpp:678
IdCollection< ESM::Class > mClasses
Definition: data.hpp:88
const InfoCollection & getJournalInfos() const
Definition: data.cpp:739
std::map< std::string, int > mContentFileNames
Definition: data.hpp:134
void rowsChanged(const QModelIndex &parent, int start, int end)
Definition: data.cpp:1316
const Fallback::Map * getFallbackMap() const
Definition: data.cpp:1326
std::map< std::string, std::map< ESM::RefNum, std::string > > mRefLoadCache
Definition: data.hpp:122
std::unique_ptr< VFS::Manager > mVFS
Definition: data.hpp:128
Base class for record collections.
Definition: collectionbase.hpp:23
bool mProject
Definition: data.hpp:121
void loadFallbackEntries()
Definition: data.cpp:977
Single type collection of top level records that are associated with cells.
Definition: pathgridcheck.hpp:12
std::unique_ptr< ActorAdapter > mActorAdapter
Definition: data.hpp:114
IdCollection< ESM::Dialogue > mJournals
Definition: data.hpp:97
const MetaData & getMetaData() const
Definition: data.cpp:884
const IdCollection< ESM::GameSetting > & getGmsts() const
Definition: data.cpp:608
std::map< UniversalId::Type, QAbstractItemModel * > mModelIndex
Definition: data.hpp:117
const IdCollection< CSMWorld::LandTexture > & getLandTextures() const
Definition: data.cpp:829
void merge()
Merge modified into base.
Definition: data.cpp:927
const IdCollection< ESM::DebugProfile > & getDebugProfiles() const
Definition: data.cpp:809
The main class responsible for loading files from a virtual file system.
Definition: manager.hpp:20
Definition: actoradapter.hpp:29
ToUTF8::Utf8Encoder mEncoder
Definition: data.hpp:84
IdCollection< ESM::Dialogue > mTopics
Definition: data.hpp:96
Definition: to_utf8.hpp:25
IdCollection< ESM::Script > mScripts
Definition: data.hpp:92
std::vector< boost::filesystem::path > PathContainer
Definition: gamesettings.hpp:14
NestedInfoCollection mTopicInfos
Definition: data.hpp:105
const IdCollection< CSMWorld::Land > & getLand() const
Definition: data.cpp:819
Collection< MetaData > mMetaData
Definition: data.hpp:113
const IdCollection< ESM::Dialogue > & getTopics() const
Definition: data.cpp:709
const RefIdCollection & getReferenceables() const
Definition: data.cpp:759
bool continueLoading(CSMDoc::Messages &messages)
Definition: data.cpp:1000
References in cells.
Definition: refcollection.hpp:18
virtual ~Data()
Definition: data.cpp:580
Definition: universalid.hpp:12