OpenMW
apps/openmw/mwworld/globals.hpp
Go to the documentation of this file.
00001 #ifndef GAME_MWWORLD_GLOBALS_H
00002 #define GAME_MWWORLD_GLOBALS_H
00003 
00004 #include <vector>
00005 #include <string>
00006 #include <map>
00007 
00008 #include <components/interpreter/types.hpp>
00009 
00010 namespace MWWorld
00011 {
00012     class ESMStore;
00013 
00014     class Globals
00015     {
00016         public:
00017         
00018             union Data
00019             {
00020                 Interpreter::Type_Float mFloat;
00021                 Interpreter::Type_Float mLong; // Why Morrowind, why? :(
00022                 Interpreter::Type_Float mShort;
00023             };
00024         
00025             typedef std::map<std::string, std::pair<char, Data> > Collection;
00026         
00027         private:
00028         
00029             Collection mVariables; // type, value
00030         
00031             Collection::const_iterator find (const std::string& name) const;
00032 
00033             Collection::iterator find (const std::string& name);
00034         
00035         public:
00036         
00037             Globals (const MWWorld::ESMStore& store);
00038         
00039             const Data& operator[] (const std::string& name) const;
00040 
00041             Data& operator[] (const std::string& name);
00042             
00043             void setInt (const std::string& name, int value);
00045             
00046             void setFloat (const std::string& name, float value);
00048             
00049             int getInt (const std::string& name) const;
00051                 
00052             float getFloat (const std::string& name) const;
00054             
00055             char getType (const std::string& name) const;
00057 
00058             std::vector<std::string> getGlobals () const;
00059     };
00060 }
00061 
00062 #endif