Panda3D
fltRecordWriter.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 fltRecordWriter.h
10  * @author drose
11  * @date 2000-08-24
12  */
13 
14 #ifndef FLTRECORDWRITER_H
15 #define FLTRECORDWRITER_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "fltOpcode.h"
20 #include "fltError.h"
21 
22 #include "datagram.h"
23 #include "pset.h"
24 
25 class FltHeader;
26 
27 /**
28  * This class writes a sequence of FltRecords to an ostream, handling opcode
29  * and size counts properly.
30  */
32 public:
33  FltRecordWriter(std::ostream &out);
34  ~FltRecordWriter();
35 
36  void set_opcode(FltOpcode opcode);
37  const Datagram &get_datagram() const;
38  void set_datagram(const Datagram &datagram);
40 
41  FltError advance();
42 
43  FltError write_record(FltOpcode opcode,
44  const Datagram &datagram = Datagram());
45 
46  FltError write_instance_def(FltHeader *header, int instance_index);
47 
48 private:
49  std::ostream &_out;
50  Datagram _datagram;
51  FltOpcode _opcode;
52 
53  typedef pset<int> Instances;
54  Instances _instances_written;
55 };
56 
57 #endif
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_datagram(const Datagram &datagram)
Sets the datagram that will be written when advance() is called.
This is the first bead in the file, the top of the bead hierarchy, and the primary interface to readi...
Definition: fltHeader.h:44
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
FltError write_instance_def(FltHeader *header, int instance_index)
Ensures that the given instance definition has already been written to the file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
FltError advance()
Writes the current record to the flt file, and resets the current record to receive new data.
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
FltError write_record(FltOpcode opcode, const Datagram &datagram=Datagram())
A convenience function to quickly write a simple record that consists of an opcode and possibly a dat...