Panda3D
|
00001 // Filename: config_express.cxx 00002 // Created by: drose (28Mar06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "config_express.h" 00016 #include "datagram.h" 00017 #include "nodeReferenceCount.h" 00018 #include "referenceCount.h" 00019 #include "textEncoder.h" 00020 #include "typedObject.h" 00021 #include "typedReferenceCount.h" 00022 #include "virtualFile.h" 00023 #include "virtualFileComposite.h" 00024 #include "virtualFileMount.h" 00025 #include "virtualFileMountMultifile.h" 00026 #include "virtualFileMountSystem.h" 00027 #include "virtualFileSimple.h" 00028 #include "pandaSystem.h" 00029 #include "numeric_types.h" 00030 #include "namable.h" 00031 #include "export_dtool.h" 00032 #include "dconfig.h" 00033 #include "streamWrapper.h" 00034 00035 ConfigureDef(config_express); 00036 NotifyCategoryDef(express, ""); 00037 NotifyCategoryDef(clock, ":express"); 00038 00039 ConfigureFn(config_express) { 00040 init_libexpress(); 00041 } 00042 00043 ConfigVariableInt patchfile_window_size 00044 ("patchfile-window-size", 16); 00045 00046 ConfigVariableInt patchfile_increment_size 00047 ("patchfile-increment-size", 8); 00048 00049 ConfigVariableInt patchfile_buffer_size 00050 ("patchfile-buffer-size", 4096); 00051 00052 ConfigVariableInt patchfile_zone_size 00053 ("patchfile-zone-size", 10000); 00054 00055 ConfigVariableBool keep_temporary_files 00056 ("keep-temporary-files", false, 00057 PRC_DESC("Set this true to keep around the temporary files from " 00058 "downloading, decompressing, and patching, or false (the " 00059 "default) to delete these. Mainly useful for debugging " 00060 "when the process goes wrong.")); 00061 00062 ConfigVariableBool collect_tcp 00063 ("collect-tcp", false, 00064 PRC_DESC("Set this true to enable accumulation of several small consecutive " 00065 "TCP datagrams into one large datagram before sending it, to reduce " 00066 "overhead from the TCP/IP protocol. See " 00067 "Connection::set_collect_tcp() or SocketStream::set_collect_tcp().")); 00068 00069 ConfigVariableDouble collect_tcp_interval 00070 ("collect-tcp-interval", 0.2); 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: init_libexpress 00074 // Description: Initializes the library. This must be called at 00075 // least once before any of the functions or classes in 00076 // this library can be used. Normally it will be 00077 // called by the static initializers and need not be 00078 // called explicitly, but special cases exist. 00079 //////////////////////////////////////////////////////////////////// 00080 void 00081 init_libexpress() { 00082 static bool initialized = false; 00083 if (initialized) { 00084 return; 00085 } 00086 initialized = true; 00087 00088 Datagram::init_type(); 00089 Namable::init_type(); 00090 NodeReferenceCount::init_type(); 00091 ReferenceCount::init_type(); 00092 TextEncoder::init_type(); 00093 TypedObject::init_type(); 00094 TypedReferenceCount::init_type(); 00095 VirtualFile::init_type(); 00096 VirtualFileComposite::init_type(); 00097 VirtualFileMount::init_type(); 00098 VirtualFileMountMultifile::init_type(); 00099 VirtualFileMountSystem::init_type(); 00100 VirtualFileSimple::init_type(); 00101 00102 init_system_type_handles(); 00103 00104 #ifdef HAVE_ZLIB 00105 { 00106 PandaSystem *ps = PandaSystem::get_global_ptr(); 00107 ps->add_system("zlib"); 00108 } 00109 #endif 00110 00111 // This is a fine place to ensure that the numeric types have been 00112 // chosen correctly. 00113 nassertv(sizeof(PN_int8) == 1 && sizeof(PN_uint8) == 1); 00114 nassertv(sizeof(PN_int16) == 2 && sizeof(PN_uint16) == 2); 00115 nassertv(sizeof(PN_int32) == 4 && sizeof(PN_uint32) == 4); 00116 nassertv(sizeof(PN_int64) == 8 && sizeof(PN_uint64) == 8); 00117 nassertv(sizeof(PN_float32) == 4); 00118 nassertv(sizeof(PN_float64) == 8); 00119 00120 // Also, ensure that we have the right endianness. 00121 PN_uint32 word; 00122 memcpy(&word, "\1\2\3\4", 4); 00123 #ifdef WORDS_BIGENDIAN 00124 nassertv(word == 0x01020304); 00125 #else 00126 nassertv(word == 0x04030201); 00127 #endif 00128 } 00129 00130 bool 00131 get_use_high_res_clock() { 00132 static ConfigVariableBool *use_high_res_clock = NULL; 00133 00134 if (use_high_res_clock == (ConfigVariableBool *)NULL) { 00135 use_high_res_clock = new ConfigVariableBool 00136 ("use-high-res-clock", true, 00137 PRC_DESC("Set this to false to avoid using the high-precision clock, even if " 00138 "it is available.")); 00139 } 00140 00141 return *use_high_res_clock; 00142 } 00143 00144 bool 00145 get_paranoid_clock() { 00146 static ConfigVariableBool *paranoid_clock = NULL; 00147 00148 if (paranoid_clock == (ConfigVariableBool *)NULL) { 00149 paranoid_clock = new ConfigVariableBool 00150 ("paranoid-clock", false, 00151 PRC_DESC("Set this to true to double-check the results of the high-resolution " 00152 "clock against the system clock.")); 00153 } 00154 00155 return *paranoid_clock; 00156 } 00157 00158 bool 00159 get_verify_dcast() { 00160 static ConfigVariableBool *verify_dcast = NULL; 00161 00162 if (verify_dcast == (ConfigVariableBool *)NULL) { 00163 verify_dcast = new ConfigVariableBool 00164 ("verify-dcast", true, 00165 PRC_DESC("Set this to true to verify that every attempted DCAST operation in " 00166 "fact references the correct type, or false otherwise. This has no " 00167 "effect if NDEBUG is defined, in which case it is never tested.")); 00168 } 00169 00170 return *verify_dcast; 00171 } 00172 00173 // Returns the configure object for accessing config variables from a 00174 // scripting language. 00175 DConfig & 00176 get_config_express() { 00177 static DConfig config_express; 00178 return config_express; 00179 }