xoreos  0.0.5
2dareg.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef AURORA_2DAREG_H
26 #define AURORA_2DAREG_H
27 
28 #include "src/common/ptrmap.h"
29 #include "src/common/singleton.h"
30 #include "src/common/ustring.h"
31 
32 namespace Aurora {
33 
34 class TwoDAFile;
35 class GDAFile;
36 
58 class TwoDARegistry : public Common::Singleton<TwoDARegistry> {
59 public:
60  TwoDARegistry();
62 
63  void clear();
64 
66  const TwoDAFile &get2DA(const Common::UString &name);
67 
69  const GDAFile &getGDA(const Common::UString &name);
70 
72  const GDAFile &getMGDA(const Common::UString &prefix);
73 
75  void add2DA(const Common::UString &name);
77  void remove2DA(const Common::UString &name);
78 
80  void addGDA(const Common::UString &name);
82  void addMGDA(const Common::UString &prefix);
84  void removeGDA(const Common::UString &name);
85 
86 private:
89 
92 
93  TwoDAFile *load2DA(const Common::UString &name);
94  GDAFile *loadGDA(const Common::UString &name);
96 };
97 
98 } // End of namespace Aurora
99 
101 #define TwoDAReg ::Aurora::TwoDARegistry::instance()
102 
103 #endif // AURORA_2DAREG_H
void addGDA(const Common::UString &name)
Add a certain GDA to the registry, reloading it if necessary.
Definition: 2dareg.cpp:118
Class to hold the two-dimensional array of a 2DA file.
Definition: 2dafile.h:124
Class and macro for implementing singletons.
Common::PtrMap< Common::UString, TwoDAFile > TwoDAMap
Definition: 2dareg.h:87
A map storing pointer to objects, with automatic deletion.
A class holding an UTF-8 string.
Definition: ustring.h:48
void removeGDA(const Common::UString &name)
Remove a certain GDA from the registry.
Definition: 2dareg.cpp:138
TwoDAFile * load2DA(const Common::UString &name)
Definition: 2dareg.cpp:147
GDAFile * loadMGDA(Common::UString prefix)
Definition: 2dareg.cpp:185
GDAFile * loadGDA(const Common::UString &name)
Definition: 2dareg.cpp:166
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:61
const GDAFile & getMGDA(const Common::UString &prefix)
Get a certain multiple GDA, loading it if necessary.
Definition: 2dareg.cpp:83
void remove2DA(const Common::UString &name)
Remove a certain 2DA from the registry.
Definition: 2dareg.cpp:109
void addMGDA(const Common::UString &prefix)
Add a certain multiple GDA to the registry, reloading it if necessary.
Definition: 2dareg.cpp:128
void add2DA(const Common::UString &name)
Add a certain 2DA to the registry, reloading it if necessary.
Definition: 2dareg.cpp:99
Unicode string handling.
Common::PtrMap< Common::UString, GDAFile > GDAMap
Definition: 2dareg.h:88
TwoDAMap _twodas
Definition: 2dareg.h:90
const TwoDAFile & get2DA(const Common::UString &name)
Get a certain 2DA, loading it if necessary.
Definition: 2dareg.cpp:51
The global 2DA registry, holding all current 2DAs.
Definition: 2dareg.h:58
const GDAFile & getGDA(const Common::UString &name)
Get a certain GDA, loading it if necessary.
Definition: 2dareg.cpp:67
Class to hold the GFF&#39;d two-dimensional array of a GDA file.
Definition: gdafile.h:62