Panda3D
iffChunk.h
1 // Filename: iffChunk.h
2 // Created by: drose (23Apr01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef IFFCHUNK_H
16 #define IFFCHUNK_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "iffId.h"
21 
22 #include "typedObject.h"
23 #include "typedReferenceCount.h"
24 
25 class IffInputFile;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : IffChunk
29 // Description : The basic kind of record in an EA "IFF" file, which
30 // the LightWave object file is based on.
31 ////////////////////////////////////////////////////////////////////
32 class IffChunk : public TypedReferenceCount {
33 public:
34  INLINE IffChunk();
35 
36  INLINE IffId get_id() const;
37  INLINE void set_id(IffId id);
38 
39  virtual bool read_iff(IffInputFile *in, size_t stop_at)=0;
40 
41  virtual void output(ostream &out) const;
42  virtual void write(ostream &out, int indent_level = 0) const;
43 
44  virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id);
45 
46 private:
47  IffId _id;
48 
49 public:
50  virtual TypeHandle get_type() const {
51  return get_class_type();
52  }
53  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
54  static TypeHandle get_class_type() {
55  return _type_handle;
56  }
57  static void init_type() {
58  TypedReferenceCount::init_type();
59  register_type(_type_handle, "IffChunk",
60  TypedReferenceCount::get_class_type());
61  }
62 
63 private:
64  static TypeHandle _type_handle;
65 };
66 
67 #include "iffChunk.I"
68 
69 INLINE ostream &operator << (ostream &out, const IffChunk &chunk) {
70  chunk.output(out);
71  return out;
72 }
73 
74 #endif
75 
76 
virtual IffChunk * make_new_chunk(IffInputFile *in, IffId id)
Allocates and returns a new chunk of the appropriate type based on the given ID, according to the con...
Definition: iffChunk.cxx:50
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
The basic kind of record in an EA "IFF" file, which the LightWave object file is based on...
Definition: iffChunk.h:32
A wrapper around an istream used for reading an IFF file.
Definition: iffInputFile.h:33
void set_id(IffId id)
Changes the ID associated with this chunk.
Definition: iffChunk.I:41
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A four-byte chunk ID appearing in an "IFF" file.
Definition: iffId.h:29
IffId get_id() const
Returns the ID associated with this chunk.
Definition: iffChunk.I:31