mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
assert is_initialized
This commit is contained in:
parent
77b6df9fd7
commit
58e47ab226
@ -13,6 +13,17 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: P3DInstanceManager::is_initialized
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns true if the instance manager is successfully
|
||||||
|
// initialized, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
inline bool P3DInstanceManager::
|
||||||
|
is_initialized() const {
|
||||||
|
return _is_initialized;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: P3DInstanceManager::get_root_dir
|
// Function: P3DInstanceManager::get_root_dir
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -31,6 +31,7 @@ P3DInstanceManager *P3DInstanceManager::_global_ptr;
|
|||||||
P3DInstanceManager::
|
P3DInstanceManager::
|
||||||
P3DInstanceManager() {
|
P3DInstanceManager() {
|
||||||
cerr << "creating instance manager\n";
|
cerr << "creating instance manager\n";
|
||||||
|
_is_initialized = false;
|
||||||
_unique_session_index = 0;
|
_unique_session_index = 0;
|
||||||
|
|
||||||
_request_seq = 0;
|
_request_seq = 0;
|
||||||
@ -92,6 +93,8 @@ initialize() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_is_initialized = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
bool initialize();
|
bool initialize();
|
||||||
|
|
||||||
|
inline bool is_initialized() const;
|
||||||
|
|
||||||
inline const string &get_root_dir() const;
|
inline const string &get_root_dir() const;
|
||||||
inline const string &get_download_url() const;
|
inline const string &get_download_url() const;
|
||||||
|
|
||||||
@ -74,6 +76,7 @@ private:
|
|||||||
string find_root_dir() const;
|
string find_root_dir() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool _is_initialized;
|
||||||
string _root_dir;
|
string _root_dir;
|
||||||
string _download_url;
|
string _download_url;
|
||||||
|
|
||||||
|
@ -207,8 +207,8 @@ send_command(TiXmlDocument *command) {
|
|||||||
void P3DSession::
|
void P3DSession::
|
||||||
start_p3dpython() {
|
start_p3dpython() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
string p3dpython = "c:/cygwin/home/drose/player/direct/built/bin/p3dpython.exe";
|
//string p3dpython = "c:/cygwin/home/drose/player/direct/built/bin/p3dpython.exe";
|
||||||
// string p3dpython = _python_root_dir + "/p3dpython.exe";
|
string p3dpython = _python_root_dir + "/p3dpython.exe";
|
||||||
#else
|
#else
|
||||||
string p3dpython = "/Users/drose/player/direct/built/bin/p3dpython";
|
string p3dpython = "/Users/drose/player/direct/built/bin/p3dpython";
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include "p3dInstanceManager.h"
|
#include "p3dInstanceManager.h"
|
||||||
#include "p3dInstance.h"
|
#include "p3dInstance.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
// Use a simple lock to protect the C-style API functions in this
|
// Use a simple lock to protect the C-style API functions in this
|
||||||
// module from parallel access by multiple threads in the host.
|
// module from parallel access by multiple threads in the host.
|
||||||
|
|
||||||
@ -56,6 +58,7 @@ P3D_create_instance(P3D_request_ready_func *func,
|
|||||||
int win_width, int win_height,
|
int win_width, int win_height,
|
||||||
P3D_window_handle parent_window,
|
P3D_window_handle parent_window,
|
||||||
const P3D_token tokens[], size_t num_tokens) {
|
const P3D_token tokens[], size_t num_tokens) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
||||||
P3DInstance *result =
|
P3DInstance *result =
|
||||||
@ -68,6 +71,7 @@ P3D_create_instance(P3D_request_ready_func *func,
|
|||||||
|
|
||||||
void
|
void
|
||||||
P3D_instance_finish(P3D_instance *instance) {
|
P3D_instance_finish(P3D_instance *instance) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
||||||
inst_mgr->finish_instance((P3DInstance *)instance);
|
inst_mgr->finish_instance((P3DInstance *)instance);
|
||||||
@ -77,6 +81,7 @@ P3D_instance_finish(P3D_instance *instance) {
|
|||||||
bool
|
bool
|
||||||
P3D_instance_has_property(P3D_instance *instance,
|
P3D_instance_has_property(P3D_instance *instance,
|
||||||
const char *property_name) {
|
const char *property_name) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
bool result = ((P3DInstance *)instance)->has_property(property_name);
|
bool result = ((P3DInstance *)instance)->has_property(property_name);
|
||||||
RELEASE_LOCK(_lock);
|
RELEASE_LOCK(_lock);
|
||||||
@ -86,6 +91,7 @@ P3D_instance_has_property(P3D_instance *instance,
|
|||||||
char *
|
char *
|
||||||
P3D_instance_get_property(P3D_instance *instance,
|
P3D_instance_get_property(P3D_instance *instance,
|
||||||
const char *property_name) {
|
const char *property_name) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
string value = ((P3DInstance *)instance)->get_property(property_name);
|
string value = ((P3DInstance *)instance)->get_property(property_name);
|
||||||
|
|
||||||
@ -101,6 +107,7 @@ void
|
|||||||
P3D_instance_set_property(P3D_instance *instance,
|
P3D_instance_set_property(P3D_instance *instance,
|
||||||
const char *property_name,
|
const char *property_name,
|
||||||
const char *value) {
|
const char *value) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
((P3DInstance *)instance)->set_property(property_name, value);
|
((P3DInstance *)instance)->set_property(property_name, value);
|
||||||
RELEASE_LOCK(_lock);
|
RELEASE_LOCK(_lock);
|
||||||
@ -108,6 +115,7 @@ P3D_instance_set_property(P3D_instance *instance,
|
|||||||
|
|
||||||
P3D_request *
|
P3D_request *
|
||||||
P3D_instance_get_request(P3D_instance *instance) {
|
P3D_instance_get_request(P3D_instance *instance) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
P3D_request *result = ((P3DInstance *)instance)->get_request();
|
P3D_request *result = ((P3DInstance *)instance)->get_request();
|
||||||
RELEASE_LOCK(_lock);
|
RELEASE_LOCK(_lock);
|
||||||
@ -116,6 +124,7 @@ P3D_instance_get_request(P3D_instance *instance) {
|
|||||||
|
|
||||||
P3D_instance *
|
P3D_instance *
|
||||||
P3D_check_request(bool wait) {
|
P3D_check_request(bool wait) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
||||||
P3D_instance *inst = inst_mgr->check_request();
|
P3D_instance *inst = inst_mgr->check_request();
|
||||||
@ -139,6 +148,7 @@ P3D_check_request(bool wait) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
P3D_request_finish(P3D_request *request, bool handled) {
|
P3D_request_finish(P3D_request *request, bool handled) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
if (request != (P3D_request *)NULL) {
|
if (request != (P3D_request *)NULL) {
|
||||||
((P3DInstance *)request->_instance)->finish_request(request, handled);
|
((P3DInstance *)request->_instance)->finish_request(request, handled);
|
||||||
@ -153,6 +163,7 @@ P3D_instance_feed_url_stream(P3D_instance *instance, int unique_id,
|
|||||||
size_t total_expected_data,
|
size_t total_expected_data,
|
||||||
const unsigned char *this_data,
|
const unsigned char *this_data,
|
||||||
size_t this_data_size) {
|
size_t this_data_size) {
|
||||||
|
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
|
||||||
ACQUIRE_LOCK(_lock);
|
ACQUIRE_LOCK(_lock);
|
||||||
bool result = ((P3DInstance *)instance)->
|
bool result = ((P3DInstance *)instance)->
|
||||||
feed_url_stream(unique_id, result_code, http_status_code,
|
feed_url_stream(unique_id, result_code, http_status_code,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user