summaryrefslogtreecommitdiff
path: root/apps/openmw/mwworld/globals.hpp
blob: 5b414971f6e5681c504905d0209f244c83fc0058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef GAME_MWWORLD_GLOBALS_H
#define GAME_MWWORLD_GLOBALS_H

#include <vector>
#include <string>
#include <map>

#include <stdint.h>

#include <components/esm3/loadglob.hpp>

namespace ESM
{
    class ESMWriter;
    class ESMReader;
}

namespace Loading
{
    class Listener;
}

namespace MWWorld
{
    class ESMStore;

    class Globals
    {
        private:

            typedef std::map<std::string, ESM::Global> Collection;

            Collection mVariables; // type, value

            Collection::const_iterator find (const std::string& name) const;

            Collection::iterator find (const std::string& name);

        public:

            const ESM::Variant& operator[] (const std::string& name) const;

            ESM::Variant& operator[] (const std::string& name);

            char getType (const std::string& name) const;
            ///< If there is no global variable with this name, ' ' is returned.

            void fill (const MWWorld::ESMStore& store);
            ///< Replace variables with variables from \a store with default values.

            int countSavedGameRecords() const;

            void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;

            bool readRecord (ESM::ESMReader& reader, uint32_t type);
            ///< Records for variables that do not exist are dropped silently.
            ///
            /// \return Known type?

    };
}

#endif