[Scummvm-cvs-logs] CVS: scummvm/common file.cpp,1.76,1.77 file.h,1.31,1.32 stream.cpp,1.5,1.6 stream.h,1.11,1.12 system.cpp,1.17,1.18 system.h,1.80,1.81
Max Horn
fingolfin at users.sourceforge.net
Sat Jan 8 18:03:07 CET 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/saga actor.h,1.43,1.44 saga.cpp,1.82,1.83 saga.h,1.66,1.67 script.h,1.49,1.50
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.409,1.410 sound.h,1.77,1.78
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2747
Modified Files:
file.cpp file.h stream.cpp stream.h system.cpp system.h
Log Message:
Added new interface SeekableReadStream
Index: file.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/file.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- file.cpp 1 Jan 2005 16:08:49 -0000 1.76
+++ file.cpp 9 Jan 2005 01:41:42 -0000 1.77
@@ -201,7 +201,7 @@
_ioFailed = false;
}
-bool File::eof() {
+bool File::eof() const {
if (_handle == NULL) {
error("File::eof: File is not open!");
return false;
@@ -210,7 +210,7 @@
return feof(_handle) != 0;
}
-uint32 File::pos() {
+uint32 File::pos() const {
if (_handle == NULL) {
error("File::pos: File is not open!");
return 0;
@@ -219,7 +219,7 @@
return ftell(_handle);
}
-uint32 File::size() {
+uint32 File::size() const {
if (_handle == NULL) {
error("File::size: File is not open!");
return 0;
Index: file.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/file.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- file.h 1 Jan 2005 16:08:49 -0000 1.31
+++ file.h 9 Jan 2005 01:41:43 -0000 1.32
@@ -27,7 +27,7 @@
#include "common/str.h"
#include "common/stream.h"
-class File : public Common::ReadStream, public Common::WriteStream {
+class File : public Common::SeekableReadStream, public Common::WriteStream {
protected:
/** POSIX file handle to the actual file; 0 if no file is open. */
FILE *_handle;
@@ -66,11 +66,11 @@
bool isOpen() const;
bool ioFailed() const;
void clearIOFailed();
- virtual bool eof();
- virtual uint32 pos();
- virtual uint32 size();
+ bool eof() const;
+ uint32 pos() const;
+ uint32 size() const;
const char *name() const { return _name.c_str(); }
- virtual void seek(int32 offs, int whence = SEEK_SET);
+ void seek(int32 offs, int whence = SEEK_SET);
uint32 read(void *ptr, uint32 size);
uint32 write(const void *ptr, uint32 size);
char *gets(void *ptr, uint32 size);
Index: stream.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/stream.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- stream.cpp 1 Jan 2005 16:08:50 -0000 1.5
+++ stream.cpp 9 Jan 2005 01:41:43 -0000 1.6
@@ -25,9 +25,9 @@
namespace Common {
-void MemoryReadStream::seek(uint32 offs, int whence) {
+void MemoryReadStream::seek(int32 offs, int whence) {
// Pre-Condition
- assert(_pos <= _bufSize);
+ assert(0 <= _pos && _pos <= _bufSize);
switch (whence) {
case SEEK_END:
// SEEK_END works just like SEEK_SET, only 'reversed',
@@ -45,7 +45,7 @@
break;
}
// Post-Condition
- assert(_pos <= _bufSize);
+ assert(0 <= _pos && _pos <= _bufSize);
}
Index: stream.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/stream.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- stream.h 1 Jan 2005 16:08:50 -0000 1.11
+++ stream.h 9 Jan 2005 01:41:43 -0000 1.12
@@ -166,6 +166,24 @@
}
};
+
+/**
+ * Interface for a seekable & readable data stream.
+ *
+ * @todo We really need better error handling here!
+ * Like seek should somehow indicate whether it failed.
+ */
+class SeekableReadStream : public ReadStream {
+public:
+
+ virtual bool eof() const = 0;
+ virtual uint32 pos() const = 0;
+ virtual uint32 size() const = 0;
+
+ virtual void seek(int32 offs, int whence = SEEK_SET) = 0;
+};
+
+
/**
* XORReadStream is a wrapper around an arbitrary other ReadStream,
* which 'decrypts' the data being read by XORing all data bytes with the given
@@ -200,7 +218,7 @@
* Simple memory based 'stream', which implements the ReadStream interface for
* a plain memory block.
*/
-class MemoryReadStream : public ReadStream {
+class MemoryReadStream : public SeekableReadStream {
private:
const byte *_ptr;
const byte * const _ptrOrig;
@@ -223,7 +241,7 @@
uint32 pos() const { return _pos; }
uint32 size() const { return _bufSize; }
- void seek(uint32 offs, int whence = SEEK_SET);
+ void seek(int32 offs, int whence = SEEK_SET);
};
} // End of namespace Common
Index: system.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/system.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- system.cpp 6 Jan 2005 18:38:34 -0000 1.17
+++ system.cpp 9 Jan 2005 01:41:43 -0000 1.18
@@ -35,6 +35,10 @@
template <>
OSystem *Common::Singleton<OSystem>::makeInstance() {
+ return OSystem::createSystem();
+}
+
+OSystem *OSystem::createSystem() {
// Attention: Do not call parseGraphicsMode() here, nor any other function
// which needs to access the OSystem instance, else you get stuck in an
// endless loop.
Index: system.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- system.h 6 Jan 2005 19:34:07 -0000 1.80
+++ system.h 9 Jan 2005 01:41:43 -0000 1.81
@@ -29,14 +29,6 @@
#include "common/savefile.h"
#include "common/singleton.h"
-class OSystem;
-
-/**
- * Custom object factory for OSystem.
- */
-template <>
-OSystem *Common::Singleton<OSystem>::makeInstance();
-
/**
* Interface for ScummVM backends. If you want to port ScummVM to a system
@@ -49,6 +41,10 @@
* control audio CD playback, and sound output.
*/
class OSystem : public Common::Singleton<OSystem> {
+protected:
+ static OSystem *createSystem();
+ friend class Common::Singleton<SingletonBaseType>;
+
public:
/** @name Feature flags */
@@ -682,6 +678,14 @@
//@}
};
+/**
+ * Custom object factory for OSystem.
+ */
+template <>
+OSystem *Common::Singleton<OSystem>::makeInstance();
+
+
+
/** The global OSystem instance. Inited in main(). */
#define g_system (&OSystem::instance())
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/saga actor.h,1.43,1.44 saga.cpp,1.82,1.83 saga.h,1.66,1.67 script.h,1.49,1.50
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.409,1.410 sound.h,1.77,1.78
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list