16 #include "config_pgraph.h" 19 #include "bamCacheRecord.h" 20 #include "config_util.h" 21 #include "bamReader.h" 22 #include "bamWriter.h" 24 #include "config_express.h" 25 #include "virtualFileSystem.h" 59 if (!_din.
open(bam_filename)) {
63 return continue_open_read(bam_filename, report_errors);
74 open_read(istream &in,
const string &bam_filename,
bool report_errors) {
81 return continue_open_read(bam_filename, report_errors);
158 read_node(
bool report_errors) {
172 if (
object == TypedWritable::Null) {
174 loader_cat.error() <<
"Bam file " << _bam_filename <<
" is empty.\n";
177 }
else if (!object->
is_of_type(PandaNode::get_class_type())) {
180 <<
"Bam file " << _bam_filename
181 <<
" contains a " <<
object->get_type() <<
", not a PandaNode.\n";
191 <<
"Ignoring extra objects in " << _bam_filename <<
"\n";
199 <<
"Unable to resolve Bam file.\n";
222 if (!_dout.
open(bam_filename)) {
224 loader_cat.error() <<
"Unable to open " << bam_filename <<
"\n";
229 return continue_open_write(bam_filename, report_errors);
240 open_write(ostream &out,
const string &bam_filename,
bool report_errors) {
243 if (!_dout.
open(out)) {
244 loader_cat.error() <<
"Could not write bam: " << bam_filename <<
"\n";
248 return continue_open_write(bam_filename, report_errors);
303 return _bam_major_ver;
319 return _bam_minor_ver;
358 return bam_stdfloat_double;
370 return _bam_major_ver;
382 return _bam_minor_ver;
417 continue_open_read(
const string &bam_filename,
bool report_errors) {
418 _bam_filename = bam_filename;
420 if (!_bam_filename.empty()) {
422 <<
"Reading " << _bam_filename <<
"\n";
428 loader_cat.error() << _bam_filename <<
" is not a valid BAM file.\n";
433 if (head != _bam_header) {
435 loader_cat.error() << _bam_filename <<
" is not a valid BAM file.\n";
441 if (!_reader->
init()) {
457 continue_open_write(
const string &bam_filename,
bool report_errors) {
458 _bam_filename = bam_filename;
460 if (!_bam_filename.empty()) {
461 loader_cat.info() <<
"Writing " << _bam_filename <<
"\n";
466 loader_cat.error() <<
"Unable to write to " << _bam_filename <<
"\n";
473 if (!_writer->
init()) {
bool write_object(const TypedWritable *object)
Writes the indicated object to the Bam file.
A basic node of the scene graph or data graph.
bool get_file_stdfloat_double() const
Returns true if the file will store all "standard" floats as 64-bit doubles, or false if they are 32-...
bool open_read(const Filename &bam_filename, bool report_errors=true)
Attempts to open the indicated filename for reading.
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
bool resolve()
This must be called after one or more objects have been read via calls to read_object() in order to r...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
bool resolve()
This may be called at any time during processing of the Bam file to resolve all the known pointers so...
int get_file_major_ver()
Returns the major version number of the file currently being read, or the system current major versio...
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS's file system.
TypedWritable * read_object()
Reads a single object from the Bam file.
BamWriter * get_writer()
Returns the BamWriter in charge of performing the write operations.
Base class for objects that can be written to and read from Bam files.
bool write_header(const string &header)
Writes a sequence of bytes to the beginning of the datagram file.
BamEndian get_file_endian() const
Returns the endian preference indicated by the Bam file currently being written.
BamEndian get_file_endian() const
Returns the endian preference indicated by the Bam file currently being read.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
void close()
Closes the input or output stream.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
bool open(const FileReference *file)
Opens the indicated filename for writing.
int get_file_major_ver() const
Returns the major version number of the Bam file currently being read.
BamReader * get_reader()
Returns the BamReader in charge of performing the read operations.
bool init()
Initializes the BamReader prior to reading any objects from its source.
bool is_eof() const
Returns true if the reader has reached end-of-file, false otherwise.
bool get_file_stdfloat_double() const
Returns true if the file stores all "standard" floats as 64-bit doubles, or false if they are 32-bit ...
The name of a file, such as a texture file or an Egg file.
int get_current_minor_ver()
Returns the system current minor version number.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
bool write_object(const TypedWritable *obj)
Writes a single object to the Bam file, so that the BamReader::read_object() can later correctly rest...
int get_current_major_ver()
Returns the system current major version number.
bool get_file_stdfloat_double() const
Returns true if the file stores all "standard" floats as 64-bit doubles, or false if they are 32-bit ...
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
bool delete_file(const Filename &filename)
Attempts to delete the indicated file or directory.
bool open_write(const Filename &bam_filename, bool report_errors=true)
Attempts to open the indicated file for writing.
void close()
Closes the file.
bool init()
Initializes the BamWriter prior to writing any objects to its output stream.
int get_file_minor_ver()
Returns the minor version number of the file currently being read, or the system current minor versio...
bool is_eof() const
Returns true if the reader has reached end-of-file, false otherwise.
TypedWritable * read_object()
Reads and returns the next object from the Bam file, or NULL if the end of the file has been reached...
BamEndian get_file_endian() const
Returns the endian preference indicated by the Bam file currently being read or written.