Panda3D
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 
24 class BamReader;
25 class BamWriter;
26 class TypedWritable;
27 class 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  */
41 class EXPCL_PANDA_PGRAPH BamFile : public BamEnums {
42 PUBLISHED:
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 
50  TypedWritable *read_object();
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 
66  int get_file_major_ver();
67  int get_file_minor_ver();
68  BamEndian get_file_endian() const;
69  bool get_file_stdfloat_double() const;
70 
71  int get_current_major_ver();
72  int get_current_minor_ver();
73 
74  BamReader *get_reader();
75  BamWriter *get_writer();
76 
77 PUBLISHED:
78  MAKE_PROPERTY(file_endian, get_file_endian);
79  MAKE_PROPERTY(file_stdfloat_double, get_file_stdfloat_double);
80 
81  MAKE_PROPERTY(reader, get_reader);
82  MAKE_PROPERTY(writer, get_writer);
83 
84 private:
85  bool continue_open_read(const std::string &bam_filename, bool report_errors);
86  bool continue_open_write(const std::string &bam_filename, bool report_errors);
87 
88  std::string _bam_filename;
89  DatagramInputFile _din;
90  DatagramOutputFile _dout;
91  BamReader *_reader;
92  BamWriter *_writer;
93 };
94 
95 #include "bamFile.I"
96 
97 #endif
The principle public interface to reading and writing Bam disk files.
Definition: bamFile.h:41
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This class can be used to read a binary file that consists of an arbitrary header followed by a numbe...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class can be used to write a binary file that consists of an arbitrary header followed by a numb...
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