Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/flt/fltRecord.h

Go to the documentation of this file.
00001 // Filename: fltRecord.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 FLTRECORD_H
00020 #define FLTRECORD_H
00021 
00022 #include "pandatoolbase.h"
00023 
00024 #include "fltOpcode.h"
00025 #include "fltError.h"
00026 
00027 #include "typedObject.h"
00028 #include "typedReferenceCount.h"
00029 #include "pointerTo.h"
00030 
00031 class FltHeader;
00032 class FltRecordReader;
00033 class FltRecordWriter;
00034 class DatagramIterator;
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //       Class : FltRecord
00038 // Description : The base class for all kinds of records in a MultiGen
00039 //               OpenFlight file.  A flt file consists of a hierarchy
00040 //               of "beads" of various kinds, each of which may be
00041 //               followed by n ancillary records, written sequentially
00042 //               to the file.
00043 ////////////////////////////////////////////////////////////////////
00044 class FltRecord : public TypedReferenceCount {
00045 public:
00046   FltRecord(FltHeader *header);
00047   virtual ~FltRecord();
00048 
00049   int get_num_children() const;
00050   FltRecord *get_child(int n) const;
00051   void clear_children();
00052   void add_child(FltRecord *child);
00053 
00054   int get_num_subfaces() const;
00055   FltRecord *get_subface(int n) const;
00056   void clear_subfaces();
00057   void add_subface(FltRecord *subface);
00058 
00059   int get_num_extensions() const;
00060   FltRecord *get_extension(int n) const;
00061   void clear_extensions();
00062   void add_extension(FltRecord *extension);
00063 
00064   int get_num_ancillary() const;
00065   FltRecord *get_ancillary(int n) const;
00066   void clear_ancillary();
00067   void add_ancillary(FltRecord *ancillary);
00068 
00069   bool has_comment() const;
00070   const string &get_comment() const;
00071   void clear_comment();
00072   void set_comment(const string &comment);
00073 
00074   void check_remaining_size(const DatagramIterator &di, 
00075                             const string &name = string()) const;
00076 
00077   virtual void apply_converted_filenames();
00078 
00079   virtual void output(ostream &out) const;
00080   virtual void write(ostream &out, int indent_level = 0) const;
00081 
00082 protected:
00083   void write_children(ostream &out, int indent_level) const;
00084 
00085   static bool is_ancillary(FltOpcode opcode);
00086 
00087   FltRecord *create_new_record(FltOpcode opcode) const;
00088   FltError read_record_and_children(FltRecordReader &reader);
00089   virtual bool extract_record(FltRecordReader &reader);
00090   virtual bool extract_ancillary(FltRecordReader &reader);
00091 
00092   virtual FltError write_record_and_children(FltRecordWriter &writer) const;
00093   virtual bool build_record(FltRecordWriter &writer) const;
00094   virtual FltError write_ancillary(FltRecordWriter &writer) const;
00095 
00096 protected:
00097   FltHeader *_header;
00098 
00099 private:
00100   typedef pvector<PT(FltRecord)> Records;
00101   Records _children;
00102   Records _subfaces;
00103   Records _extensions;
00104   Records _ancillary;
00105 
00106   string _comment;
00107 
00108 
00109 public:
00110   virtual TypeHandle get_type() const {
00111     return get_class_type();
00112   }
00113   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00114   static TypeHandle get_class_type() {
00115     return _type_handle;
00116   }
00117   static void init_type() {
00118     TypedReferenceCount::init_type();
00119     register_type(_type_handle, "FltRecord",
00120                   TypedReferenceCount::get_class_type());
00121   }
00122 
00123 private:
00124   static TypeHandle _type_handle;
00125 };
00126 
00127 INLINE ostream &operator << (ostream &out, const FltRecord &record);
00128 
00129 #include "fltRecord.I"
00130 
00131 #endif
00132 
00133 

Generated on Fri May 2 03:19:32 2003 for Panda-Tool by doxygen1.3