oslConfig.h
Go to the documentation of this file.
00001 /* oslConfig.h
00002  */
00003 #ifndef OSL_OSLCONFIG_H
00004 #define OSL_OSLCONFIG_H
00005 
00006 #include "osl/config.h"
00007 #include <boost/thread/mutex.hpp>
00008 #include <stdexcept>
00009 #include <string>
00010 #include <utility>
00011 
00012 namespace osl
00013 {
00015   struct OslConfig
00016   {
00017     static const int MaxThreads=16;
00019     static const std::string& home();
00020     static const char * home_c_str();
00021     static const std::string gpsusiConf();
00022 
00024     static const std::string testPrivate();
00025     static const std::string testPublic();
00026     static const char *testPrivateFile(const std::string& filename);
00027     static const char *testPublicFile(const std::string& filename);
00028     static const char *testCsaFile(const std::string& filename);
00029 
00034     static const char *openingBook(const std::string& filenamme="");
00035 
00036     static void setVerbose(bool verbose);
00037     static bool verbose();
00038 
00039     static void showOslHome();
00040     static void setNumCPUs(int ncpu);
00041     static int numCPUs();
00042 
00043     static int dfpnMaxDepth();
00044     static void setDfpnMaxDepth(int);
00045 
00046     enum UsiMode { NoUSI, PortableUSI, ExtendedUSI };
00047     static UsiMode usiMode();
00048     static void setUsiMode(UsiMode new_mode=PortableUSI);
00049     static bool usiModeInSilent();
00050     static void setUsiSilent(bool silent=true);
00051 
00052     static bool searchExactValueInOneReply();
00053     static void setSearchExactValueInOneReply(bool new_value);
00054 
00055     static size_t residentMemoryUse();
00056     static size_t memoryUseLimit()
00057     {
00058       return static_cast<size_t>(memory_use_limit * memory_use_percent / 100.0); 
00059     }
00060     static void setMemoryUseLimit(size_t limit) { memory_use_limit = limit; }
00061     static double memoryUseRatio() 
00062     {
00063       return residentMemoryUse() * 1.0 / memoryUseLimit();
00064     }
00065     static bool isMemoryLimitEffective() 
00066     {
00067       return memory_use_limit != memory_use_limit_system_max
00068         && residentMemoryUse() > 0;
00069     }
00070     static void setMemoryUsePercent(double limit) 
00071     { 
00072       assert(limit > 0.0 && limit <= 100.0);
00073       limit = std::max(0.01, limit);
00074       limit = std::min(100.0, limit);
00075       memory_use_percent = limit; 
00076     }
00078     static unsigned int evalRandom() { return eval_random; }
00079     static void setEvalRandom(unsigned int sigma) { eval_random = sigma; }
00080 
00081     static void setUsiOutputPawnValue(int new_value) { usi_output_pawn_value = new_value; }
00082     static int usiOutputPawnValue() { return usi_output_pawn_value; }
00084     static int inUnitTest() { return in_unit_test; }
00085     static bool inUnitTestShort() { return in_unit_test == 1; }
00086     static bool inUnitTestLong() { return in_unit_test == 2; }
00087     static void setInUnitTest(int new_value) { in_unit_test = new_value; }
00088 
00090     static void setUp();
00091     static bool hasByoyomi();
00092     static void setHasByoyomi(bool);
00093 
00094     static bool healthCheck();
00095     static int resignThreshold();
00096   private:
00097     static const std::string makeHome();
00098     static const std::string makeTest();
00099     static const std::string makeTestPublic();
00100     static bool isGoodDir(const std::string&);
00101     static void trySetDir(std::string&, const std::string&);
00102     static void showOslHome(const std::string&);
00103     static size_t memory_use_limit;
00104     static double memory_use_percent;
00105     static const size_t memory_use_limit_system_max;
00106     static unsigned int eval_random;
00107     static bool is_verbose;
00108     static const int default_ncpus;
00109     static int num_cpu;
00110     static volatile UsiMode usi_mode;
00111     static volatile bool usi_mode_silent;
00112     static int usi_output_pawn_value;
00113     static bool search_exact_value_in_one_reply, has_byoyomi;
00114     static volatile bool force_root_window;
00115     static volatile int root_window_alpha, root_window_beta;
00116     static volatile int in_unit_test;
00117     static int dfpn_max_depth;
00118   public:
00119     static boost::mutex lock_io;
00120   };
00121 
00122   struct NoMoreMemory : std::runtime_error
00123   {
00124     NoMoreMemory() : std::runtime_error("memory exhausted")
00125     {
00126     }
00127   };
00128 }
00129 
00130 #endif /* OSL_OSLCONFIG_H */
00131 // ;;; Local Variables:
00132 // ;;; mode:c++
00133 // ;;; c-basic-offset:2
00134 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines