Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/express/config_express.cxx

Go to the documentation of this file.
00001 // Filename: config_express.cxx
00002 // Created by:  cary (04Jan00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 #include "config_express.h"
00021 #include "datagram.h"
00022 #include "referenceCount.h"
00023 #include "textEncoder.h"
00024 #include "thread.h"
00025 #include "typedObject.h"
00026 #include "typedReferenceCount.h"
00027 #include "virtualFile.h"
00028 #include "virtualFileComposite.h"
00029 #include "virtualFileMount.h"
00030 #include "virtualFileMountMultifile.h"
00031 #include "virtualFileMountSystem.h"
00032 #include "virtualFileSimple.h"
00033 
00034 #include <dconfig.h>
00035 
00036 ConfigureDef(config_express);
00037 NotifyCategoryDef(express, "");
00038 NotifyCategoryDef(thread, "");
00039 
00040 extern void init_system_type_handles();
00041 
00042 ConfigureFn(config_express) {
00043   init_libexpress();
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: init_libexpress
00048 //  Description: Initializes the library.  This must be called at
00049 //               least once before any of the functions or classes in
00050 //               this library can be used.  Normally it will be
00051 //               called by the static initializers and need not be
00052 //               called explicitly, but special cases exist.
00053 ////////////////////////////////////////////////////////////////////
00054 void
00055 init_libexpress() {
00056   static bool initialized = false;
00057   if (initialized) {
00058     return;
00059   }
00060   initialized = true;
00061 
00062   Datagram::init_type();
00063   ReferenceCount::init_type();
00064   TextEncoder::init_type();
00065   Thread::init_type();
00066   TypedObject::init_type();
00067   TypedReferenceCount::init_type();
00068   VirtualFile::init_type();
00069   VirtualFileComposite::init_type();
00070   VirtualFileMount::init_type();
00071   VirtualFileMountMultifile::init_type();
00072   VirtualFileMountSystem::init_type();
00073   VirtualFileSimple::init_type();
00074 
00075   init_system_type_handles();
00076 
00077   string text_encoding = config_express.GetString("text-encoding", "iso8859");
00078   if (text_encoding == "iso8859") {
00079     TextEncoder::set_default_encoding(TextEncoder::E_iso8859);
00080   } else if (text_encoding == "utf8") {
00081     TextEncoder::set_default_encoding(TextEncoder::E_utf8);
00082   } else if (text_encoding == "unicode") {
00083     TextEncoder::set_default_encoding(TextEncoder::E_unicode);
00084   } else {
00085     express_cat.error()
00086       << "Invalid text-encoding: " << text_encoding << "\n";
00087   }
00088 }
00089 
00090 
00091 // Set leak-memory true to disable the actual deletion of
00092 // ReferenceCount-derived objects.  This is sometimes useful to track
00093 // a reference counting bug, since the formerly deleted objects will
00094 // still remain (with a reference count of -100) without being
00095 // overwritten with a newly-allocated object, and the assertion tests
00096 // in ReferenceCount may more accurately detect the first instance of
00097 // an error.
00098 bool
00099 get_leak_memory() {
00100   static bool got_leak_memory = false;
00101   static bool leak_memory;
00102 
00103   if (!got_leak_memory) {
00104     leak_memory = config_express.GetBool("leak-memory", false);
00105     got_leak_memory = true;
00106   }
00107 
00108   return leak_memory;
00109 }
00110 
00111 // never-destruct is similar to leak-memory, above, except that not
00112 // only will memory not be freed, but the destructor will not even be
00113 // called (on ReferenceCount objects, at least).  This will leak gobs
00114 // of memory, but ensures that every pointer to a ReferenceCount
00115 // object will always be valid, and may be useful for tracking down
00116 // certain kinds of errors.
00117 
00118 // never-destruct is only respected if leak-memory, above, is true.
00119 bool
00120 get_never_destruct() {
00121   static bool got_never_destruct = false;
00122   static bool never_destruct;
00123 
00124   if (!got_never_destruct) {
00125     never_destruct = config_express.GetBool("never-destruct", false);
00126     got_never_destruct = true;
00127   }
00128 
00129   return never_destruct;
00130 }
00131 
00132 //const bool track_memory_usage = config_express.GetBool("track-memory-usage", false);
00133 
00134 // Set this to false to avoid using the high-precision clock, even if
00135 // it is available.
00136 bool
00137 get_use_high_res_clock() {
00138   return config_express.GetBool("use-high-res-clock", true);
00139 }
00140 
00141 // Set this to true to double-check the results of the high-resolution
00142 // clock against the system clock.  This has no effect if NDEBUG is
00143 // defined.
00144 bool
00145 get_paranoid_clock() {
00146   return config_express.GetBool("paranoid-clock", false);
00147 }
00148 
00149 // Set this to true to double-check the test for inheritance of
00150 // TypeHandles, e.g. via is_of_type().  This has no effect if NDEBUG
00151 // is defined.
00152 bool
00153 get_paranoid_inheritance() {
00154   return config_express.GetBool("paranoid-inheritance", true);
00155 }
00156 
00157 // Set this to true to verify that every attempted DCAST operation in
00158 // fact references the correct type, or false otherwise.  This has no
00159 // effect if NDEBUG is defined, in which case it is never tested.
00160 bool
00161 get_verify_dcast() {
00162   static bool got_verify_dcast = false;
00163   static bool verify_dcast;
00164 
00165   if (!got_verify_dcast) {
00166     verify_dcast = config_express.GetBool("verify-dcast", true);
00167     got_verify_dcast = true;
00168   }
00169 
00170   return verify_dcast;
00171 }
00172 
00173 const int patchfile_window_size =
00174         config_express.GetInt("patchfile-window-size", 16);
00175 
00176 const int patchfile_increment_size =
00177         config_express.GetInt("patchfile-increment-size", 8);
00178 
00179 const int patchfile_buffer_size =
00180         config_express.GetInt("patchfile-buffer-size", 4096);
00181 
00182 const int patchfile_zone_size =
00183         config_express.GetInt("patchfile-zone-size", 10000);
00184 
00185 // Set this true to keep around the temporary files from downloading,
00186 // decompressing, and patching, or false (the default) to delete
00187 // these.  Mainly useful for debugging when the process goes wrong.
00188 const bool keep_temporary_files =
00189 config_express.GetBool("keep-temporary-files", false);
00190 
00191 // Set this true to use the VirtualFileSystem mechanism for loading
00192 // models, etc.  Since the VirtualFileSystem maps to the same as the
00193 // actual file system by default, there is probably no reason to set
00194 // this false, except for testing or if you mistrust the new code.
00195 const bool use_vfs = config_express.GetBool("use-vfs", true);
00196 
00197 // Set this true to enable accumulation of several small consecutive
00198 // TCP datagrams into one large datagram before sending it, to reduce
00199 // overhead from the TCP/IP protocol.  See
00200 // Connection::set_collect_tcp() or SocketStream::set_collect_tcp().
00201 const bool collect_tcp = config_express.GetBool("collect-tcp", false);
00202 const double collect_tcp_interval = config_express.GetDouble("collect-tcp-interval", 0.2);
00203 
00204 // Returns the configure object for accessing config variables from a
00205 // scripting language.
00206 ConfigExpress &
00207 get_config_express() {
00208   return config_express;
00209 }
00210 

Generated on Fri May 2 00:38:20 2003 for Panda by doxygen1.3