Panda3D
Loading...
Searching...
No Matches
config_express.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file config_express.cxx
10 * @author drose
11 * @date 2006-03-28
12 */
13
14#include "config_express.h"
15#include "datagram.h"
16#include "datagramIterator.h"
17#include "nodeReferenceCount.h"
18#include "referenceCount.h"
19#include "textEncoder.h"
20#include "typedObject.h"
21#include "typedReferenceCount.h"
22#include "virtualFile.h"
24#include "virtualFileMount.h"
29#include "virtualFileSimple.h"
30#include "fileReference.h"
31#include "temporaryFile.h"
32#include "pandaSystem.h"
33#include "numeric_types.h"
34#include "namable.h"
35#include "export_dtool.h"
36#include "dconfig.h"
37#include "streamWrapper.h"
38
39#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EXPRESS)
40 #error Buildsystem error: BUILDING_PANDA_EXPRESS not defined
41#endif
42
43ConfigureDef(config_express);
44NotifyCategoryDef(express, "");
45NotifyCategoryDef(clock, ":express");
46
47ConfigureFn(config_express) {
49}
50
51ConfigVariableInt patchfile_window_size
52("patchfile-window-size", 16);
53
54ConfigVariableInt patchfile_increment_size
55("patchfile-increment-size", 8);
56
57ConfigVariableInt patchfile_buffer_size
58("patchfile-buffer-size", 4096);
59
60ConfigVariableInt patchfile_zone_size
61("patchfile-zone-size", 10000);
62
63ConfigVariableBool keep_temporary_files
64("keep-temporary-files", false,
65 PRC_DESC("Set this true to keep around the temporary files from "
66 "downloading, decompressing, and patching, or false (the "
67 "default) to delete these. Mainly useful for debugging "
68 "when the process goes wrong."));
69
70ConfigVariableBool multifile_always_binary
71("multifile-always-binary", false,
72 PRC_DESC("This is a temporary transition variable. Set this true "
73 "to enable the old behavior for multifiles: all subfiles are "
74 "always added to and extracted from the multifile in binary mode. "
75 "Set it false to enable the new behavior: subfiles may be added "
76 "or extracted in either binary or text mode, according to the "
77 "set_binary() or set_text() flag on the Filename."));
78
79ConfigVariableBool collect_tcp
80("collect-tcp", false,
81 PRC_DESC("Set this true to enable accumulation of several small consecutive "
82 "TCP datagrams into one large datagram before sending it, to reduce "
83 "overhead from the TCP/IP protocol. See "
84 "Connection::set_collect_tcp() or SocketStream::set_collect_tcp()."));
85
86ConfigVariableDouble collect_tcp_interval
87("collect-tcp-interval", 0.2);
88
89/**
90 * Initializes the library. This must be called at least once before any of
91 * the functions or classes in this library can be used. Normally it will be
92 * called by the static initializers and need not be called explicitly, but
93 * special cases exist.
94 */
95void
97 static bool initialized = false;
98 if (initialized) {
99 return;
100 }
101 initialized = true;
102
103 Datagram::init_type();
104 DatagramIterator::init_type();
105 Namable::init_type();
106 NodeReferenceCount::init_type();
107 ReferenceCount::init_type();
109 TypedReferenceCount::init_type();
110 VirtualFile::init_type();
111 VirtualFileComposite::init_type();
112 VirtualFileMount::init_type();
113#ifdef ANDROID
114 VirtualFileMountAndroidAsset::init_type();
115#endif
116 VirtualFileMountMultifile::init_type();
117 VirtualFileMountRamdisk::init_type();
118 VirtualFileMountSystem::init_type();
119 VirtualFileSimple::init_type();
120 FileReference::init_type();
121 TemporaryFile::init_type();
122
123 init_system_type_handles();
124
125#ifdef HAVE_ZLIB
126 {
128 ps->add_system("zlib");
129 }
130#endif
131
132 // This is a fine place to ensure that the numeric types have been chosen
133 // correctly.
134 nassertv(sizeof(int8_t) == 1 && sizeof(uint8_t) == 1);
135 nassertv(sizeof(int16_t) == 2 && sizeof(uint16_t) == 2);
136 nassertv(sizeof(int32_t) == 4 && sizeof(uint32_t) == 4);
137 nassertv(sizeof(int64_t) == 8 && sizeof(uint64_t) == 8);
138 nassertv(sizeof(PN_float32) == 4);
139 nassertv(sizeof(PN_float64) == 8);
140
141 // Also, ensure that we have the right endianness.
142 uint32_t word;
143 memcpy(&word, "\1\2\3\4", 4);
144#ifdef WORDS_BIGENDIAN
145 nassertv(word == 0x01020304);
146#else
147 nassertv(word == 0x04030201);
148#endif
149}
150
151bool
152get_use_high_res_clock() {
153 static ConfigVariableBool *use_high_res_clock = nullptr;
154
155 if (use_high_res_clock == nullptr) {
156 use_high_res_clock = new ConfigVariableBool
157 ("use-high-res-clock", true,
158 PRC_DESC("Set this to false to avoid using the high-precision clock, even if "
159 "it is available."));
160 }
161
162 return *use_high_res_clock;
163}
164
165bool
166get_paranoid_clock() {
167 static ConfigVariableBool *paranoid_clock = nullptr;
168
169 if (paranoid_clock == nullptr) {
170 paranoid_clock = new ConfigVariableBool
171 ("paranoid-clock", false,
172 PRC_DESC("Set this to true to double-check the results of the high-resolution "
173 "clock against the system clock."));
174 }
175
176 return *paranoid_clock;
177}
178
179bool
180get_verify_dcast() {
181 static ConfigVariableBool *verify_dcast = nullptr;
182
183 if (verify_dcast == nullptr) {
184 verify_dcast = new ConfigVariableBool
185 ("verify-dcast", true,
186 PRC_DESC("Set this to true to verify that every attempted DCAST operation in "
187 "fact references the correct type, or false otherwise. This has no "
188 "effect if NDEBUG is defined, in which case it is never tested."));
189 }
190
191 return *verify_dcast;
192}
This is a convenience class to specialize ConfigVariable as a boolean type.
This is a convenience class to specialize ConfigVariable as a floating- point type.
This is a convenience class to specialize ConfigVariable as an integer type.
This class is used as a namespace to group several global properties of Panda.
Definition pandaSystem.h:26
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
void add_system(const std::string &system)
Intended for use by each subsystem to register itself at startup.
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
void init_libexpress()
Initializes the library.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.