configuration.h

Go to the documentation of this file.
00001 /*
00002  *  The Mana World
00003  *  Copyright 2004 The Mana World Development Team
00004  *
00005  *  This file is part of The Mana World.
00006  *
00007  *  The Mana World is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  any later version.
00011  *
00012  *  The Mana World is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with The Mana World; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  *  $Id: configuration.h 2951 2006-12-29 13:43:24Z gmelquio $
00022  */
00023 
00024 #ifndef __INIREAD_H
00025 #define __INIREAD_H
00026 
00027 #include <map>
00028 #include <list>
00029 #include <string>
00030 
00031 
00038 class ConfigListener
00039 {
00040     public:
00044         virtual ~ConfigListener();
00045 
00050         virtual void optionChanged(const std::string &name) = 0;
00051 };
00052 
00058 class Configuration
00059 {
00060     public:
00065         void init(const std::string &filename);
00066 
00071         void write();
00072 
00078         void setValue(const std::string &key, std::string value);
00079 
00085         void setValue(const std::string &key, float value);
00086 
00092         std::string getValue(const std::string &key, std::string deflt);
00093 
00099         float getValue(const std::string &key, float deflt);
00100 
00104         void addListener(const std::string &key, ConfigListener *listener);
00105 
00110         void removeListener(const std::string &key, ConfigListener *listener);
00111 
00112     private:
00113         std::map<std::string, std::string> options;
00114         std::map<std::string, std::list<ConfigListener*> > listeners;
00115 
00116         std::string configPath;          
00117 };
00118 
00119 extern Configuration config;
00120 
00121 #ifndef DEFAULT_SERVER_PORT
00122 #define DEFAULT_SERVER_PORT 9601
00123 #endif
00124 #endif

Generated on Fri Mar 30 15:39:16 2007 for TMW Server by  doxygen 1.3.9.1