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

panda/src/pnmimage/pnmFileType.h

Go to the documentation of this file.
00001 // Filename: pnmFileType.h
00002 // Created by:  drose (15Jun00)
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 PNMFILETYPE_H
00020 #define PNMFILETYPE_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "pnmimage_base.h"
00025 
00026 #include "typedObject.h"
00027 #include "typedWritable.h"
00028 
00029 class PNMReader;
00030 class PNMWriter;
00031 class FactoryParams;
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //       Class : PNMFileType
00035 // Description : This is the base class of a family of classes that
00036 //               represent particular image file types that PNMImage
00037 //               supports.
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDA PNMFileType : public TypedWritable {
00040 protected:
00041   PNMFileType();
00042 
00043 public:
00044   virtual ~PNMFileType();
00045 
00046   virtual string get_name() const=0;
00047 
00048   virtual int get_num_extensions() const;
00049   virtual string get_extension(int n) const;
00050   virtual string get_suggested_extension() const;
00051 
00052   virtual bool has_magic_number() const;
00053   virtual bool matches_magic_number(const string &magic_number) const;
00054 
00055   virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00056                                  const string &magic_number = string());
00057   virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00058 
00059 protected:
00060   static void init_pnm();
00061 
00062 private:
00063   static bool _did_init_pnm;
00064 
00065 
00066   // The TypedWritable interface follows.
00067 public:
00068   static void register_with_read_factory(void);
00069   virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00070 
00071 protected:
00072   static TypedWritable *make_PNMFileType(const FactoryParams &params);
00073 
00074 public:
00075   static TypeHandle get_class_type() {
00076     return _type_handle;
00077   }
00078   static void init_type() {
00079     TypedWritable::init_type();
00080     register_type(_type_handle, "PNMFileType",
00081                   TypedWritable::get_class_type());
00082   }
00083   virtual TypeHandle get_type() const {
00084     return get_class_type();
00085   }
00086   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00087 
00088 private:
00089   static TypeHandle _type_handle;
00090 };
00091 
00092 #endif
00093 

Generated on Fri May 2 00:43:06 2003 for Panda by doxygen1.3