Panda3D

Loading...
Searching...
No Matches
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 */
31 class FltRecordWriter {
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);
39 Datagram &update_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
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FltHeader
This is the first bead in the file, the top of the bead hierarchy, and the primary interface to readi...
Definition fltHeader.h:44
FltRecordWriter::set_datagram
void set_datagram(const Datagram &datagram)
Sets the datagram that will be written when advance() is called.
Definition fltRecordWriter.cxx:55
FltRecordWriter::write_instance_def
FltError write_instance_def(FltHeader *header, int instance_index)
Ensures that the given instance definition has already been written to the file.
Definition fltRecordWriter.cxx:136
FltRecordWriter::set_opcode
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.
Definition fltRecordWriter.cxx:47
FltRecordWriter::advance
FltError advance()
Writes the current record to the flt file, and resets the current record to receive new data.
Definition fltRecordWriter.cxx:75
FltRecordWriter::write_record
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...
Definition fltRecordWriter.cxx:125
FltRecordWriter::update_datagram
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
Definition fltRecordWriter.cxx:66
datagram.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
fltError.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
fltOpcode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pset.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.