Panda3D

datagramOutputFile.h

00001 // Filename: datagramOutputFile.h
00002 // Created by:  drose (30Oct00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef DATAGRAMOUTPUTFILE_H
00016 #define DATAGRAMOUTPUTFILE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "datagramSink.h"
00021 #include "filename.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : DatagramOutputFile
00025 // Description : This class can be used to write a binary file that
00026 //               consists of an arbitrary header followed by a number
00027 //               of datagrams.
00028 ////////////////////////////////////////////////////////////////////
00029 class EXPCL_PANDA_PUTIL DatagramOutputFile : public DatagramSink {
00030 public:
00031   INLINE DatagramOutputFile();
00032 
00033   bool open(Filename filename);
00034   bool open(ostream &out);
00035 
00036   void close();
00037 
00038   bool write_header(const string &header);
00039   virtual bool put_datagram(const Datagram &data);
00040   virtual bool is_error();
00041   virtual void flush();
00042 
00043 private:
00044   bool _wrote_first_datagram;
00045   bool _error;
00046   pofstream _out_file;
00047   ostream *_out;
00048   bool _owns_out;
00049 };
00050 
00051 #include "datagramOutputFile.I"
00052 
00053 #endif
 All Classes Functions Variables Enumerations