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

BamFile Class Reference

The principle public interface to reading and writing Bam disk files. More...

#include <bamFile.h>

List of all members.

Public Member Functions

 BamFile ()
 ~BamFile ()
bool open_read (const Filename &filename, bool report_errors=true)
 Attempts to open the indicated filename for reading.

TypedWritableread_object ()
 Reads and returns the next object from the Bam file, or NULL if the end of the file has been reached, or if there is an error condition.

bool is_eof () const
 Returns true if the reader has reached end-of-file, false otherwise.

bool resolve ()
 This must be called after one or more objects have been read via calls to read_object() in order to resolve all internal pointer references in the objects read and make all the pointers valid.

bool open_write (const Filename &filename, bool report_errors=true)
 Attempts to open the indicated file for writing.

bool write_object (const TypedWritable *object)
 Writes the indicated object to the Bam file.

void close ()
 Closes the input or output stream.

bool is_valid_read () const
 Returns true if the Bam file is open and ready for reading with no errors so far detected, or false otherwise.

bool is_valid_write () const
 Returns true if the Bam file is open and ready for writing with no errors so far detected, or false otherwise.

int get_file_major_ver ()
 Returns the major version number of the file currently being read, or the system current major version number if no file is currently open for reading.

int get_file_minor_ver ()
 Returns the minor version number of the file currently being read, or the system current minor version number if no file is currently open for reading.

int get_current_major_ver ()
 Returns the system current major version number.

int get_current_minor_ver ()
 Returns the system current minor version number.


Private Attributes

DatagramInputFile _din
DatagramOutputFile _dout
BamReader_reader
BamWriter_writer


Detailed Description

The principle public interface to reading and writing Bam disk files.

See also BamReader and BamWriter, the more general implementation of this class.

Bam files are most often used to store scene graphs or subgraphs, and by convention they are given filenames ending in the extension ".bam" when they are used for this purpose. However, a Bam file may store any arbitrary list of TypedWritable objects; in this more general usage, they are given filenames ending in ".boo" to differentiate them from the more common scene graph files.

Definition at line 64 of file bamFile.h.


Constructor & Destructor Documentation

BamFile::BamFile  ) 
 

Definition at line 41 of file bamFile.cxx.

References close().

BamFile::~BamFile  ) 
 

Definition at line 54 of file bamFile.cxx.

References close(), VirtualFileSystem::exists(), and VirtualFileSystem::get_global_ptr().


Member Function Documentation

void BamFile::close  ) 
 

Closes the input or output stream.

Definition at line 268 of file bamFile.cxx.

Referenced by BamFile(), is_eof(), and ~BamFile().

int BamFile::get_current_major_ver  ) 
 

Returns the system current major version number.

This is the version number that will be assigned to any generated Bam files.

Definition at line 340 of file bamFile.cxx.

int BamFile::get_current_minor_ver  ) 
 

Returns the system current minor version number.

This is the version number that will be assigned to any generated Bam files.

Definition at line 357 of file bamFile.cxx.

int BamFile::get_file_major_ver  ) 
 

Returns the major version number of the file currently being read, or the system current major version number if no file is currently open for reading.

Definition at line 298 of file bamFile.cxx.

int BamFile::get_file_minor_ver  ) 
 

Returns the minor version number of the file currently being read, or the system current minor version number if no file is currently open for reading.

Definition at line 320 of file bamFile.cxx.

bool BamFile::is_eof  )  const
 

Returns true if the reader has reached end-of-file, false otherwise.

This call is only valid after a call to read_object().

Definition at line 160 of file bamFile.cxx.

References _dout, close(), DatagramOutputFile::open(), Filename::unlink(), and DatagramOutputFile::write_header().

bool BamFile::is_valid_read  )  const [inline]
 

Returns true if the Bam file is open and ready for reading with no errors so far detected, or false otherwise.

Definition at line 36 of file bamFile.I.

References _writer, INLINE, and NULL.

bool BamFile::is_valid_write  )  const [inline]
 

Returns true if the Bam file is open and ready for writing with no errors so far detected, or false otherwise.

Definition at line 54 of file bamFile.I.

bool BamFile::open_read const Filename filename,
bool  report_errors = true
 

Attempts to open the indicated filename for reading.

Returns true if successful, false on error.

Definition at line 69 of file bamFile.cxx.

Referenced by LoaderFileTypeBam::get_extension().

bool BamFile::open_write const Filename filename,
bool  report_errors = true
 

Attempts to open the indicated file for writing.

If another file by the same name already exists, it will be silently removed. Returns true if successful, false otherwise.

Definition at line 209 of file bamFile.cxx.

TypedWritable * BamFile::read_object  ) 
 

Reads and returns the next object from the Bam file, or NULL if the end of the file has been reached, or if there is an error condition.

Use is_eof() to differentiate these two cases.

The pointers returned by this method will not be valid for use until resolve() is subsequently called.

Definition at line 139 of file bamFile.cxx.

References _reader, NULL, and BamReader::resolve().

Referenced by LoaderFileTypeBam::get_extension().

bool BamFile::resolve  ) 
 

This must be called after one or more objects have been read via calls to read_object() in order to resolve all internal pointer references in the objects read and make all the pointers valid.

It returns true if all objects are successfully resolved, or false if some have not been (in which case you must call resolve() again later).

Definition at line 185 of file bamFile.cxx.

References _writer.

bool BamFile::write_object const TypedWritable object  ) 
 

Writes the indicated object to the Bam file.

Returns true if successful, false on error.

Definition at line 246 of file bamFile.cxx.

References _reader, and NULL.


Member Data Documentation

DatagramInputFile BamFile::_din [private]
 

Definition at line 88 of file bamFile.h.

DatagramOutputFile BamFile::_dout [private]
 

Definition at line 89 of file bamFile.h.

Referenced by is_eof().

BamReader* BamFile::_reader [private]
 

Definition at line 90 of file bamFile.h.

Referenced by read_object(), and write_object().

BamWriter* BamFile::_writer [private]
 

Definition at line 91 of file bamFile.h.

Referenced by is_valid_read(), and resolve().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:47:32 2003 for Panda by doxygen1.3