Panda3D
Loading...
Searching...
No Matches
bamFile.h
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 bamFile.h
10 * @author drose
11 * @date 2000-07-02
12 */
13
14#ifndef BAMFILE_H
15#define BAMFILE_H
16
17#include "pandabase.h"
18#include "datagramInputFile.h"
19#include "datagramOutputFile.h"
20#include "pandaNode.h"
21#include "pointerTo.h"
22#include "bamEnums.h"
23
24class BamReader;
25class BamWriter;
26class TypedWritable;
27class Filename;
28
29/**
30 * The principle public interface to reading and writing Bam disk files. See
31 * also BamReader and BamWriter, the more general implementation of this
32 * class.
33 *
34 * Bam files are most often used to store scene graphs or subgraphs, and by
35 * convention they are given filenames ending in the extension ".bam" when
36 * they are used for this purpose. However, a Bam file may store any
37 * arbitrary list of TypedWritable objects; in this more general usage, they
38 * are given filenames ending in ".boo" to differentiate them from the more
39 * common scene graph files.
40 */
41class EXPCL_PANDA_PGRAPH BamFile : public BamEnums {
42PUBLISHED:
43 BamFile();
44 ~BamFile();
45
46 bool open_read(const Filename &bam_filename, bool report_errors = true);
47 bool open_read(std::istream &in, const std::string &bam_filename = "stream",
48 bool report_errors = true);
49
51
52 bool is_eof() const;
53 bool resolve();
54
55 PT(PandaNode) read_node(bool report_errors = true);
56
57 bool open_write(const Filename &bam_filename, bool report_errors = true);
58 bool open_write(std::ostream &out, const std::string &bam_filename = "stream",
59 bool report_errors = true);
60 bool write_object(const TypedWritable *object);
61
62 void close();
63 INLINE bool is_valid_read() const;
64 INLINE bool is_valid_write() const;
65
69 bool get_file_stdfloat_double() const;
70
73
76
77public:
78 EXTENSION(PyObject *get_file_version() const);
79
80PUBLISHED:
81 MAKE_PROPERTY(file_version, get_file_version);
82 MAKE_PROPERTY(file_endian, get_file_endian);
83 MAKE_PROPERTY(file_stdfloat_double, get_file_stdfloat_double);
84
85 MAKE_PROPERTY(reader, get_reader);
86 MAKE_PROPERTY(writer, get_writer);
87
88private:
89 bool continue_open_read(const std::string &bam_filename, bool report_errors);
90 bool continue_open_write(const std::string &bam_filename, bool report_errors);
91
92 std::string _bam_filename;
95 BamReader *_reader;
96 BamWriter *_writer;
97};
98
99#include "bamFile.I"
100
101#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class exists just to provide scoping for the enums shared by BamReader and BamWriter.
Definition bamEnums.h:23
BamEndian
This defines an enumerated type used to represent the endianness of certain numeric values stored in ...
Definition bamEnums.h:32
get_file_stdfloat_double
Returns true if the file stores all "standard" floats as 64-bit doubles, or false if they are 32-bit ...
Definition bamFile.h:83
int get_current_major_ver()
Returns the system current major version number.
Definition bamFile.cxx:321
void close()
Closes the input or output stream.
Definition bamFile.cxx:243
int get_current_minor_ver()
Returns the system current minor version number.
Definition bamFile.cxx:330
int get_file_minor_ver()
Returns the minor version number of the file currently being read, or the system current minor versio...
Definition bamFile.cxx:277
PointerTo< PandaNode > read_node(bool report_errors=true)
Although the bam file format is general enough to store a list of objects of arbitrary type,...
Definition bamFile.cxx:134
bool open_write(const Filename &bam_filename, bool report_errors=true)
Attempts to open the indicated file for writing.
Definition bamFile.cxx:190
TypedWritable * read_object()
Reads and returns the next object from the Bam file, or NULL if the end of the file has been reached,...
Definition bamFile.cxx:85
int get_file_major_ver()
Returns the major version number of the file currently being read, or the system current major versio...
Definition bamFile.cxx:264
get_file_endian
Returns the endian preference indicated by the Bam file currently being read or written.
Definition bamFile.h:82
bool is_valid_write() const
Returns true if the Bam file is open and ready for writing with no errors so far detected,...
Definition bamFile.I:29
bool open_read(const Filename &bam_filename, bool report_errors=true)
Attempts to open the indicated filename for reading.
Definition bamFile.cxx:51
get_writer
Returns the BamWriter in charge of performing the write operations.
Definition bamFile.h:86
get_reader
Returns the BamReader in charge of performing the read operations.
Definition bamFile.h:85
bool is_valid_read() const
Returns true if the Bam file is open and ready for reading with no errors so far detected,...
Definition bamFile.I:19
bool resolve()
This must be called after one or more objects have been read via calls to read_object() in order to r...
Definition bamFile.cxx:110
bool is_eof() const
Returns true if the reader has reached end-of-file, false otherwise.
Definition bamFile.cxx:98
bool write_object(const TypedWritable *object)
Writes the indicated object to the Bam file.
Definition bamFile.cxx:226
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
This class can be used to read a binary file that consists of an arbitrary header followed by a numbe...
This class can be used to write a binary file that consists of an arbitrary header followed by a numb...
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
Base class for objects that can be written to and read from Bam files.
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.