Files
pokerth/src/config/configfile.h
T

90 lines
3.1 KiB
C++
Raw Normal View History

/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2011 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/ #ifndef CONFIGFILE_H
2007-01-21 16:01:37 +00:00
#define CONFIGFILE_H
#include <vector>
2007-05-22 22:40:44 +00:00
#include <string>
2007-08-22 23:01:32 +00:00
#include <boost/thread.hpp>
enum ConfigState { NONEXISTING, OLD, OK };
enum ConfigType { CONFIG_TYPE_INT, CONFIG_TYPE_STRING, CONFIG_TYPE_INT_LIST, CONFIG_TYPE_STRING_LIST };
2007-01-21 16:01:37 +00:00
2007-06-16 22:08:52 +00:00
class QtToolsInterface;
2007-04-21 20:42:50 +00:00
class ConfigFile
{
2007-01-21 16:01:37 +00:00
public:
ConfigFile(char *argv0, bool readonly);
2007-01-21 16:01:37 +00:00
2007-05-22 22:40:44 +00:00
~ConfigFile();
void fillBuffer();
2007-08-22 20:01:08 +00:00
void writeBuffer() const;
2007-05-08 20:54:36 +00:00
void updateConfig(ConfigState);
ConfigState getConfigState() const {
return myConfigState;
}
2007-04-20 08:18:18 +00:00
2007-08-22 20:01:08 +00:00
std::string readConfigString(std::string varName) const;
std::list<std::string> readConfigStringList(std::string varName) const;
2007-05-22 22:40:44 +00:00
void writeConfigString(std::string varName, std::string varCont);
void writeConfigStringList(std::string varName, std::list<std::string> varCont);
2007-08-22 20:01:08 +00:00
int readConfigInt(std::string varName) const;
std::list<int> readConfigIntList(std::string varName) const;
2007-01-22 21:29:51 +00:00
void writeConfigInt(std::string varName, int varCont);
void writeConfigIntList(std::string varName, std::list<int> varCont);
2007-04-18 00:11:24 +00:00
2007-04-20 23:14:08 +00:00
private:
2007-08-22 20:01:08 +00:00
2007-09-30 13:08:24 +00:00
mutable boost::recursive_mutex m_configMutex;
2007-05-08 20:54:36 +00:00
struct ConfigInfo {
ConfigInfo(const std::string &n, ConfigType t, const std::string &d, const std::list<std::string> &l =std::list<std::string>()) : name(n), type(t), defaultValue(d), defaultListValue(l) {}
2007-05-08 20:54:36 +00:00
std::string name;
ConfigType type;
std::string defaultValue;
std::list<std::string> defaultListValue;
2007-05-08 20:54:36 +00:00
};
2007-05-22 22:40:44 +00:00
std::vector<ConfigInfo> configList;
std::vector<ConfigInfo> configBufferList;
2007-05-08 20:54:36 +00:00
2007-04-20 23:14:08 +00:00
std::string configFileName;
std::string logDir;
std::string dataDir;
2007-09-08 18:53:59 +00:00
std::string cacheDir;
std::string defaultGameTableStyle;
std::string defaultCardDeck;
2007-04-20 08:18:18 +00:00
int configRev;
2007-05-16 08:55:49 +00:00
bool noWriteAccess;
std::string logOnOffDefault;
2007-05-05 20:11:49 +00:00
2007-05-08 20:54:36 +00:00
ConfigState myConfigState;
2007-06-16 22:08:52 +00:00
QtToolsInterface *myQtToolsInterface;
2007-09-17 23:06:10 +00:00
char *myArgv0;
2007-01-21 16:01:37 +00:00
};
#endif