Main Page   Compound List   File List   Compound Members   File Members  

ContentSource.h

Go to the documentation of this file.
00001 /*
00002  * Modification History
00003  *
00004  * 2002-February-12    Jason Rohrer
00005  * Created from UML diagram.
00006  *
00007  * 2002-March-3    Jason Rohrer
00008  * Added a virtual destructor.
00009  *
00010  * 2002-March-8    Jason Rohrer
00011  * Added a copy function.
00012  *
00013  * 2002-March-9    Jason Rohrer
00014  * Added a skipContent function.
00015  * Changed readContent to take an unsigned char buffer.
00016  *
00017  * 2002-March-11    Jason Rohrer
00018  * Added a restart function.
00019  *
00020  * 2002-July-23    Jason Rohrer
00021  * Added a function for clearing the source.
00022  */
00023 
00024 
00025 
00026 #ifndef CONTENT_SOURCE_INCLUDED
00027 #define CONTENT_SOURCE_INCLUDED
00028 
00029 
00030 
00031 
00032 
00033 
00034 /**
00035  * Interface for a class that can provide buffers full of content.
00036  *
00037  * @author Jason Rohrer
00038  */
00039 class ContentSource {
00040 
00041 
00042 
00043     public:
00044 
00045 
00046 
00047         // present so that virtual deletes work
00048         virtual ~ContentSource();
00049 
00050 
00051         
00052         /**
00053          * Gets the number of bytes remaining to be read.
00054          *
00055          * @return the number of bytes remaining.
00056          */
00057         virtual unsigned long getBytesRemaining(  ) = 0;
00058 
00059 
00060 
00061         /**
00062          * Reads a buffer full of content.
00063          *
00064          * @param outDestinationBuffer the buffer to place the
00065          *   read bytes in.  Must be allocated and destroyed by caller.
00066          * @param inBytesToRead the number of bytes to read
00067          *   into outDestinationBuffer.
00068          *
00069          * @return the number of bytes read successfully.
00070          */
00071         virtual int readContent( unsigned char * outDestinationBuffer,
00072                                  unsigned long inBytesToRead ) = 0;
00073 
00074 
00075 
00076         /**
00077          * Skips content.
00078          *
00079          * @param inBytesToSkip the number of bytes to skip.
00080          */
00081         virtual void skipContent( unsigned long inBytesToSkip )  = 0;
00082 
00083 
00084 
00085         /**
00086          * Restarts this content source so that
00087          * readContent will re-read the first byte.
00088          */
00089         virtual void restart() = 0;
00090 
00091 
00092 
00093         /**
00094          * Destroys the content underlying this source.
00095          *
00096          * For example, if this content source reads from a file on
00097          * disk, calling clear() on this source will remove the file
00098          * from the disk.
00099          *
00100          * Calling clear() may render a content source unusable.
00101          */
00102         virtual void clear() = 0;
00103 
00104         
00105         
00106         /**
00107          * Makes a deep copy of this source.
00108          *
00109          * @param a copy of this source.
00110          *   Must be destroyed by caller.
00111          */
00112         virtual ContentSource *copy() = 0;
00113 
00114 
00115         
00116     };
00117 
00118 
00119 
00120 #endif

Generated at Tue Oct 29 12:29:29 2002 for konspire2b API by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001