degate  0.1.2
ImageWriterBase.h
Go to the documentation of this file.
00001 /* -*-c++-*-
00002 
00003  This file is part of the IC reverse engineering tool degate.
00004 
00005  Copyright 2008, 2009, 2010 by Martin Schobert
00006 
00007  Degate is free software: you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by
00009  the Free Software Foundation, either version 3 of the License, or
00010  any later version.
00011 
00012  Degate is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU General Public License for more details.
00016 
00017  You should have received a copy of the GNU General Public License
00018  along with degate. If not, see <http://www.gnu.org/licenses/>.
00019 
00020 */
00021 
00022 #ifndef __IMAGEWRITERBASE_H__
00023 #define __IMAGEWRITERBASE_H__
00024 
00025 #include <list>
00026 #include <memory>
00027 #include "degate_exceptions.h"
00028 
00029 #include "TypeTraits.h"
00030 #include "StoragePolicies.h"
00031 #include "PixelPolicies.h"
00032 #include "FileSystem.h"
00033 #include <degate_exceptions.h>
00034 
00035 namespace degate {
00036 
00037   /**
00038    * The base class for image readers.
00039    */
00040 
00041   template<class ImageType>
00042   class ImageWriterBase {
00043   private:
00044 
00045     std::string filename;
00046     unsigned int width, height;
00047 
00048   protected:
00049 
00050     /**
00051      * Set the width of the image.
00052      * This method should be called by derived image readers to set
00053      * the image size.
00054      */
00055     void set_width(unsigned int _width) { width = _width; }
00056 
00057 
00058     /**
00059      * Set the height of the image.
00060      * This method should be called by derived image readers to set
00061      * the image size.
00062      */
00063     void set_height(unsigned int _height) { height = _height; }
00064 
00065 
00066   public:
00067 
00068     /**
00069      * Constructor.
00070      */
00071 
00072     ImageWriterBase(unsigned int _width,
00073                     unsigned int _height,
00074                     std::string const & _filename) :
00075       filename(_filename),
00076       width(_width),
00077       height(_height) {}
00078 
00079     /**
00080      * The destructor.
00081      */
00082 
00083     virtual ~ImageWriterBase() {}
00084 
00085     /**
00086      * Get the filename.
00087      */
00088 
00089     std::string get_filename() const { return filename; }
00090 
00091     /**
00092      * Get the image width.
00093      * You have to call read() before.
00094      */
00095 
00096     unsigned int get_width() const { return width; }
00097 
00098     /**
00099      * Get the image height.
00100      * You have to call read() before.
00101      */
00102 
00103     unsigned int get_height() const { return height; }
00104 
00105 
00106 
00107     /**
00108      * Writer the image into a file.
00109      */
00110 
00111     virtual bool write_image(std::shared_ptr<ImageType> img) = 0;
00112 
00113   };
00114 
00115 
00116 
00117 }
00118 
00119 #endif