*** empty log message ***

This commit is contained in:
David Rose 2001-01-11 01:29:22 +00:00
parent e8c50ff107
commit 90a2ea1759
5 changed files with 73 additions and 43 deletions

View File

@ -98,22 +98,6 @@ queue(PN_uint16 objId)
_deferred_reads.push_back(objId); _deferred_reads.push_back(objId);
} }
////////////////////////////////////////////////////////////////////
// Function: BamReader::empty_queue
// Access: Private
// Description: For every objId in the queue, reads an object
// from the datagram source
////////////////////////////////////////////////////////////////////
INLINE void BamReader::
empty_queue(void)
{
while(!_deferred_reads.empty())
{
_deferred_reads.pop_front();
(void)read_object();
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BamReader::clear_queue // Function: BamReader::clear_queue
// Access: Private // Access: Private

View File

@ -54,7 +54,7 @@ init(void)
} }
if (!_source->get_datagram(header)) { if (!_source->get_datagram(header)) {
util_cat->error() bam_cat.error()
<< "Unable to read Bam header.\n"; << "Unable to read Bam header.\n";
return false; return false;
} }
@ -68,16 +68,16 @@ init(void)
// *newer*, we can't safely load the file. // *newer*, we can't safely load the file.
if (_file_major != _bam_major_ver || _file_minor > _bam_minor_ver) if (_file_major != _bam_major_ver || _file_minor > _bam_minor_ver)
{ {
util_cat->error() bam_cat.error()
<< "Bam file is version " << _file_major << "." << _file_minor << "Bam file is version " << _file_major << "." << _file_minor
<< ".\n"; << ".\n";
if (_bam_minor_ver == 0) { if (_bam_minor_ver == 0) {
util_cat.error() bam_cat.error()
<< "This program can only load version " << "This program can only load version "
<< _bam_major_ver << ".0 bams.\n"; << _bam_major_ver << ".0 bams.\n";
} else { } else {
util_cat.error() bam_cat.error()
<< "This program can only load version " << "This program can only load version "
<< _bam_major_ver << ".0 through " << _bam_major_ver << ".0 through "
<< _bam_major_ver << "." << _bam_minor_ver << " bams.\n"; << _bam_major_ver << "." << _bam_minor_ver << " bams.\n";
@ -86,12 +86,12 @@ init(void)
return false; return false;
} }
if (util_cat->is_debug()) { if (bam_cat.is_debug()) {
util_cat->debug() bam_cat.debug()
<< "Bam file is version " << _file_major << "." << _file_minor << "Bam file is version " << _file_major << "." << _file_minor
<< ".\n"; << ".\n";
if (_file_minor != _bam_minor_ver) { if (_file_minor != _bam_minor_ver) {
util_cat.debug() bam_cat.debug()
<< "(Current version is " << _bam_major_ver << "." << _bam_minor_ver << "(Current version is " << _bam_major_ver << "." << _bam_minor_ver
<< ".)\n"; << ".)\n";
} }
@ -116,6 +116,10 @@ read_handle(DatagramIterator& scan)
{ {
//This indicates an object that should have already been read in, //This indicates an object that should have already been read in,
//so return TypeHandle::none() to indicate this. //so return TypeHandle::none() to indicate this.
if (bam_cat.is_spam()) {
bam_cat.spam()
<< "Reading previously read TypeHandle.\n";
}
return TypeHandle::none(); return TypeHandle::none();
} }
@ -131,7 +135,7 @@ read_handle(DatagramIterator& scan)
//This is a new type we've never heard of before so register it //This is a new type we've never heard of before so register it
//with the type registry //with the type registry
type = TypeRegistry::ptr()->register_dynamic_type(name); type = TypeRegistry::ptr()->register_dynamic_type(name);
util_cat.warning() bam_cat.warning()
<< "Bam file contains objects of unknown type: " << type << "\n"; << "Bam file contains objects of unknown type: " << type << "\n";
new_type = true; new_type = true;
} }
@ -145,7 +149,7 @@ read_handle(DatagramIterator& scan)
TypeRegistry::ptr()->record_derivation(type, parent_type); TypeRegistry::ptr()->record_derivation(type, parent_type);
} else { } else {
if (type.get_parent_towards(parent_type) != parent_type) { if (type.get_parent_towards(parent_type) != parent_type) {
util_cat.warning() bam_cat.warning()
<< "Bam file indicates a derivation of " << type << "Bam file indicates a derivation of " << type
<< " from " << parent_type << " which is no longer true.\n"; << " from " << parent_type << " which is no longer true.\n";
} }
@ -154,6 +158,11 @@ read_handle(DatagramIterator& scan)
} }
if (bam_cat.is_spam()) {
bam_cat.spam()
<< "Reading TypeHandle for " << _index_map[id] << ".\n";
}
return _index_map[id]; return _index_map[id];
} }
@ -182,6 +191,11 @@ read_object(void)
if (!_source->get_datagram(packet)) { if (!_source->get_datagram(packet)) {
// The datagram source is empty. // The datagram source is empty.
if (bam_cat.is_debug()) {
bam_cat.debug()
<< "Reached end of bam source.\n";
}
return TypedWriteable::Null; return TypedWriteable::Null;
} }
@ -219,16 +233,23 @@ read_object(void)
//value otherwise //value otherwise
_created_objs[objId]; _created_objs[objId];
_created_objs[objId] = _factory->make_instance_more_general(type, list); _created_objs[objId] = _factory->make_instance_more_general(type, list);
//Just some sanity checks //Just some sanity checks
if (_created_objs[objId] == (TypedWriteable *)NULL) if (_created_objs[objId] == (TypedWriteable *)NULL) {
{ bam_cat.error()
util_cat->error() << "Failed to create a " << type.get_name() << endl; << "Unable to create an object of type " << type << endl;
}
else if (_created_objs[objId]->get_type() != type) } else if (_created_objs[objId]->get_type() != type) {
{ bam_cat.warning()
util_cat->warning() << "Attempted to create a " << type.get_name() \ << "Attempted to create a " << type.get_name() \
<< " but a " << _created_objs[objId]->get_type().get_name() \ << " but a " << _created_objs[objId]->get_type() \
<< " was created instead." << endl; << " was created instead." << endl;
} else {
if (bam_cat.is_spam()) {
bam_cat.spam()
<< "Read a " << _created_objs[objId]->get_type() << "\n";
}
} }
} }
@ -299,7 +320,7 @@ register_finalize(TypedWriteable *whom)
{ {
if (whom == TypedWriteable::Null) if (whom == TypedWriteable::Null)
{ {
util_cat->error() << "Can't register a null pointer to finalize!" << endl; bam_cat.error() << "Can't register a null pointer to finalize!" << endl;
return; return;
} }
_finalize_list.insert(whom); _finalize_list.insert(whom);
@ -315,7 +336,7 @@ finalize_now(TypedWriteable *whom)
{ {
if (whom == TypedWriteable::Null) if (whom == TypedWriteable::Null)
{ {
util_cat->error() << "Can't finalize null pointer!" << endl; bam_cat.error() << "Can't finalize null pointer!" << endl;
return; return;
} }
if (_finalize_list.find(whom) != _finalize_list.end()) if (_finalize_list.find(whom) != _finalize_list.end())
@ -325,12 +346,29 @@ finalize_now(TypedWriteable *whom)
} }
else else
{ {
util_cat->warning() << "Request to finalize object of type " bam_cat.warning() << "Request to finalize object of type "
<< whom->get_type().get_name() << " failed" << whom->get_type().get_name() << " failed"
<< endl; << endl;
} }
} }
////////////////////////////////////////////////////////////////////
// Function: BamReader::empty_queue
// Access: Private
// Description: For every objId in the queue, reads an object
// from the datagram source
////////////////////////////////////////////////////////////////////
void BamReader::
empty_queue(void) {
size_t num_reads = _deferred_reads.size();
_deferred_reads.clear();
while (num_reads > 0) {
read_object();
num_reads--;
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BamReader::finalize_this // Function: BamReader::finalize_this
// Access: Private // Access: Private
@ -351,14 +389,19 @@ finalize_this(TypedWriteable *whom)
void BamReader:: void BamReader::
finalize(void) finalize(void)
{ {
if (bam_cat.is_debug()) {
bam_cat.debug()
<< "Finalizing bam source\n";
}
Finalize::iterator fi = _finalize_list.begin(); Finalize::iterator fi = _finalize_list.begin();
while(fi != _finalize_list.end()) while(fi != _finalize_list.end())
{ {
if (*fi == TypedWriteable::Null) if (*fi == TypedWriteable::Null)
{ {
util_cat->error() << "Spun off into the weeds. " bam_cat.error() << "Spun off into the weeds. "
<< "somehow a null was registered to be " << "somehow a null was registered to be "
<< "finalized." << endl; << "finalized." << endl;
_finalize_list.erase(fi); _finalize_list.erase(fi);
} }
else else
@ -480,7 +523,7 @@ resolve(void)
else else
{ {
// nassertv(objReferencesComplete); // nassertv(objReferencesComplete);
util_cat.warning() bam_cat.warning()
<< "Unable to complete " << (*whom).first->get_type() << "\n"; << "Unable to complete " << (*whom).first->get_type() << "\n";
whom++; whom++;
} }

View File

@ -103,7 +103,7 @@ private:
private: private:
INLINE void queue(PN_uint16); INLINE void queue(PN_uint16);
INLINE void empty_queue(void); void empty_queue(void);
INLINE void clear_queue(void); INLINE void clear_queue(void);
void finalize_this(TypedWriteable *whom); void finalize_this(TypedWriteable *whom);
void finalize(void); void finalize(void);
@ -112,6 +112,7 @@ private:
typedef map<int, TypedWriteable*> Created; typedef map<int, TypedWriteable*> Created;
typedef map<TypedWriteable*, vector_ushort> Requests; typedef map<TypedWriteable*, vector_ushort> Requests;
typedef set<TypedWriteable*> Finalize; typedef set<TypedWriteable*> Finalize;
typedef deque<PN_uint16> DeferredReads;
static WriteableFactory *_factory; static WriteableFactory *_factory;
@ -123,7 +124,7 @@ private:
//Map of Objects that need pointers completed, to the //Map of Objects that need pointers completed, to the
//object ID of the objects they need //object ID of the objects they need
Requests _deferred_pointers; Requests _deferred_pointers;
deque<PN_uint16> _deferred_reads; DeferredReads _deferred_reads;
//Keep track of all objects needing to be finalized //Keep track of all objects needing to be finalized
Finalize _finalize_list; Finalize _finalize_list;

View File

@ -26,6 +26,7 @@
ConfigureDef(config_util); ConfigureDef(config_util);
NotifyCategoryDef(util, ""); NotifyCategoryDef(util, "");
NotifyCategoryDef(bam, util_cat);
ConfigureFn(config_util) { ConfigureFn(config_util) {
// ClockObject::init_ptr(); // ClockObject::init_ptr();

View File

@ -14,6 +14,7 @@ class DSearchPath;
ConfigureDecl(config_util, EXPCL_PANDA, EXPTP_PANDA); ConfigureDecl(config_util, EXPCL_PANDA, EXPTP_PANDA);
NotifyCategoryDecl(util, EXPCL_PANDA, EXPTP_PANDA); NotifyCategoryDecl(util, EXPCL_PANDA, EXPTP_PANDA);
NotifyCategoryDecl(bam, EXPCL_PANDA, EXPTP_PANDA);
// Actually, we can't determine this config variable the normal way, // Actually, we can't determine this config variable the normal way,
// because we must be able to access it at static init time. Instead // because we must be able to access it at static init time. Instead