Panda3D
 All Classes Functions Variables Enumerations
pnmFileType.h
1 // Filename: pnmFileType.h
2 // Created by: drose (15Jun00)
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 PNMFILETYPE_H
16 #define PNMFILETYPE_H
17 
18 #include "pandabase.h"
19 
20 #include "pnmimage_base.h"
21 
22 #include "typedObject.h"
23 #include "typedWritable.h"
24 
25 class PNMReader;
26 class PNMWriter;
27 class FactoryParams;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : PNMFileType
31 // Description : This is the base class of a family of classes that
32 // represent particular image file types that PNMImage
33 // supports.
34 ////////////////////////////////////////////////////////////////////
35 class EXPCL_PANDA_PNMIMAGE PNMFileType : public TypedWritable {
36 protected:
37  PNMFileType();
38 
39 public:
40  virtual ~PNMFileType();
41 
42 PUBLISHED:
43  virtual string get_name() const=0;
44 
45  virtual int get_num_extensions() const;
46  virtual string get_extension(int n) const;
47  MAKE_SEQ(get_extensions, get_num_extensions, get_extension);
48  virtual string get_suggested_extension() const;
49 
50 public:
51  virtual bool has_magic_number() const;
52  virtual bool matches_magic_number(const string &magic_number) const;
53 
54  virtual PNMReader *make_reader(istream *file, bool owns_file = true,
55  const string &magic_number = string());
56  virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
57 
58 protected:
59  static void init_pnm();
60 
61 private:
62  static bool _did_init_pnm;
63 
64 
65  // The TypedWritable interface follows.
66 public:
67  static void register_with_read_factory();
68  virtual void write_datagram(BamWriter *writer, Datagram &datagram);
69 
70 protected:
71  static TypedWritable *make_PNMFileType(const FactoryParams &params);
72 
73 public:
74  static TypeHandle get_class_type() {
75  return _type_handle;
76  }
77  static void init_type() {
78  TypedWritable::init_type();
79  register_type(_type_handle, "PNMFileType",
80  TypedWritable::get_class_type());
81  }
82  virtual TypeHandle get_type() const {
83  return get_class_type();
84  }
85  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
86 
87 private:
88  static TypeHandle _type_handle;
89 };
90 
91 #endif
92 
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition: pnmFileType.h:35
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
This is an abstract base class that defines the interface for reading image files of various types...
Definition: pnmReader.h:31
This is an abstract base class that defines the interface for writing image files of various types...
Definition: pnmWriter.h:31
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43