Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

pldatasrc.cpp

Go to the documentation of this file.
00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: pldatasrc.cpp,v 1.1 2004/05/21 21:02:52 maxx Exp $
00005 |      Data Source Base Class
00006 |
00007 |      This is a base class for a source of picture data.
00008 |      It defines methods to open, close, and read from data sources.
00009 |
00010 |      Copyright (c) 1996-1998 Ulrich von Zadow
00011 |
00012 \--------------------------------------------------------------------
00013 */
00014 
00015 #include "plstdpch.h"
00016 
00017 #include "pldatasrc.h"
00018 #include "plprognot.h"
00019 
00020 
00021 PLDataSource::PLDataSource
00022     ( 
00023       PLIProgressNotification * pNotification
00024     )
00025     : PLObject(),
00026       m_pszName(NULL),
00027       m_FileSize(0),
00028       m_BytesRead(0),
00029       m_bSrcLSBFirst(true),   // Source byte order: true for intel order,
00030                               // false for Motorola et al. (MSB first).
00031       m_pNotification(pNotification)
00032 
00033 {
00034 }
00035 
00036 
00037 PLDataSource::~PLDataSource
00038     ()
00039 {
00040 }
00041 
00042 
00043 void PLDataSource::Open
00044     ( const char * pszName,
00045       int    FileSize
00046     )
00047 {
00048   // Data source may not be open already!
00049   PLASSERT (!m_FileSize);
00050 
00051   m_pszName = new char [strlen (pszName)+1];
00052   strcpy (m_pszName, pszName);
00053   m_FileSize = FileSize;
00054   m_BytesRead = 0;
00055 }
00056 
00057 
00058 void PLDataSource::Close
00059     ()
00060 {
00061   if (m_pNotification)
00062     // be smart and tell the world: ich habe fertig!
00063     m_pNotification->OnProgress( 1);
00064   delete [] m_pszName;
00065   m_pszName = NULL;
00066 }
00067 
00068 
00069 char * PLDataSource::GetName
00070     ()
00071 {
00072   return m_pszName;
00073 }
00074 
00075 PLBYTE * PLDataSource::ReadNBytes
00076     ( int n
00077     )
00078 {
00079   int OldBytesRead = m_BytesRead;
00080   m_BytesRead += n;
00081   if (m_BytesRead/1024 > OldBytesRead/1024 && m_pNotification)
00082     m_pNotification->OnProgress (double(m_BytesRead)/m_FileSize);
00083   CheckEOF();
00084   return NULL;
00085 }
00086 
00087 // Jo Hagelberg 15.4.99:
00088 // for use by other libs that handle progress internally (eg libjpeg)
00089 void PLDataSource::OProgressNotification
00090     ( double part
00091     )
00092 {
00093   if( m_pNotification)
00094     m_pNotification->OnProgress( part);
00095 }
00096 /*
00097 /--------------------------------------------------------------------
00098 |
00099 |      $Log: pldatasrc.cpp,v $
00100 |      Revision 1.1  2004/05/21 21:02:52  maxx
00101 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00102 |
00103 |      Revision 1.1  2002/11/13 01:58:21  mspindle
00104 |      *** empty log message ***
00105 |
00106 |      Revision 1.2  2001/10/06 22:37:08  uzadow
00107 |      Linux compatibility.
00108 |
00109 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00110 |      Added global name prefix PL, changed most filenames.
00111 |
00112 |      Revision 1.8  2001/02/04 14:31:52  uzadow
00113 |      Member initialization list cleanup (Erik Hoffmann).
00114 |
00115 |      Revision 1.7  2001/01/21 14:28:21  uzadow
00116 |      Changed array cleanup from delete to delete[].
00117 |
00118 |      Revision 1.6  2000/01/16 20:43:13  anonymous
00119 |      Removed MFC dependencies
00120 |
00121 |      Revision 1.5  1999/12/08 15:39:45  Ulrich von Zadow
00122 |      Unix compatibility changes
00123 |
00124 |      Revision 1.4  1999/10/03 18:50:51  Ulrich von Zadow
00125 |      Added automatic logging of changes.
00126 |
00127 |
00128 \--------------------------------------------------------------------
00129 */

Generated on Wed Dec 15 21:20:30 2004 for vuVolume by  doxygen 1.3.9.1