From b3da11ba8afc3925de551ae7cc51ccc73e721211 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 8 Feb 2010 21:46:50 +0000 Subject: Introduce factory function makeArjArchive, hide ArjArchive class implementation svn-id: r48009 --- common/unarj.cpp | 24 ++++++++++++++++++++++++ common/unarj.h | 26 +++++--------------------- engines/drascula/resource.cpp | 2 +- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/common/unarj.cpp b/common/unarj.cpp index 57f55f2c1e..895b0928b3 100644 --- a/common/unarj.cpp +++ b/common/unarj.cpp @@ -712,6 +712,26 @@ void ArjDecoder::decode_f(int32 origsize) { #pragma mark ArjArchive implementation +typedef HashMap ArjFilesMap; + +class ArjArchive : public Common::Archive { + + Common::Array _headers; + ArjFilesMap _fileMap; + + Common::String _arjFilename; + +public: + ArjArchive(const String &name); + virtual ~ArjArchive(); + + // Common::Archive implementation + virtual bool hasFile(const String &name); + virtual int listMembers(ArchiveMemberList &list); + virtual ArchiveMemberPtr getMember(const String &name); + virtual SeekableReadStream *createReadStreamForMember(const String &name) const; +}; + ArjArchive::ArjArchive(const String &filename) : _arjFilename(filename) { Common::File arjFile; @@ -813,4 +833,8 @@ SeekableReadStream *ArjArchive::createReadStreamForMember(const String &name) co return new Common::MemoryReadStream(uncompressedData, hdr->origSize, DisposeAfterUse::YES); } +Archive *makeArjArchive(const String &name) { + return new ArjArchive(name); +} + } // End of namespace Common diff --git a/common/unarj.h b/common/unarj.h index f44828baca..831c8aeb90 100644 --- a/common/unarj.h +++ b/common/unarj.h @@ -32,27 +32,11 @@ namespace Common { -struct ArjHeader; - -typedef HashMap ArjFilesMap; - -class ArjArchive : public Common::Archive { - - Common::Array _headers; - ArjFilesMap _fileMap; - - Common::String _arjFilename; - -public: - ArjArchive(const String &name); - virtual ~ArjArchive(); - - // Common::Archive implementation - virtual bool hasFile(const String &name); - virtual int listMembers(ArchiveMemberList &list); - virtual ArchiveMemberPtr getMember(const String &name); - virtual SeekableReadStream *createReadStreamForMember(const String &name) const; -}; +/** + * This factory method creates an Archive instance corresponding to the content + * of the ARJ compressed file with the given name. + */ +Archive *makeArjArchive(const String &name); } // End of namespace Common diff --git a/engines/drascula/resource.cpp b/engines/drascula/resource.cpp index cfa8ab9af3..b26c4605fb 100644 --- a/engines/drascula/resource.cpp +++ b/engines/drascula/resource.cpp @@ -35,7 +35,7 @@ ArchiveMan::~ArchiveMan() { } void ArchiveMan::registerArchive(const Common::String &filename) { - add(filename, new Common::ArjArchive(filename)); + add(filename, Common::makeArjArchive(filename)); } Common::SeekableReadStream *ArchiveMan::open(const Common::String &filename) { -- cgit v1.2.3