Panda3D
 All Classes Functions Variables Enumerations
bamFile.h
1 // Filename: bamFile.h
2 // Created by: drose (02Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BAMFILE_H
16 #define BAMFILE_H
17 
18 #include "pandabase.h"
19 #include "datagramInputFile.h"
20 #include "datagramOutputFile.h"
21 #include "pandaNode.h"
22 #include "pointerTo.h"
23 #include "bamEnums.h"
24 
25 class BamReader;
26 class BamWriter;
27 class TypedWritable;
28 class Filename;
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : BamFile
32 // Description : The principle public interface to reading and writing
33 // Bam disk files. See also BamReader and BamWriter,
34 // the more general implementation of this class.
35 //
36 // Bam files are most often used to store scene graphs
37 // or subgraphs, and by convention they are given
38 // filenames ending in the extension ".bam" when they
39 // are used for this purpose. However, a Bam file may
40 // store any arbitrary list of TypedWritable objects;
41 // in this more general usage, they are given filenames
42 // ending in ".boo" to differentiate them from the more
43 // common scene graph files.
44 ////////////////////////////////////////////////////////////////////
45 class EXPCL_PANDA_PGRAPH BamFile : public BamEnums {
46 PUBLISHED:
47  BamFile();
48  ~BamFile();
49 
50  bool open_read(const Filename &bam_filename, bool report_errors = true);
51  bool open_read(istream &in, const string &bam_filename = "stream",
52  bool report_errors = true);
53 
54  TypedWritable *read_object();
55 
56  bool is_eof() const;
57  bool resolve();
58 
59  PT(PandaNode) read_node(bool report_errors = true);
60 
61  bool open_write(const Filename &bam_filename, bool report_errors = true);
62  bool open_write(ostream &out, const string &bam_filename = "stream",
63  bool report_errors = true);
64  bool write_object(const TypedWritable *object);
65 
66  void close();
67  INLINE bool is_valid_read() const;
68  INLINE bool is_valid_write() const;
69 
70  int get_file_major_ver();
71  int get_file_minor_ver();
72  BamEndian get_file_endian() const;
73  bool get_file_stdfloat_double() const;
74 
75  int get_current_major_ver();
76  int get_current_minor_ver();
77 
78  BamReader *get_reader();
79  BamWriter *get_writer();
80 
81 private:
82  bool continue_open_read(const string &bam_filename, bool report_errors);
83  bool continue_open_write(const string &bam_filename, bool report_errors);
84 
85  string _bam_filename;
86  DatagramInputFile _din;
87  DatagramOutputFile _dout;
88  BamReader *_reader;
89  BamWriter *_writer;
90 };
91 
92 #include "bamFile.I"
93 
94 #endif
The principle public interface to reading and writing Bam disk files.
Definition: bamFile.h:45
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
This class can be used to read a binary file that consists of an arbitrary header followed by a numbe...
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
This class can be used to write a binary file that consists of an arbitrary header followed by a numb...
This class exists just to provide scoping for the enums shared by BamReader and BamWriter.
Definition: bamEnums.h:25