00001 // Filename: fltRecordWriter.h 00002 // Created by: drose (24Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef FLTRECORDWRITER_H 00020 #define FLTRECORDWRITER_H 00021 00022 #include "pandatoolbase.h" 00023 00024 #include "fltOpcode.h" 00025 #include "fltError.h" 00026 00027 #include "datagram.h" 00028 #include "pset.h" 00029 00030 class FltHeader; 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Class : FltRecordWriter 00034 // Description : This class writes a sequence of FltRecords to an 00035 // ostream, handling opcode and size counts properly. 00036 //////////////////////////////////////////////////////////////////// 00037 class FltRecordWriter { 00038 public: 00039 FltRecordWriter(ostream &out); 00040 ~FltRecordWriter(); 00041 00042 void set_opcode(FltOpcode opcode); 00043 const Datagram &get_datagram() const; 00044 void set_datagram(const Datagram &datagram); 00045 Datagram &update_datagram(); 00046 00047 FltError advance(); 00048 00049 FltError write_record(FltOpcode opcode, 00050 const Datagram &datagram = Datagram()); 00051 00052 FltError write_instance_def(FltHeader *header, int instance_index); 00053 00054 private: 00055 ostream &_out; 00056 Datagram _datagram; 00057 FltOpcode _opcode; 00058 00059 typedef pset<int> Instances; 00060 Instances _instances_written; 00061 }; 00062 00063 #endif 00064 00065