stream.h

00001 /*
00002  * libopenraw - stream.h
00003  *
00004  * Copyright (C) 2006 Hubert Figuière
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 
00022 #ifndef __IO_STREAM_H__
00023 #define __IO_STREAM_H__
00024 
00025 #include <sys/types.h>
00026 #include <unistd.h>
00027 
00028 #include <string>
00029 
00030 #include <libopenraw/libopenraw.h>
00031 
00032 namespace OpenRaw {
00033     namespace IO {
00034         
00038         class Stream
00039         {
00040         public:
00044             Stream(const char *filename);
00045             virtual ~Stream();
00046             
00050             typedef ::or_error Error;
00051             
00052 // file APIs
00054             virtual Error open() = 0;
00056             virtual int close() = 0;
00058             virtual int seek(off_t offset, int whence) = 0;
00060             virtual int read(void *buf, size_t count) = 0;
00061             virtual off_t filesize() = 0;
00062 //          virtual void *mmap(size_t l, off_t offset) = 0;
00063 //          virtual int munmap(void *addr, size_t l) = 0;
00064             
00065             Error get_error()
00066                 {
00067                     return m_error;
00068                 }
00069 
00071             const std::string &get_path() const
00072                 {
00073                     return m_fileName;
00074                 }
00075 
00076         protected:
00077             void set_error(Error error)
00078                 {
00079                     m_error = error;
00080                 }
00081 
00082         private:
00084             Stream(const Stream& f);
00086             Stream & operator=(const Stream&);
00087             
00089             std::string m_fileName;
00090             Error m_error;
00091         };
00092 
00093     }
00094 }
00095 
00096 
00097 #endif

Generated on Sat Jan 27 11:36:13 2007 for libopenraw by  doxygen 1.4.7