[Scummvm-cvs-logs] SF.net SVN: scummvm: [27891] scummex/branches/gsoc2007-gameresbrowser

zbychs at users.sourceforge.net zbychs at users.sourceforge.net
Wed Jul 4 03:34:12 CEST 2007


Revision: 27891
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27891&view=rev
Author:   zbychs
Date:     2007-07-03 18:34:12 -0700 (Tue, 03 Jul 2007)

Log Message:
-----------
Browsing disk files now possible. Available sample presenter for BMP files.

Modified Paths:
--------------
    scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/FileTypeRecognizer.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/common/simplefile.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/functionalex.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot_detail.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/plugin.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/plugin_detail.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/rcobject.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/core/rcobject.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/safe_static.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/treealgos.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/BrowserApp.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/FilePresenter.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/FilePresenter.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/PanelProvider.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/PanelProvider.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/Test1.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/guicon.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/BMPParser.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/BMPParser.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/BitmapPanel.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/BitmapPanel.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/DiskFileProvider.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/DiskFileProvider.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/FileTypeRecognizer.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/GUIIntf.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/GUIIntf.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/ftregistry.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/wx2scstream.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/wx2scstream.h
    scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_plugins.cpp
    scummex/branches/gsoc2007-gameresbrowser/vc8/Browser/Browser.vcproj
    scummex/branches/gsoc2007-gameresbrowser/vc8/core/core.vcproj
    scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/plugins.vcproj

Added Paths:
-----------
    scummex/branches/gsoc2007-gameresbrowser/src/core/ReadMe.txt
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/Directories.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/Directories.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/ReadMe.txt

Removed Paths:
-------------
    scummex/branches/gsoc2007-gameresbrowser/vc8/core/ReadMe.txt
    scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/ReadMe.txt

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.cpp	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.cpp	2007-07-04 01:34:12 UTC (rev 27891)
@@ -4,6 +4,7 @@
 #include "stdafx.h"
 
 #include "CoreIntf.h"
+#include "common/simplefile.h"
 
 #include <iostream>
 
@@ -16,32 +17,65 @@
 // Concrete implementations of the interfaces
 
 IStreamImpl::IStreamImpl(Common::SeekableReadStream* stream, bool ownStream /*= false*/)
-    : _stream(stream), _ownStream(ownStream) {}
+	: _stream(stream), _ownStream(ownStream) {}
 
 Common::SeekableReadStream* IStreamImpl::getStream() {
-    std::cout << "IStreamImpl::getStream()" << std::endl;
-    return _stream;
+	return _stream;
 }
 
 IStreamImpl::~IStreamImpl() {
-    if(_ownStream)
-        delete _stream;
+	if(_ownStream)
+		delete _stream;
 }
 
 
 IFileImpl::IFileImpl(std::string name, Common::SeekableReadStream* stream, bool ownStream /*= false*/)
-    : _streamImpl(stream,ownStream), _name(name) {}
+	: _streamImpl(stream,ownStream), _name(name) {}
 
 const std::string& IFileImpl::getName() {
-    std::cout << "IFileImpl::getName() = " << _name << std::endl;
-    return _name;
+	return _name;
 }
 
 Common::SeekableReadStream* IFileImpl::getStream() {
-    return _streamImpl.getStream();
+	return _streamImpl.getStream();
 }
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 
+IDiskFileImpl::IDiskFileImpl(std::string name, std::string fullpath)
+	: _name(name), _fullpath(fullpath), _stream(NULL) {}
+
+IDiskFileImpl::~IDiskFileImpl() {
+	diet();
+}
+
+void IDiskFileImpl::diet() {
+	if (_stream)
+		delete _stream;
+	_stream = NULL;
+}
+
+const std::string& IDiskFileImpl::getName() {
+	return _name;
+}
+
+Common::SeekableReadStream* IDiskFileImpl::getStream() {
+	if (!_stream) {
+		Common::SimpleFile* file = new Common::SimpleFile();
+		bool res = file->open( _fullpath.c_str() );
+		if (!res) {
+			std::cout << "ERROR: IDiskFileImpl::getStream(): could not open file" << std::endl;
+			delete file;
+			return NULL;
+		}
+		_stream = file;
+	}
+
+	return _stream;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 } // namespace Browser

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -17,20 +17,26 @@
 
 class IStream : public IInterface {
 public:
-    GUID_FOR(IStream, "CoreInterfaces", 1);
-    virtual Common::SeekableReadStream* getStream() = 0;
+	GUID_FOR(IStream, "CoreInterfaces", 1);
+	virtual Common::SeekableReadStream* getStream() = 0;
 };
 
 class IFile : public IStream {
 public:
-    GUID_FOR(IFile, "CoreInterfaces", 1);
-    virtual const std::string& getName() = 0;
+	GUID_FOR(IFile, "CoreInterfaces", 1);
+	virtual const std::string& getName() = 0;
 };
 
+//TODO: IDirectory should support get/release semantics for IFiles
+//      It would enable disk files once opened, to be closed, memory
+//      once allocated, to be freed when not used anymore.
+//      Do it via dynamic dummy Slots?
 class IDirectory : public IInterface {
 public:
-    GUID_FOR(IDirectory, "CoreInterfaces", 1);
-    virtual const std::list<IFile*>& getFiles() = 0;
+	GUID_FOR(IDirectory, "CoreInterfaces", 1);
+	virtual const std::string& getName() = 0;
+	virtual const std::list<IFile*>& getFiles() = 0;
+	virtual const std::list<IDirectory*>& getSubDirs() = 0;
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -39,13 +45,13 @@
 
 class IStreamImpl : public IStream {
 protected:
-    Common::SeekableReadStream* _stream;
-    bool _ownStream;
+	Common::SeekableReadStream* _stream;
+	bool _ownStream;
 public:
-    //inherit guid - it's a concrete implementation of an abstract interface
-    IStreamImpl(Common::SeekableReadStream* stream, bool ownStream = false);
-    virtual Common::SeekableReadStream* getStream();
-    virtual ~IStreamImpl();
+	//inherit guid - it's a concrete implementation of an abstract interface
+	IStreamImpl(Common::SeekableReadStream* stream, bool ownStream = false);
+	virtual Common::SeekableReadStream* getStream();
+	virtual ~IStreamImpl();
 };
 
 // Limitation: can't inherit from IFile and IStreamImpl, cause I'll have to inherit
@@ -55,15 +61,29 @@
 // Instead of multiple inheritance - I use encapsulation: _streamImpl member.
 class IFileImpl : public IFile {
 protected:
-    std::string _name;
-    IStreamImpl _streamImpl;
+	std::string _name;
+	IStreamImpl _streamImpl;
 public:
-    //inherit guid - it's a concrete implementation of an abstract interface
-    IFileImpl(std::string name, Common::SeekableReadStream* stream, bool ownStream = false);
-    virtual const std::string& getName();
-    virtual Common::SeekableReadStream* getStream();
+	//inherit guid - it's a concrete implementation of an abstract interface
+	IFileImpl(std::string name, Common::SeekableReadStream* stream, bool ownStream = false);
+	virtual const std::string& getName();
+	virtual Common::SeekableReadStream* getStream();
 };
 
+class IDiskFileImpl : public IFile {
+protected:
+	std::string _name;
+	std::string _fullpath;
+	Common::SeekableReadStream* _stream;
+public:
+	//inherit guid - it's a concrete implementation of an abstract interface
+	IDiskFileImpl(std::string name, std::string fullpath);
+	virtual ~IDiskFileImpl();
+	virtual void diet();
+	virtual const std::string& getName();
+	virtual Common::SeekableReadStream* getStream();
+};
+
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/FileTypeRecognizer.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/FileTypeRecognizer.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/FileTypeRecognizer.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -30,17 +30,17 @@
 //                   BinaryParser - POOR
 
 enum FileTypeMatch {
-    NO_MATCH = -1,
-    IDEAL_MATCH = 1,
-    GOOD_MATCH = 2,
-    POOR_MATCH = 3,
+	NO_MATCH = -1,
+	IDEAL_MATCH = 1,
+	GOOD_MATCH = 2,
+	POOR_MATCH = 3,
 };
 
 enum ResolvedParsersPriority {
-    NO_PARSERS = -1,
-    IDEAL_PARSERS = 1,
-    GOOD_PARSERS = 2,
-    POOR_PARSERS = 3,
+	NO_PARSERS = -1,
+	IDEAL_PARSERS = 1,
+	GOOD_PARSERS = 2,
+	POOR_PARSERS = 3,
 };
 
 
@@ -48,25 +48,25 @@
 /////////////////////////////////////////////////////////////////////////////
 
 struct RecognizedFileType {
-    static RecognizedFileType NotRecognized;
+	static RecognizedFileType NotRecognized;
 
-    FileTypeMatch _match;
-    BGUID _fileTypeGUID;
-    RecognizedFileType(FileTypeMatch match, const BGUID& fileTypeGUID)
-        : _match(match), _fileTypeGUID(fileTypeGUID) {}
+	FileTypeMatch _match;
+	BGUID _fileTypeGUID;
+	RecognizedFileType(FileTypeMatch match, const BGUID& fileTypeGUID)
+		: _match(match), _fileTypeGUID(fileTypeGUID) {}
 
-    /*RecognizedFileType(const RecognizedFileType& other)
-        : _match(other._match), _fileTypeGUID(other._fileTypeGUID) {}
-    RecognizedFileType& operator=(const RecognizedFileType& other) {
-        _match = other._match; _fileTypeGUID = other._fileTypeGUID;
-    }*/
+	/*RecognizedFileType(const RecognizedFileType& other)
+		: _match(other._match), _fileTypeGUID(other._fileTypeGUID) {}
+	RecognizedFileType& operator=(const RecognizedFileType& other) {
+		_match = other._match; _fileTypeGUID = other._fileTypeGUID;
+	}*/
 
-    bool isOk() {
-        return _match != NO_MATCH;
-    }
-    bool operator<(const RecognizedFileType& other) const {
-        return this->_match < other._match;
-    }
+	bool isOk() {
+		return _match != NO_MATCH;
+	}
+	bool operator<(const RecognizedFileType& other) const {
+		return this->_match < other._match;
+	}
 };
 
 typedef std::list<RecognizedFileType> RecognizedFileTypes;
@@ -75,20 +75,20 @@
 typedef std::list<BGUID> guid_list;
 
 struct ResolvedFileTypeParsers {
-    static ResolvedFileTypeParsers NoParsers;
+	static ResolvedFileTypeParsers NoParsers;
 
-    ResolvedParsersPriority _priority;
-    guid_list _parserGUIDs;
-    ResolvedFileTypeParsers(ResolvedParsersPriority priority,
-        const guid_list& parserGUIDs)
-        : _priority(priority), _parserGUIDs(parserGUIDs) {}
+	ResolvedParsersPriority _priority;
+	guid_list _parserGUIDs;
+	ResolvedFileTypeParsers(ResolvedParsersPriority priority,
+		const guid_list& parserGUIDs)
+		: _priority(priority), _parserGUIDs(parserGUIDs) {}
 
-    bool isOk() {
-        return _priority != NO_PARSERS;
-    }
-    bool operator<(const ResolvedFileTypeParsers& other) const {
-        return this->_priority < other._priority;
-    }
+	bool isOk() {
+		return _priority != NO_PARSERS;
+	}
+	bool operator<(const ResolvedFileTypeParsers& other) const {
+		return this->_priority < other._priority;
+	}
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -98,12 +98,12 @@
 
 class FileTypeRecognizer {
 public:
-    virtual RecognizedFileType recognize(VirtualFile* file) = 0;
+	virtual RecognizedFileType recognize(VirtualFile* file) = 0;
 };
 
 class FileTypeParserResolver {
 public:
-    virtual ResolvedFileTypeParsers resolve(const BGUID& fileType) = 0;
+	virtual ResolvedFileTypeParsers resolve(const BGUID& fileType) = 0;
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -112,12 +112,12 @@
 //BinaryFileTypeRecognizer - a sample recognizer
 //this is a rather unusual BObject - it does not have any pins nor slots
 class BinaryFileTypeRecognizer : public BObject, public FileTypeRecognizer {
-    DECLARE_BOBJECT_CLASS(BinaryFileTypeRecognizer, BObject)
+	DECLARE_BOBJECT_CLASS(BinaryFileTypeRecognizer, BObject)
 
 public:
-    ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
+	ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
 
-    virtual RecognizedFileType recognize(VirtualFile* file);
+	virtual RecognizedFileType recognize(VirtualFile* file);
 };
 
 
@@ -127,12 +127,12 @@
 //BinaryFileTypeParserResolver - a sample resolver
 //this is a rather unusual BObject - it does not have any pins nor slots
 class BinaryFileTypeParserResolver : public BObject, public FileTypeParserResolver {
-    DECLARE_BOBJECT_CLASS(BinaryFileTypeParserResolver, BObject)
+	DECLARE_BOBJECT_CLASS(BinaryFileTypeParserResolver, BObject)
 
 public:
-    ASSIGN_DESC(IS_FILE_TYPE_RESOLVER, "CoreObjects", 1)
+	ASSIGN_DESC(IS_FILE_TYPE_RESOLVER, "CoreObjects", 1)
 
-    virtual ResolvedFileTypeParsers resolve(const BGUID& fileType);
+	virtual ResolvedFileTypeParsers resolve(const BGUID& fileType);
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -140,46 +140,46 @@
 
 //utility base class for FileTypeRecognizers
 class GenericFileTypeRecognizer : public BObject, public FileTypeRecognizer {
-    DECLARE_BOBJECT_CLASS(GenericFileTypeRecognizer, BObject)
+	DECLARE_BOBJECT_CLASS(GenericFileTypeRecognizer, BObject)
 
 protected:
-    Slot<IFile>* _fileSlot;
+	Slot<IFile>* _fileSlot;
 
 public:
-    ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
+	ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
 
-    SLOT_DESCS
-        SLOT_DESC(_fileSlot, SLOT_DEFAULT)
-    END_DESCS
+	SLOT_DESCS
+		SLOT_DESC(_fileSlot, SLOT_DEFAULT)
+	END_DESCS
 
-    virtual RecognizedFileType recognize(VirtualFile* file);
+	virtual RecognizedFileType recognize(VirtualFile* file);
 
-    //subclasses need to provide this method
-    virtual RecognizedFileType doRecognize(VirtualFile* file, IFile* ifile) = 0;
+	//subclasses need to provide this method
+	virtual RecognizedFileType doRecognize(VirtualFile* file, IFile* ifile) = 0;
 };
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 
 class BMPFileTypeRecognizer : public GenericFileTypeRecognizer {
-    DECLARE_BOBJECT_CLASS(BMPFileTypeRecognizer, BObject)
+	DECLARE_BOBJECT_CLASS(BMPFileTypeRecognizer, BObject)
 
 public:
-    ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
+	ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
 
-    virtual RecognizedFileType doRecognize(VirtualFile* file, IFile* ifile);
+	virtual RecognizedFileType doRecognize(VirtualFile* file, IFile* ifile);
 };
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 
 class BMPFileTypeParserResolver : public BObject, public FileTypeParserResolver {
-    DECLARE_BOBJECT_CLASS(BMPFileTypeParserResolver, BObject)
+	DECLARE_BOBJECT_CLASS(BMPFileTypeParserResolver, BObject)
 
 public:
-    ASSIGN_DESC(IS_FILE_TYPE_RESOLVER, "CoreObjects", 1)
+	ASSIGN_DESC(IS_FILE_TYPE_RESOLVER, "CoreObjects", 1)
 
-    virtual ResolvedFileTypeParsers resolve(const BGUID& fileType);
+	virtual ResolvedFileTypeParsers resolve(const BGUID& fileType);
 };
 
 /////////////////////////////////////////////////////////////////////////////

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/ReadMe.txt (from rev 27884, scummex/branches/gsoc2007-gameresbrowser/vc8/core/ReadMe.txt)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/ReadMe.txt	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/ReadMe.txt	2007-07-04 01:34:12 UTC (rev 27891)
@@ -0,0 +1,33 @@
+========================================================================
+    STATIC LIBRARY : core Project Overview
+========================================================================
+
+Library with core objects for the Game Resource Browser.
+
+TODO: When doing IFile/IStream->getStream() check for NULL result!
+
+Guidelines:
+
+When passing an BObject, pass: const RCPtr<BObject>&
+When returning an BObject, return: RCPtr<BObject>
+
+
+Singletons and statics:
+
+BObjects use statics for their descs, pin-descs and slot-descs.
+Therefore you can't have a static object that owns BObjects -
+you'll get segfaults sooner or later.
+So all singletons (ObjectRegistry, FileTypeRegistry, ExplorationTree etc...)
+that own BObjects need to be explicitly destroyed *before* statics get
+destroyed.
+
+
+Libs from wxDevCpp:
+
+wxmsw28.lib wxmsw28_gl.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib
+kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib opengl32.lib
+
+wxmsw28d.lib wxmsw28d_gl.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib
+kernel32d.lib user32d.lib gdi32d.lib comdlg32d.lib winspoold.lib winmmd.lib shell32d.lib comctl32d.lib ole32d.lib oleaut32d.lib uuidd.lib rpcrt4d.lib advapi32d.lib wsock32d.lib odbc32d.lib opengl32d.lib
+
+========================================================================

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -184,10 +184,10 @@
 		#else
 		/* need this for the SDL_BYTEORDER define */
 		
-    	#define SCUMM_LITTLE_ENDIAN
+		#define SCUMM_LITTLE_ENDIAN
 
-        /* ZZZ
-        #include <SDL_byteorder.h>
+		/* ZZZ
+		#include <SDL_byteorder.h>
 	
 		#if SDL_BYTEORDER == SDL_LIL_ENDIAN
 		#define SCUMM_LITTLE_ENDIAN

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/common/simplefile.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/common/simplefile.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/common/simplefile.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -66,7 +66,7 @@
 	 */
 	//static bool exists(const String &filename);
 
-    virtual bool open(const std::string &filename, AccessMode mode = kFileReadMode);
+	virtual bool open(const std::string &filename, AccessMode mode = kFileReadMode);
 
 	virtual void close();
 

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -1,15 +1,15 @@
 /* debugmem.h
 
-    Defines a debug new operator.
+	Defines a debug new operator.
 
-    Be very carefull where you include this header.
-    Always include it after any standard headers (like STL), cause
-    overloading of the new operator causes STL to not compile.
+	Be very carefull where you include this header.
+	Always include it after any standard headers (like STL), cause
+	overloading of the new operator causes STL to not compile.
 
-    To kill the overloading write:
-        #undef new
-    To reenable it write:
-        #define new DEBUG_NEW
+	To kill the overloading write:
+		#undef new
+	To reenable it write:
+		#define new DEBUG_NEW
 */
 
 #pragma once

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -25,22 +25,26 @@
 
 class FileTypeRegistry {
 public:
-    typedef std::list< RCPtr<BObject> > object_list;
-    object_list _recognizers;
-    object_list _resolvers;
+	typedef std::list< RCPtr<BObject> > object_list;
+	object_list _recognizers;
+	object_list _resolvers;
 
-    void registerRecognizerPlugin(const ObjectPlugin* oplugin);
+	void registerRecognizerPlugin(const ObjectPlugin* oplugin);
 
-    void registerResolverPlugin(const ObjectPlugin* oplugin);
+	void registerResolverPlugin(const ObjectPlugin* oplugin);
 
-    //return properly sorted list of fileTypes
-    RecognizedFileTypes recognizeFileType(VirtualFile* file);
+	//return properly sorted list of fileTypes
+	RecognizedFileTypes recognizeFileType(VirtualFile* file);
 
-    guid_list resolveParsers(VirtualFile* file);
+	guid_list resolveParsers(VirtualFile* file);
 
-    ResolvedFileTypeParsers resolveParsers(const BGUID& fileType);
+	ResolvedFileTypeParsers resolveParsers(const BGUID& fileType);
 
-    static FileTypeRegistry* get();
+	static FileTypeRegistry* get();
+	static void release();
+private:
+	static FileTypeRegistry* _instance;
+	FileTypeRegistry() {}
 
 };
 

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/functionalex.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/functionalex.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/functionalex.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -18,7 +18,7 @@
 template<class _Result>
 struct nullary_function
 {	// base class for nullary functions
-    typedef _Result result_type;
+	typedef _Result result_type;
 };
 
 // TEMPLATE STRUCT trinary_function
@@ -28,10 +28,10 @@
 class _Result>
 struct trinary_function
 {	// base class for trinary functions
-    typedef _Arg1 first_argument_type;
-    typedef _Arg2 second_argument_type;
-    typedef _Arg3 third_argument_type;
-    typedef _Result result_type;
+	typedef _Arg1 first_argument_type;
+	typedef _Arg2 second_argument_type;
+	typedef _Arg3 third_argument_type;
+	typedef _Result result_type;
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -40,32 +40,32 @@
 
 // TEMPLATE CLASS cast1st_unary_t
 template<class NArg,
-         class _Fn1>
+		 class _Fn1>
 class cast1st_unary_t
-    : public std::unary_function<NArg, typename _Fn1::result_type>
+	: public std::unary_function<NArg, typename _Fn1::result_type>
 {	// functor adapter func((NArg)left)
 public:
-    typedef typename _Fn1::result_type _Result;
+	typedef typename _Fn1::result_type _Result;
 
-    explicit cast1st_unary_t(const _Fn1& _Left)
-        : _Pfun(_Left)
-    {	// construct from unary_function
-    }
+	explicit cast1st_unary_t(const _Fn1& _Left)
+		: _Pfun(_Left)
+	{	// construct from unary_function
+	}
 
-    _Result operator()(NArg _Left) const
-    {	// call function with operand
-        return (_Pfun(static_cast<typename _Fn1::argument_type>(_Left)));
-    }
+	_Result operator()(NArg _Left) const
+	{	// call function with operand
+		return (_Pfun(static_cast<typename _Fn1::argument_type>(_Left)));
+	}
 
 protected:
-    _Fn1 _Pfun;	// the function pointer
+	_Fn1 _Pfun;	// the function pointer
 };
 
 // TEMPLATE FUNCTION cast1st_unary
 template<class NArg, class _Fn1> inline
 cast1st_unary_t<NArg, _Fn1> cast1st_unary(const _Fn1& fn)
 {	// return a cast1st_unary_t functor adapter
-    return cast1st_unary_t<NArg, _Fn1>(fn);
+	return cast1st_unary_t<NArg, _Fn1>(fn);
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -74,34 +74,34 @@
 
 // TEMPLATE CLASS cast1st_unary_t
 template<class NArg,
-         class _Fn2>
+		 class _Fn2>
 class cast2nd_binary_t
-    : public std::binary_function<typename _Fn2::first_argument_type, NArg,
-                                  typename _Fn2::result_type>
+	: public std::binary_function<typename _Fn2::first_argument_type, NArg,
+								  typename _Fn2::result_type>
 {	// functor adapter func(left,(NArg)right)
 public:
-    typedef typename _Fn2::first_argument_type _Arg1;
-    typedef typename _Fn2::result_type _Result;
+	typedef typename _Fn2::first_argument_type _Arg1;
+	typedef typename _Fn2::result_type _Result;
 
-    explicit cast2nd_binary_t(const _Fn2& _Left)
-        : _Pfun(_Left)
-    {	// construct from unary_function
-    }
+	explicit cast2nd_binary_t(const _Fn2& _Left)
+		: _Pfun(_Left)
+	{	// construct from unary_function
+	}
 
-    _Result operator()(_Arg1 _Left, NArg _Right) const
-    {	// call function with operand
-        return (_Pfun(_Left, static_cast<typename _Fn2::second_argument_type>(_Right)));
-    }
+	_Result operator()(_Arg1 _Left, NArg _Right) const
+	{	// call function with operand
+		return (_Pfun(_Left, static_cast<typename _Fn2::second_argument_type>(_Right)));
+	}
 
 protected:
-    _Fn2 _Pfun;	// the function pointer
+	_Fn2 _Pfun;	// the function pointer
 };
 
 // TEMPLATE FUNCTION cast1st_unary
 template<class NArg, class _Fn2> inline
-    cast2nd_binary_t<NArg, _Fn2> cast2nd_binary(const _Fn2& fn)
+	cast2nd_binary_t<NArg, _Fn2> cast2nd_binary(const _Fn2& fn)
 {	// return a cast2nd_binary_t functor adapter
-    return cast2nd_binary_t<NArg, _Fn2>(fn);
+	return cast2nd_binary_t<NArg, _Fn2>(fn);
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -111,30 +111,30 @@
 // TEMPLATE CLASS cast_nullary_t
 template<class NResult, class _Fn>
 class cast_nullary_t
-    : public nullary_function<NResult>
+	: public nullary_function<NResult>
 {	// functor adapter (_Result)_Func()
 public:
-    typedef NResult result_type;
+	typedef NResult result_type;
 
-    cast_nullary_t(const _Fn& _Func)
-        : op(_Func)
-    {	// construct from functor
-    }
+	cast_nullary_t(const _Fn& _Func)
+		: op(_Func)
+	{	// construct from functor
+	}
 
-    result_type operator()() const
-    {	// apply functor to operands
-        return static_cast<NResult>( op() );
-    }
+	result_type operator()() const
+	{	// apply functor to operands
+		return static_cast<NResult>( op() );
+	}
 
 protected:
-    _Fn op;	// the functor to apply
+	_Fn op;	// the functor to apply
 };
 
 // TEMPLATE FUNCTION cast_nullary
 template<class _Result, class _Fn> inline
 cast_nullary_t<_Result, _Fn> cast_nullary(const _Fn& _Func)
 {	// return a cast_nullary_t functor adapter
-    return cast_nullary_t<_Result,_Fn>(_Func);
+	return cast_nullary_t<_Result,_Fn>(_Func);
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -143,33 +143,33 @@
 
 // TEMPLATE CLASS binary_unary2nd_t
 template<class Arg1,
-         class _Fn1>
+		 class _Fn1>
 class binary_unary2nd_t
-    : public std::binary_function<Arg1, typename _Fn1::argument_type, typename _Fn1::result_type>
+	: public std::binary_function<Arg1, typename _Fn1::argument_type, typename _Fn1::result_type>
 {	// functor adapter func2(_,v) = func(v)
 public:
-    typedef typename _Fn1::argument_type _Arg2;
-    typedef typename _Fn1::result_type _Result;
+	typedef typename _Fn1::argument_type _Arg2;
+	typedef typename _Fn1::result_type _Result;
 
-    explicit binary_unary2nd_t(const _Fn1& _fn)
-        : fn(_fn)
-    {	// construct from pointer
-    }
+	explicit binary_unary2nd_t(const _Fn1& _fn)
+		: fn(_fn)
+	{	// construct from pointer
+	}
 
-    _Result operator()(Arg1 _Left, _Arg2 _Right) const
-    {	// call function with operand
-        return fn(_Right);
-    }
+	_Result operator()(Arg1 _Left, _Arg2 _Right) const
+	{	// call function with operand
+		return fn(_Right);
+	}
 
 private:
-    _Fn1 fn;	// the member function pointer
+	_Fn1 fn;	// the member function pointer
 };
 
 // TEMPLATE FUNCTION binary_unary2nd_t
 template<class Arg1, class _Fn1> inline
 binary_unary2nd_t<Arg1, _Fn1> binary_unary2nd(const _Fn1& _Func)
 {	// return a binary_unary2nd_t functor adapter
-    return binary_unary2nd_t<Arg1,_Fn1>(_Func);
+	return binary_unary2nd_t<Arg1,_Fn1>(_Func);
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -179,35 +179,35 @@
 // TEMPLATE CLASS unary_binder
 template<class _Fn1>
 class unary_binder
-    : public nullary_function<typename _Fn1::result_type>
+	: public nullary_function<typename _Fn1::result_type>
 {	// functor adapter _Func(stored)
 public:
-    typedef std::unary_function<typename _Fn1::argument_type,
-        typename _Fn1::result_type> _Base;
-    typedef typename _Base::result_type result_type;
+	typedef std::unary_function<typename _Fn1::argument_type,
+		typename _Fn1::result_type> _Base;
+	typedef typename _Base::result_type result_type;
 
-    unary_binder(const _Fn1& _Func,
-        const typename _Fn1::argument_type& _Left)
-        : op(_Func), value(_Left)
-    {	// construct from functor and left operand
-    }
+	unary_binder(const _Fn1& _Func,
+		const typename _Fn1::argument_type& _Left)
+		: op(_Func), value(_Left)
+	{	// construct from functor and left operand
+	}
 
-    result_type operator()() const
-    {	// apply functor to operands
-        return (op(value));
-    }
+	result_type operator()() const
+	{	// apply functor to operands
+		return (op(value));
+	}
 
 protected:
-    _Fn1 op;	// the functor to apply
-    typename _Fn1::argument_type value;	// the left operand
+	_Fn1 op;	// the functor to apply
+	typename _Fn1::argument_type value;	// the left operand
 };
 
 // TEMPLATE FUNCTION bind_unary
 template<class _Fn1, class _Ty> inline
-    unary_binder<_Fn1> bind_unary(const _Fn1& _Func, const _Ty& _Left)
+	unary_binder<_Fn1> bind_unary(const _Fn1& _Func, const _Ty& _Left)
 {	// return a unary_binder functor adapter
-    typename _Fn1::argument_type _Val(_Left);
-    return (unary_binder<_Fn1>(_Func, _Val));
+	typename _Fn1::argument_type _Val(_Left);
+	return (unary_binder<_Fn1>(_Func, _Val));
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -217,45 +217,45 @@
 // TEMPLATE CLASS trinary_binder
 template<class _Fn3>
 class trinary_binder
-    : public binary_function<typename _Fn3::first_argument_type,
-                             typename _Fn3::second_argument_type,
-                             typename _Fn3::result_type>
+	: public binary_function<typename _Fn3::first_argument_type,
+							 typename _Fn3::second_argument_type,
+							 typename _Fn3::result_type>
 {	// functor adapter _Func(left, stored)
 public:
-    typedef binary_function<typename _Fn3::first_argument_type,
-                            typename _Fn3::second_argument_type,
-                            typename _Fn3::result_type> _Base;
-    typedef typename _Base::first_argument_type first_argument_type;
-    typedef typename _Base::second_argument_type second_argument_type;
-    typedef typename _Base::result_type result_type;
+	typedef binary_function<typename _Fn3::first_argument_type,
+							typename _Fn3::second_argument_type,
+							typename _Fn3::result_type> _Base;
+	typedef typename _Base::first_argument_type first_argument_type;
+	typedef typename _Base::second_argument_type second_argument_type;
+	typedef typename _Base::result_type result_type;
 
-    trinary_binder(const _Fn3& _Func,
-        const typename _Fn3::third_argument_type& _Right)
-        : op(_Func), value(_Right)
-    {	// construct from functor and right operand
-    }
+	trinary_binder(const _Fn3& _Func,
+		const typename _Fn3::third_argument_type& _Right)
+		: op(_Func), value(_Right)
+	{	// construct from functor and right operand
+	}
 
-    result_type operator()(const first_argument_type& _Left, const second_argument_type& _Middle) const
-    {	// apply functor to operands
-        return (op(_Left, _Middle, value));
-    }
+	result_type operator()(const first_argument_type& _Left, const second_argument_type& _Middle) const
+	{	// apply functor to operands
+		return (op(_Left, _Middle, value));
+	}
 
-    result_type operator()(first_argument_type& _Left, second_argument_type& _Middle) const
-    {	// apply functor to operands
-        return (op(_Left, _Middle, value));
-    }
+	result_type operator()(first_argument_type& _Left, second_argument_type& _Middle) const
+	{	// apply functor to operands
+		return (op(_Left, _Middle, value));
+	}
 
 protected:
-    _Fn3 op;	// the functor to apply
-    typename _Fn3::third_argument_type value;	// the right operand
+	_Fn3 op;	// the functor to apply
+	typename _Fn3::third_argument_type value;	// the right operand
 };
 
 // TEMPLATE FUNCTION bind3rd
 template<class _Fn3, class _Ty> inline
-    trinary_binder<_Fn3> bind3rd(const _Fn3& _Func, const _Ty& _Right)
+	trinary_binder<_Fn3> bind3rd(const _Fn3& _Func, const _Ty& _Right)
 {	// return a binder2nd functor adapter
-    typename _Fn3::third_argument_type _Val(_Right);
-    return (trinary_binder<_Fn2>(_Func, _Val));
+	typename _Fn3::third_argument_type _Val(_Right);
+	return (trinary_binder<_Fn2>(_Func, _Val));
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -264,26 +264,26 @@
 
 // TEMPLATE CLASS pointer_to_trinary_function
 template<class _Arg1,
-         class _Arg2,
-         class _Arg3,
-         class _Result,
-         class _Fn = _Result (*)(_Arg1, _Arg2, _Arg3)>
+		 class _Arg2,
+		 class _Arg3,
+		 class _Result,
+		 class _Fn = _Result (*)(_Arg1, _Arg2, _Arg3)>
 class pointer_to_trinary_function
-    : public trinary_function<_Arg1, _Arg2, _Arg3, _Result>
+	: public trinary_function<_Arg1, _Arg2, _Arg3, _Result>
 {	// functor adapter (*pfunc)(left, middle, right)
 public:
-    explicit pointer_to_trinary_function(_Fn _Left)
-        : _Pfun(_Left)
-    {	// construct from pointer
-    }
+	explicit pointer_to_trinary_function(_Fn _Left)
+		: _Pfun(_Left)
+	{	// construct from pointer
+	}
 
-    _Result operator()(_Arg1 _Left, _Arg2 _Middle, _Arg3 _Right) const
-    {	// call function with operands
-        return (_Pfun(_Left, _Middle, _Right));
-    }
+	_Result operator()(_Arg1 _Left, _Arg2 _Middle, _Arg3 _Right) const
+	{	// call function with operands
+		return (_Pfun(_Left, _Middle, _Right));
+	}
 
 protected:
-    _Fn _Pfun;	// the function pointer
+	_Fn _Pfun;	// the function pointer
 };
 */
 /////////////////////////////////////////////////////////////////////////////

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp	2007-07-04 01:34:12 UTC (rev 27891)
@@ -21,50 +21,50 @@
 /////////////////////////////////////////////////////////////////////////////
 
 /*static*/ const BGUID& BGUID::Unknown() {
-    static BGUID unknown("Unknown Facility", "Unknown GUID", 1);
-    return unknown;
+	static BGUID unknown("Unknown Facility", "Unknown GUID", 1);
+	return unknown;
 }
 
 BGUID::BGUID(std::string _facility, std::string _identifier, int _version)
-    : facility(_facility), identifier(_identifier), version(_version) {}
+	: facility(_facility), identifier(_identifier), version(_version) {}
 
 bool BGUID::operator==(const BGUID& other) const {
-    return facility == other.facility &&
-        identifier == other.identifier &&
-        version == other.version;
+	return facility == other.facility &&
+		identifier == other.identifier &&
+		version == other.version;
 }
 
 bool BGUID::operator!=(const BGUID& other) const {
-    return !(*this == other);
+	return !(*this == other);
 }
 
 bool BGUID::operator<(const BGUID& other) const {
-    if(facility < other.facility) return true;
-    if(facility > other.facility) return false;
-    if(identifier < other.identifier) return true;
-    if(identifier > other.identifier) return false;
-    return version < other.version;
+	if(facility < other.facility) return true;
+	if(facility > other.facility) return false;
+	if(identifier < other.identifier) return true;
+	if(identifier > other.identifier) return false;
+	return version < other.version;
 }
 
 bool BGUID::operator>(const BGUID& other) const {
-    if(facility > other.facility) return true;
-    if(facility < other.facility) return false;
-    if(identifier > other.identifier) return true;
-    if(identifier < other.identifier) return false;
-    return version > other.version;
+	if(facility > other.facility) return true;
+	if(facility < other.facility) return false;
+	if(identifier > other.identifier) return true;
+	if(identifier < other.identifier) return false;
+	return version > other.version;
 }
 
 /*
 This thing doesn't have sense.
 explicit BGUID::BGUID(const BGUID& other) {   //no implicit copy
-    this->facility = other.facility;
-    this->identifier = other.identifier;
-    this->version = other.version;
+	this->facility = other.facility;
+	this->identifier = other.identifier;
+	this->version = other.version;
 }*/
 
 std::ostream& operator<<(std::ostream& os, const BGUID& guid) {
-    return os << "BGUID(" << guid.facility << ", " << guid.identifier << ", "
-        << guid.version << ")";
+	return os << "BGUID(" << guid.facility << ", " << guid.identifier << ", "
+		<< guid.version << ")";
 }
 
 /////////////////////////////////////////////////////////////////////////////

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -24,20 +24,20 @@
 /////////////////////////////////////////////////////////////////////////////
 
 struct BGUID {
-    static const BGUID& Unknown();
+	static const BGUID& Unknown();
 
-    std::string facility;
-    std::string identifier;
-    int version;
-    BGUID(std::string _facility, std::string _identifier, int _version);
+	std::string facility;
+	std::string identifier;
+	int version;
+	BGUID(std::string _facility, std::string _identifier, int _version);
 
-    bool operator==(const BGUID& other) const;
-    bool operator!=(const BGUID& other) const;
-    bool operator<(const BGUID& other) const;
-    bool operator>(const BGUID& other) const;
+	bool operator==(const BGUID& other) const;
+	bool operator!=(const BGUID& other) const;
+	bool operator<(const BGUID& other) const;
+	bool operator>(const BGUID& other) const;
 
 //private:
-    //BGUID& operator=(const BGUID& other); //don't assign
+	//BGUID& operator=(const BGUID& other); //don't assign
 };
 
 std::ostream& operator<<(std::ostream& os, const BGUID& guid);
@@ -47,20 +47,20 @@
 
 class GUIDObject {
 public:
-    virtual const BGUID& get_GUID() = 0;
+	virtual const BGUID& get_GUID() = 0;
 };
 
 #define ASSIGN_GUID_VERBOSE(name, facility, version) \
-    virtual const BGUID& get_GUID() { \
-        return /*clazz::*/static_GUID(); \
-    } \
-    static const BGUID& static_GUID() { \
-        static BGUID guid(facility, name, version); \
-        return guid; \
-    }
+	virtual const BGUID& get_GUID() { \
+		return /*clazz::*/static_GUID(); \
+	} \
+	static const BGUID& static_GUID() { \
+		static BGUID guid(facility, name, version); \
+		return guid; \
+	}
 
 #define GUID_FOR(clazz, facility, version) \
-    ASSIGN_GUID_VERBOSE(#clazz, facility, version)
+	ASSIGN_GUID_VERBOSE(#clazz, facility, version)
 
 //#define ASSIGN_GUID(facility, version) \
 //    ASSIGN_GUID_VERBOSE(typeid(this_class).name(), facility, version)

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.cpp	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.cpp	2007-07-04 01:34:12 UTC (rev 27891)
@@ -25,209 +25,259 @@
 //Connecting Pins and Slots does not change ref counts.
 //ObjectChain holds BObjects and connections between them.
 
-    
+	
 //returns true if the insertion was made
 //returns false if the object was already there
 bool ObjectChain::addObject(const RCPtr<BObject>& obj) {
-    std::pair<object_set::iterator, bool> res =
-        objects.insert(obj);
-    if(!res.second) //the object was already there
-        return false;
-    return true;
+	std::pair<object_set::iterator, bool> res =
+		objects.insert(obj);
+	if(!res.second) //the object was already there
+		return false;
+	return true;
 }
 
 bool ObjectChain::isContained(const RCPtr<BObject>& obj) {
-    return objects.count(obj) == 1;
+	return objects.count(obj) == 1;
 }
 
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 //returns true if connected
 //false in case of error or if already was connected
 bool ObjectChain::connect(const RCPtr<BObject>& obj0,
-                          const RCPtr<BObject>& obj1,
-                          const BGUID& interfaceGUID) {
-    ASSERT( objects.count(obj0) == 1 ); // must be our object
-    ASSERT( objects.count(obj1) == 1 ); // must be our object
+						  const RCPtr<BObject>& obj1,
+						  const BGUID& interfaceGUID) {
+	ASSERT( objects.count(obj0) == 1 ); // must be our object
+	ASSERT( objects.count(obj1) == 1 ); // must be our object
 
-    PinType* pin = obj0->get_pin(interfaceGUID);
-    SlotType* slot = obj1->get_slot(interfaceGUID);
-    if(!pin || !slot)
-        return false;
+	PinType* pin = obj0->get_pin(interfaceGUID);
+	SlotType* slot = obj1->get_slot(interfaceGUID);
+	if(!pin || !slot)
+		return false;
 
-    if(slot->isConnected())
-        return false;
-    //the slot is not conected *anywhere*, so it's not in our maps either
+	if(slot->isConnected())
+		return false;
+	//the slot is conected *somewhere*, so we can't connect it here
 
-    bool cycles = check_for_cycles(obj0,obj1);
-    if(cycles)
-        return false;
+	bool cycles = check_for_cycles(obj0,obj1);
+	if(cycles)
+		return false;
 
-    slot2pin.insert( slot2pin_pair(slot, pin) );
-    pin2slot.insert( pin2slot_pair(pin, slot) );
-    pin2that.insert( pin2that_pair(pin, obj0.get()) );
-    slot->connect(pin);
-    
-    return true;
+	slot2pin.insert( slot2pin_pair(slot, pin) );
+	pin2slot.insert( pin2slot_pair(pin, slot) );
+	pin2that.insert( pin2that_pair(pin, obj0.get()) );
+	slot->connect(pin);
+	
+	return true;
 }
 
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 bool ObjectChain::isConnected(const RCPtr<BObject>& obj0,
-                              const RCPtr<BObject>& obj1,
-                              const BGUID& interfaceGUID) {
-    ASSERT( objects.count(obj0) == 1 ); // must be our object
-    ASSERT( objects.count(obj1) == 1 ); // must be our object
+							  const RCPtr<BObject>& obj1,
+							  const BGUID& interfaceGUID) {
+	ASSERT( objects.count(obj0) == 1 ); // must be our object
+	ASSERT( objects.count(obj1) == 1 ); // must be our object
 
-    PinType* pin = obj0->get_pin(interfaceGUID);
-    SlotType* slot = obj1->get_slot(interfaceGUID);
-    if(!pin || !slot)
-        return false;
+	PinType* pin = obj0->get_pin(interfaceGUID);
+	SlotType* slot = obj1->get_slot(interfaceGUID);
+	if(!pin || !slot)
+		return false;
 
-    if(slot->isConnected())
-        return false;
-    //the slot is not conected *anywhere*, so it's not in our maps either
+	if(!slot->isConnected())
+		return false;
+	//the slot is not conected *anywhere*, so it's not in our maps either
 
-    slot2pin_map::iterator i = slot2pin.find(slot);
-    if(i == slot2pin.end())
-        return false;
+	slot2pin_map::iterator i = slot2pin.find(slot);
+	if(i == slot2pin.end())
+		return false;
 
-    if(i->second != pin)
-        return false;
+	if(i->second != pin)
+		return false;
 
-    //ASSERT(slot->getPin() == pin);
+	//ASSERT(slot->getPin() == pin);
 
-    return true;
+	return true;
 }
 
+bool ObjectChain::isConnectedSlot(SlotType* slot) {
+	if(!slot)
+		return false;
+
+	//if(!slot->isConnected())
+	//	return false;
+	//the slot is not conected *anywhere*, so it's not in our maps either
+
+	slot2pin_map::iterator i = slot2pin.find(slot);
+	if(i == slot2pin.end())
+		return false;
+
+	return true;
+}
+
+bool ObjectChain::isConnectedPin(PinType* pin) {
+	if(!pin)
+		return false;
+
+	pin2slot_map::iterator i = pin2slot.find(pin);
+	if(i == pin2slot.end())
+		return false;
+
+	return true;
+}
+
+bool ObjectChain::isConnectedSlot(const RCPtr<BObject>& obj,
+								  const BGUID& interfaceGUID) {
+	ASSERT( objects.count(obj) == 1 ); // must be our object
+	return isConnectedSlot( obj->get_slot(interfaceGUID) );
+}
+
+bool ObjectChain::isConnectedPin(const RCPtr<BObject>& obj,
+								 const BGUID& interfaceGUID) {
+	ASSERT( objects.count(obj) == 1 ); // must be our object
+	return isConnectedPin( obj->get_pin(interfaceGUID) );
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 //returns true if it has been disconnected
 //returns false in case of error or if already was not connected
 bool ObjectChain::disconnect(const RCPtr<BObject>& obj0,
-                             const RCPtr<BObject>& obj1,
-                             const BGUID& interfaceGUID) {
-    PinType* pin = obj0->get_pin(interfaceGUID);
-    SlotType* slot = obj1->get_slot(interfaceGUID);
-    return _disconnect(pin, slot);
+							 const RCPtr<BObject>& obj1,
+							 const BGUID& interfaceGUID) {
+	PinType* pin = obj0->get_pin(interfaceGUID);
+	SlotType* slot = obj1->get_slot(interfaceGUID);
+	return _disconnect(pin, slot);
 }
 
 //returns true if it has been disconnected
 //returns false on error or if already was not connected
 bool ObjectChain::disconnect_slot(const RCPtr<BObject>& obj,
-                                  const BGUID& interfaceGUID) {
-    SlotType* slot = obj->get_slot(interfaceGUID);
-    return disconnect_slot(slot);
+								  const BGUID& interfaceGUID) {
+	SlotType* slot = obj->get_slot(interfaceGUID);
+	return disconnect_slot(slot);
 }
 
 //returns true if it has been disconnected
 //returns false on error or if already was not connected
 bool ObjectChain::disconnect_slot(SlotType* slot) {
-    PinType* pin = _match_pin(slot);
+	PinType* pin = _match_pin(slot);
 
-    return _disconnect(pin, slot);
+	return _disconnect(pin, slot);
 }
 
 //returns true if all the slots has been succesfully disconnected
 //returns false on error
 bool ObjectChain::disconnect_pin(const RCPtr<BObject>& obj,
-                                 const BGUID& interfaceGUID) {
-    PinType* pin = obj->get_pin(interfaceGUID);
-    return disconnect_pin(pin);
+								 const BGUID& interfaceGUID) {
+	PinType* pin = obj->get_pin(interfaceGUID);
+	return disconnect_pin(pin);
 }
 
 //returns true if all the slots has been succesfully disconnected
 //returns false on error
 bool ObjectChain::disconnect_pin(PinType* pin) {
-    if(!pin)
-        return false;
-    bool res = true;
-    pin2slot_map::iterator i;
-    i = pin2slot.find(pin);
+	if(!pin)
+		return false;
+	bool res = true;
+	pin2slot_map::iterator i;
+	i = pin2slot.find(pin);
 
-    std::vector<SlotType*> slots; //cache slots, cause _disconnect messes with pin2slot 
-    for(; i != pin2slot.end() && i->first == pin; ++i)
-        slots.push_back( i->second );
+	std::vector<SlotType*> slots; //cache slots, cause _disconnect messes with pin2slot 
+	for(; i != pin2slot.end() && i->first == pin; ++i)
+		slots.push_back( i->second );
 
-    std::vector<SlotType*>::iterator j;
-    for(j = slots.begin(); j != slots.end(); ++j)
-        res &= _disconnect(pin, *j);
+	std::vector<SlotType*>::iterator j;
+	for(j = slots.begin(); j != slots.end(); ++j)
+		res &= _disconnect(pin, *j);
 
-    return res;
+	return res;
 }
 
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 void ObjectChain::disconnectObject(const RCPtr<BObject>& obj) {
-    ASSERT( objects.count(obj) == 1 ); // must be our object
+	ASSERT( objects.count(obj) == 1 ); // must be our object
 
-    bool res = true;
+	bool res = true;
 
-    //iterate over pins and slots and disconnect them:
-    //(careful not to disconnect pins/slots that are connected in some other
-    //ObjectChain)
-    PinSlotDescs::const_iterator i;
-    const PinSlotDescs& pins = obj->get_pins();
-    for (i = pins.begin(); i != pins.end(); ++i)
-    {
-        PinSlotDesc* desc = i->second;
-        PinType* pin = desc->get_pin(obj.get());
-        res &= disconnect_pin(pin);
-    }
+	//iterate over pins and slots and disconnect them:
+	//(careful not to disconnect pins/slots that are connected in some other
+	//ObjectChain)
+	PinSlotDescs::const_iterator i;
+	const PinSlotDescs& pins = obj->get_pins();
+	for (i = pins.begin(); i != pins.end(); ++i)
+	{
+		PinSlotDesc* desc = i->second;
+		PinType* pin = desc->get_pin(obj.get());
+		res &= disconnect_pin(pin);
+	}
 
-    const PinSlotDescs& slots = obj->get_slots();
-    for (i = slots.begin(); i != slots.end(); ++i)
-    {
-        PinSlotDesc* desc = i->second;
-        SlotType* slot = desc->get_slot(obj.get());
-        res &= disconnect_slot(slot);
-    }
+	const PinSlotDescs& slots = obj->get_slots();
+	for (i = slots.begin(); i != slots.end(); ++i)
+	{
+		PinSlotDesc* desc = i->second;
+		SlotType* slot = desc->get_slot(obj.get());
+		res &= disconnect_slot(slot);
+	}
 
-    //return res; - nonsense - it will say false if *any* of the pins/slots was not connected
+	//return res; - nonsense - it will say false if *any* of the pins/slots was not connected
 }
 
 void ObjectChain::removeObject(const RCPtr<BObject>& obj) {
-    ASSERT( objects.count(obj) == 1 ); // must be our object
-    obj->unrealize(this);
-    disconnectObject(obj);
-    objects.erase(obj); //the ref count just went down
+	ASSERT( objects.count(obj) == 1 ); // must be our object
+	obj->unrealize(this);
+	disconnectObject(obj);
+	objects.erase(obj); //the ref count just went down
 }
 
 bool ObjectChain::realize() {
-    ordered_objs objs;
-    order_back_to_front(objs);
-    ordered_objs::const_reverse_iterator i;
+	ordered_objs objs;
+	order_back_to_front(objs);
+	ordered_objs::const_reverse_iterator i;
 
-    bool res = true;
-    for (i = objs.rbegin(); i != objs.rend(); ++i) {
-        res &= (*i)->realize(this);
-    }
+	bool res = true;
+	for (i = objs.rbegin(); i != objs.rend(); ++i) {
+		res &= (*i)->realize(this);
+	}
 
-    if(!res)
-        unrealize();
+	if(!res)
+		unrealize();
 
-    return res;
+	return res;
 }
 
 void ObjectChain::unrealize() {
-    ordered_objs objs;
-    order_back_to_front(objs);
-    ordered_objs::const_iterator i;
-    for (i = objs.begin(); i != objs.end(); ++i) {
-        (*i)->unrealize(this);
-    }
+	ordered_objs objs;
+	order_back_to_front(objs);
+	ordered_objs::const_iterator i;
+	for (i = objs.begin(); i != objs.end(); ++i) {
+		(*i)->unrealize(this);
+	}
 }
 
 void ObjectChain::disconnectAll() {
-    object_set::const_iterator i;
-    for (i = objects.begin(); i != objects.end(); ++i) {
-        disconnectObject(*i);
-    }
+	object_set::const_iterator i;
+	for (i = objects.begin(); i != objects.end(); ++i) {
+		disconnectObject(*i);
+	}
 }
 
 void ObjectChain::removeAllObjects() {
-    ordered_objs objs;
-    order_back_to_front(objs);
-    ordered_objs::const_iterator i;
-    for (i = objs.begin(); i != objs.end(); ++i) {
-        removeObject(*i);
-    }
+	ordered_objs objs;
+	order_back_to_front(objs);
+	ordered_objs::const_iterator i;
+	for (i = objs.begin(); i != objs.end(); ++i) {
+		removeObject(*i);
+	}
 }
 
 ObjectChain::~ObjectChain() {
-    removeAllObjects();
+	removeAllObjects();
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -235,106 +285,134 @@
 
 PinSlotDesc* ObjectChain::_get_not_connected(BObject* obj, bool ifPin) {
 
-    PinSlotDescs::const_iterator i;
-    const PinSlotDescs& descs = ifPin ? obj->get_pins() : obj->get_slots();
-    for (i = descs.begin(); i != descs.end(); ++i)
-    {
-        PinSlotDesc* desc = i->second;
-        if (ifPin && (desc->flags & PIN_DEFAULT) ) {
-            pin2slot_map::iterator i;
-            PinType* pin = desc->get_pin(obj);
-            i = pin2slot.find(pin);
-            if (i == pin2slot.end())
-                return desc;            //not connected default pin
-        }
+	PinSlotDescs::const_iterator i;
+	const PinSlotDescs& descs = ifPin ? obj->get_pins() : obj->get_slots();
+	for (i = descs.begin(); i != descs.end(); ++i)
+	{
+		PinSlotDesc* desc = i->second;
+		if (ifPin && (desc->flags & PIN_DEFAULT) ) {
+			pin2slot_map::iterator i;
+			PinType* pin = desc->get_pin(obj);
+			i = pin2slot.find(pin);
+			if (i == pin2slot.end())
+				return desc;            //not connected default pin
+		}
 
-        if (!ifPin && (desc->flags & SLOT_DEFAULT) ) {
-            pin2slot_map::iterator i;
-            SlotType* slot = desc->get_slot(obj);
-            PinType* pin = _match_pin(slot);
-            if (pin == NULL)
-                return desc;            //not connected default slot
-        }
-    }
+		if (!ifPin && (desc->flags & SLOT_DEFAULT) ) {
+			pin2slot_map::iterator i;
+			SlotType* slot = desc->get_slot(obj);
+			PinType* pin = _match_pin(slot);
+			if (pin == NULL)
+				return desc;            //not connected default slot
+		}
+	}
 
-    return NULL;
+	return NULL;
 }
 
 //FIXME: implement whole completion logic
 void ObjectChain::complete() {
-    PinSlotDesc* desc;
-    ordered_objs objs;
-    ordered_objs::const_reverse_iterator i;
+	PinSlotDesc* desc;
+	ordered_objs objs;
+	ordered_objs::const_reverse_iterator i;
 
-    std::cout << "--- ObjectChain::complete() ---" << std::endl;
-    std::cout << "--- PINS ---" << std::endl;
+	std::cout << "--- ObjectChain::complete() ---" << std::endl;
+	std::cout << "--- PINS ---" << std::endl;
 
-    //connecting pins with new objects
+	//connecting pins with new objects
 next_pin:
-    order_back_to_front(objs);
-    for (i = objs.rbegin(); i != objs.rend(); ++i) {
-        desc = _get_not_connected(*i, true);
+	order_back_to_front(objs);
+	for (i = objs.rbegin(); i != objs.rend(); ++i) {
+		BObject* obj0 = *i;
+		desc = _get_not_connected(obj0, true);
 
-        if (!desc)
-            continue; //every pin is connected
+		if (!desc)
+			continue; //every pin is connected
 
-        RCPtr<BObject> obj = ObjectRegistry::get()->getObjectWithSlot(desc->interfaceGUID);
-        if (obj.get() == NULL)
-            continue; //no object with desired slot
+		//try to find existing object
+		ordered_objs::const_reverse_iterator j;
+		for (j = objs.rbegin(); j != objs.rend(); ++j) {
+			BObject* obj1 = *j;
+			if (obj1 == obj0)
+				continue;
 
-        this->addObject(obj);
-        bool res = connect(RCPtr<BObject>(*i), obj, desc->interfaceGUID);
-        if (res) {
-            std::cout << "    CONNECTED: " << (*i)->get_GUID().identifier
-                      << " --> " << desc->interfaceGUID.identifier
-                      << " --> " << obj->get_GUID().identifier << std::endl;
-            goto next_pin; //connected
-        } else {
-            std::cout << "    CYCLE?: " << (*i)->get_GUID().identifier
-                << " --> " << desc->interfaceGUID.identifier
-                << " --> " << obj->get_GUID().identifier << std::endl;
-        }
+			SlotType* slot = obj1->get_slot(desc->interfaceGUID);
+			if (!slot || slot->isConnected())
+				continue; //no apropriate slot
 
-        this->removeObject(obj);
-    }
+			bool res = connect(RCPtr<BObject>(obj0),RCPtr<BObject>(obj1),desc->interfaceGUID);
+			if (res) {
+				std::cout << "    CONNECTED: " << obj1->get_GUID().identifier
+					<< " --> " << desc->interfaceGUID.identifier
+					<< " --> " << obj0->get_GUID().identifier << std::endl;
+				goto next_pin; //connected
+			} else {
+				std::cout << "    CYCLE?: " << obj1->get_GUID().identifier
+					<< " --> " << desc->interfaceGUID.identifier
+					<< " --> " << obj0->get_GUID().identifier << std::endl;
+			}
+		}
 
-    std::cout << "--- SLOTS ---" << std::endl;
+		//no existing object fits...
+		//...try to create one
+		RCPtr<BObject> obj = ObjectRegistry::get()->getObjectWithSlot(desc->interfaceGUID);
+		if (obj.get() == NULL)
+			continue; //no object with desired slot
 
-    //connecting slots with existing objects
+		this->addObject(obj);
+		bool res = connect(RCPtr<BObject>(obj0), obj, desc->interfaceGUID);
+		if (res) {
+			std::cout << "    CONNECTED: " << obj0->get_GUID().identifier
+					  << " --> " << desc->interfaceGUID.identifier
+					  << " --> " << obj->get_GUID().identifier << std::endl;
+			goto next_pin; //connected
+		} else {
+			std::cout << "    CYCLE?: " << obj0->get_GUID().identifier
+				<< " --> " << desc->interfaceGUID.identifier
+				<< " --> " << obj->get_GUID().identifier << std::endl;
+		}
+
+		this->removeObject(obj);
+	}
+
+	std::cout << "--- SLOTS ---" << std::endl;
+
+	//connecting slots with existing objects
 next_slot:
-    order_back_to_front(objs);
-    for (i = objs.rbegin(); i != objs.rend(); ++i) {
-        BObject* obj0 = *i;
-        desc = _get_not_connected(obj0, false);
+	order_back_to_front(objs);
+	for (i = objs.rbegin(); i != objs.rend(); ++i) {
+		BObject* obj0 = *i;
+		desc = _get_not_connected(obj0, false);
 
-        if (!desc)
-            continue; //every slot is connected
+		if (!desc)
+			continue; //every slot is connected
 
-        ordered_objs::const_reverse_iterator j;
-        for (j = objs.rbegin(); j != objs.rend(); ++j) {
-            BObject* obj1 = *j;
-            if(obj1 == obj0)
-                continue;
+		//try to find existing object
+		ordered_objs::const_reverse_iterator j;
+		for (j = objs.rbegin(); j != objs.rend(); ++j) {
+			BObject* obj1 = *j;
+			if (obj1 == obj0)
+				continue;
 
-            PinType* pin = obj1->get_pin(desc->interfaceGUID);
-            if (!pin)
-                continue; //no apropraiate pin
+			PinType* pin = obj1->get_pin(desc->interfaceGUID);
+			if (!pin)
+				continue; //no apropriate pin
 
-            bool res = connect(RCPtr<BObject>(obj1),RCPtr<BObject>(obj0),desc->interfaceGUID);
-            if (res) {
-                std::cout << "    CONNECTED: " << obj1->get_GUID().identifier
-                    << " --> " << desc->interfaceGUID.identifier
-                    << " --> " << obj0->get_GUID().identifier << std::endl;
-                goto next_slot; //connected
-            } else {
-                std::cout << "    CYCLE?: " << obj1->get_GUID().identifier
-                    << " --> " << desc->interfaceGUID.identifier
-                    << " --> " << obj0->get_GUID().identifier << std::endl;
-            }
-        }
-    }
+			bool res = connect(RCPtr<BObject>(obj1),RCPtr<BObject>(obj0),desc->interfaceGUID);
+			if (res) {
+				std::cout << "    CONNECTED: " << obj1->get_GUID().identifier
+					<< " --> " << desc->interfaceGUID.identifier
+					<< " --> " << obj0->get_GUID().identifier << std::endl;
+				goto next_slot; //connected
+			} else {
+				std::cout << "    CYCLE?: " << obj1->get_GUID().identifier
+					<< " --> " << desc->interfaceGUID.identifier
+					<< " --> " << obj0->get_GUID().identifier << std::endl;
+			}
+		}
+	}
 
-    std::cout << "--- DONE ---" << std::endl;
+	std::cout << "--- DONE ---" << std::endl;
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -345,184 +423,187 @@
 
 //functor for expanding the node in bfs traversal of the DAG
 struct ocExpand {
-    ObjectChain* _that;
-    ocExpand(ObjectChain* that) : _that(that) {}
-    void operator()(BObject* obj, int level, bfsFringe& fringe) {
-        //this implementation is stupid and allow duplicates to end up in
-        //the fringe - there won't be infinite recursion though
+	ObjectChain* _that;
+	ocExpand(ObjectChain* that) : _that(that) {}
+	void operator()(BObject* obj, int level, bfsFringe& fringe) {
+		//this implementation is stupid and allow duplicates to end up in
+		//the fringe - there won't be infinite recursion though
 
-        const PinSlotDescs& slots = obj->get_slots();
-        PinSlotDescs::const_iterator i;
-        for (i = slots.begin(); i != slots.end(); ++i) {
-            PinSlotDesc* desc = i->second;
-            SlotType* slot = desc->get_slot(obj);
-            PinType* pin = _that->_match_pin(slot);
-            if(!pin)
-                continue;
-            BObject* other = _that->_match_that(pin);
-            ASSERT(other);
-            fringe.push(other, level+1);
-        }
-    }
+		const PinSlotDescs& slots = obj->get_slots();
+		PinSlotDescs::const_iterator i;
+		for (i = slots.begin(); i != slots.end(); ++i) {
+			PinSlotDesc* desc = i->second;
+			SlotType* slot = desc->get_slot(obj);
+			PinType* pin = _that->_match_pin(slot);
+			if(!pin)
+				continue;
+			BObject* other = _that->_match_that(pin);
+			ASSERT(other);
+			fringe.push(other, level+1);
+		}
+	}
 };
 
 //have to be on top-level, cause GCC complained when they were contained in a Util class
 typedef std::pair<BObject*, int> ocVisitRanks_the_pair;
 bool ocVisitRanks_compare(const ocVisitRanks_the_pair& p0, const ocVisitRanks_the_pair& p1) {
-    return p0.second < p1.second;
+	return p0.second < p1.second;
 }
 BObject* ocVisitRanks_transform(const ocVisitRanks_the_pair& p) {
-    return p.first;
+	return p.first;
 }
 
 //functor for computing ranks of the nodes in the DAG
 struct ocVisitRanks {
-    typedef std::map<BObject*, int> rank_map;
-    rank_map _ranks;
+	typedef std::map<BObject*, int> rank_map;
+	rank_map _ranks;
 
-    ObjectChain* _that;
+	ObjectChain* _that;
 
-    ocVisitRanks(ObjectChain* that) : _that(that) {
-        ObjectChain::object_set::const_iterator i;
-        for (i = _that->objects.begin(); i != _that->objects.end(); ++i)
-            _ranks.insert( std::make_pair(i->get(), 0) );
-    }
+	ocVisitRanks(ObjectChain* that) : _that(that) {
+		ObjectChain::object_set::const_iterator i;
+		for (i = _that->objects.begin(); i != _that->objects.end(); ++i)
+			_ranks.insert( std::make_pair(i->get(), 0) );
+	}
 
-    int operator()(BObject* obj, int level) {
-        rank_map::iterator i;
-        i = _ranks.find(obj);
-        ASSERT( i != _ranks.end() );
-        int rank = i->second;
-        if(rank > level)
-            return tree_algos::SKIP;
-        i->second = level;
-        return tree_algos::CONTINUE;
-    }
+	int operator()(BObject* obj, int level) {
+		rank_map::iterator i;
+		i = _ranks.find(obj);
+		ASSERT( i != _ranks.end() );
+		int rank = i->second;
+		if(rank > level)
+			return tree_algos::SKIP;
+		i->second = level;
+		return tree_algos::CONTINUE;
+	}
 
-    void returnOrdered(ObjectChain::ordered_objs& objs) {
-        //sort
-        typedef std::pair<BObject*, int> the_pair;
-        typedef std::vector<the_pair> unrank_vec;
-        unrank_vec unranks( _ranks.begin(), _ranks.end() );
+	void returnOrdered(ObjectChain::ordered_objs& objs) {
+		//sort
+		typedef std::pair<BObject*, int> the_pair;
+		typedef std::vector<the_pair> unrank_vec;
+		unrank_vec unranks( _ranks.begin(), _ranks.end() );
 
-        using namespace std;
+		using namespace std;
 
-        std::sort(unranks.begin(), unranks.end(), ocVisitRanks_compare);
-        objs.resize(unranks.size());
-        std::transform(unranks.begin(), unranks.end(), objs.begin(), ocVisitRanks_transform);
-    }
+		std::sort(unranks.begin(), unranks.end(), ocVisitRanks_compare);
+		objs.resize(unranks.size());
+		std::transform(unranks.begin(), unranks.end(), objs.begin(), ocVisitRanks_transform);
+	}
 };
 
 //functor for determining, wheather a specified point has been visited
 struct ocVisitCycles {
-    BObject* _target;
-    ocVisitCycles(BObject* target) : _target(target) {}
+	BObject* _target;
+	ocVisitCycles(BObject* target) : _target(target) {}
 
-    int operator()(BObject* obj, int level) {
-        if (_target == obj)
-            return tree_algos::DONE;
-        return tree_algos::CONTINUE;
-    }
+	int operator()(BObject* obj, int level) {
+		if (_target == obj)
+			return tree_algos::DONE;
+		return tree_algos::CONTINUE;
+	}
 };
 
 //Order objects in "destruction" order
 //it stores the result in objs
 void ObjectChain::order_back_to_front(ordered_objs& objs) {
-    //for each object in the list, bfs:
-    //initial node: the object
-    //expand: for every slot in node add connected pin's owner
-    //visit: compute the object's rank
-    
-    ocVisitRanks visit(this);
-    ocExpand expand(this);
-    object_set::const_iterator i;
-    for (i = objects.begin(); i != objects.end(); ++i)
-        tree_algos::bfs(i->get(),visit,expand);
-    visit.returnOrdered(objs);
+	//for each object in the list, bfs:
+	//initial node: the object
+	//expand: for every slot in node add connected pin's owner
+	//visit: compute the object's rank
+	
+	ocVisitRanks visit(this);
+	ocExpand expand(this);
+	object_set::const_iterator i;
+	for (i = objects.begin(); i != objects.end(); ++i)
+		tree_algos::bfs(i->get(),visit,expand);
+	visit.returnOrdered(objs);
 }
 
 //Check for cycles created by edge obj0.pin <- obj1.slot
 bool ObjectChain::check_for_cycles(const RCPtr<BObject>& obj0,
-                                   const RCPtr<BObject>& obj1) {
-    ASSERT( objects.count(obj0) == 1 ); // must be our object
-    ASSERT( objects.count(obj1) == 1 ); // must be our object
+								   const RCPtr<BObject>& obj1) {
+	ASSERT( objects.count(obj0) == 1 ); // must be our object
+	ASSERT( objects.count(obj1) == 1 ); // must be our object
 
-    //bfs:
-    //initial node: = obj0
-    //expand: for every slot in node add connected pin's owner
-    //visit: return true if node == obj1
+	//bfs:
+	//initial node: = obj0
+	//expand: for every slot in node add connected pin's owner
+	//visit: return true if node == obj1
 
-    ocVisitCycles visit(obj1.get());
-    ocExpand expand(this);
-    bool cycle = tree_algos::bfs(obj0.get(),visit,expand);
-    return cycle;
+	ocVisitCycles visit(obj1.get());
+	ocExpand expand(this);
+	bool cycle = tree_algos::bfs(obj0.get(),visit,expand);
+	return cycle;
 }
-             
+			 
 //returns true if it has been disconnected
 //returns false in case of error or if already was not connected
 //NULL pin and slot parameters are allowed
 bool ObjectChain::_disconnect(PinType* pin, SlotType* slot) {
-    slot2pin_map::iterator i;
-    i = slot2pin.find(slot);
-    if (i == slot2pin.end())
-        return false;
+	slot2pin_map::iterator i;
+	i = slot2pin.find(slot);
+	if (i == slot2pin.end())
+		return false;
 
-    if (pin != i->second)
-        return false;
+	if (pin != i->second)
+		return false;
 
-    ASSERT(pin && slot);
+	ASSERT(pin && slot);
 
-    slot->disconnect();
+	slot->disconnect();
 
-    slot2pin.erase(slot);
-    pin2that.erase(pin);
-    pin2slot_map::iterator j;
-    if(!_find_pin(pin,slot,j))
-        ASSERT(false);
-    pin2slot.erase(j);
+	slot2pin.erase(slot);
+	pin2that.erase(pin);
+	pin2slot_map::iterator j;
+	if(!_find_pin(pin,slot,j))
+		ASSERT(false);
+	pin2slot.erase(j);
 
-    return true;
+	return true;
 }
 
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
 bool ObjectChain::_find_slot(SlotType* slot, slot2pin_map::iterator& i) {
-    i = slot2pin.find(slot);
-    if (i == slot2pin.end())
-        return false;
-    return true;
+	i = slot2pin.find(slot);
+	if (i == slot2pin.end())
+		return false;
+	return true;
 }
 
 bool ObjectChain::_find_pin(PinType* pin, SlotType* slot, pin2slot_map::iterator& i) {
-    i = pin2slot.find(pin);
-    for (; i != pin2slot.end() && i->first == pin; ++i)
-        if(i->second == slot) 
-            return true;
-    return false;
+	i = pin2slot.find(pin);
+	for (; i != pin2slot.end() && i->first == pin; ++i)
+		if(i->second == slot) 
+			return true;
+	return false;
 }
 
 PinType* ObjectChain::_match_pin(SlotType* slot) {
-    slot2pin_map::iterator i;
-    if (!_find_slot(slot,i))
-        return NULL;
-    PinType* pin = i->second;
-    return pin;
+	slot2pin_map::iterator i;
+	if (!_find_slot(slot,i))
+		return NULL;
+	PinType* pin = i->second;
+	return pin;
 }
 
 BObject* ObjectChain::_match_that(PinType* pin) {
-    pin2that_map::iterator i;
-    i = pin2that.find(pin);
-    if (i == pin2that.end())
-        return NULL;
-    BObject* that = i->second;
-    return that;
+	pin2that_map::iterator i;
+	i = pin2that.find(pin);
+	if (i == pin2that.end())
+		return NULL;
+	BObject* that = i->second;
+	return that;
 }
 
 /* nonsense:
 SlotType* ObjectChain::_match_slot(PinType* pin, SlotType* slot) {
-    pin2slot_map::iterator i;
-    if(!_find_pin(pin,slot,i))
-        return NULL;
-    SlotType* _slot = i->second;
-    return _slot;
+	pin2slot_map::iterator i;
+	if(!_find_pin(pin,slot,i))
+		return NULL;
+	SlotType* _slot = i->second;
+	return _slot;
 }*/
 
 /////////////////////////////////////////////////////////////////////////////

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -23,116 +23,123 @@
 //ObjectChain holds BObjects and connections between them.
 
 class ObjectChain : public RCObject {
-    typedef std::set< RCPtr<BObject> > object_set;  //we're ref-count-holding the objects
-    typedef std::map<SlotType*, PinType*> slot2pin_map;
-    typedef std::multimap<PinType*, SlotType*> pin2slot_map;
-    typedef std::map<PinType*, BObject*> pin2that_map;
-    typedef slot2pin_map::value_type slot2pin_pair;
-    typedef pin2slot_map::value_type pin2slot_pair;
-    typedef pin2that_map::value_type pin2that_pair;
+	typedef std::set< RCPtr<BObject> > object_set;  //we're ref-count-holding the objects
+	typedef std::map<SlotType*, PinType*> slot2pin_map;
+	typedef std::multimap<PinType*, SlotType*> pin2slot_map;
+	typedef std::map<PinType*, BObject*> pin2that_map;
+	typedef slot2pin_map::value_type slot2pin_pair;
+	typedef pin2slot_map::value_type pin2slot_pair;
+	typedef pin2that_map::value_type pin2that_pair;
 
-    object_set objects;
-    slot2pin_map slot2pin;
-    pin2slot_map pin2slot;
-    pin2that_map pin2that; //could be replaced by introducing pin->getOwner()
+	object_set objects;
+	slot2pin_map slot2pin;
+	pin2slot_map pin2slot;
+	pin2that_map pin2that; //could be replaced by introducing pin->getOwner()
 
-    typedef std::vector<BObject*> ordered_objs;
+	typedef std::vector<BObject*> ordered_objs;
 
 public:
-    
-    //returns true if the insertion was made
-    //returns false if the object was already there
-    bool addObject(const RCPtr<BObject>& obj);
+	
+	//returns true if the insertion was made
+	//returns false if the object was already there
+	bool addObject(const RCPtr<BObject>& obj);
 
-    bool isContained(const RCPtr<BObject>& obj);
+	bool isContained(const RCPtr<BObject>& obj);
 
-    void complete();
+	void complete();
 
-    bool realize();
+	bool realize();
 
-    void unrealize();
+	void unrealize();
 
-    //returns true if connected
-    //false in case of error or if already was connected
-    bool connect(const RCPtr<BObject>& obj0,
-                 const RCPtr<BObject>& obj1,
-                 const BGUID& interfaceGUID);
+	//returns true if connected
+	//false in case of error or if already was connected
+	bool connect(const RCPtr<BObject>& obj0,
+				 const RCPtr<BObject>& obj1,
+				 const BGUID& interfaceGUID);
 
-    bool isConnected(const RCPtr<BObject>& obj0,
-                     const RCPtr<BObject>& obj1,
-                     const BGUID& interfaceGUID);
+	bool isConnected(const RCPtr<BObject>& obj0,
+					 const RCPtr<BObject>& obj1,
+					 const BGUID& interfaceGUID);
 
-    //returns true if it has been disconnected
-    //returns false in case of error or if already was not connected
-    bool disconnect(const RCPtr<BObject>& obj0,
-                    const RCPtr<BObject>& obj1,
-                    const BGUID& interfaceGUID);
+	bool isConnectedPin(PinType* pin);
+	bool isConnectedSlot(SlotType* slot);
+	bool isConnectedPin(const RCPtr<BObject>& obj,
+						const BGUID& interfaceGUID);
+	bool isConnectedSlot(const RCPtr<BObject>& obj,
+						 const BGUID& interfaceGUID);
 
-    //returns true if it has been disconnected
-    //returns false on error or if already was not connected
-    bool disconnect_slot(const RCPtr<BObject>& obj,
-                         const BGUID& interfaceGUID);
+	//returns true if it has been disconnected
+	//returns false in case of error or if already was not connected
+	bool disconnect(const RCPtr<BObject>& obj0,
+					const RCPtr<BObject>& obj1,
+					const BGUID& interfaceGUID);
 
-    //returns true if it has been disconnected
-    //returns false on error or if already was not connected
-    bool disconnect_slot(SlotType* slot);
+	//returns true if it has been disconnected
+	//returns false on error or if already was not connected
+	bool disconnect_slot(const RCPtr<BObject>& obj,
+						 const BGUID& interfaceGUID);
 
-    //returns true if all the slots has been succesfully disconnected
-    //returns false on error
-    bool disconnect_pin(const RCPtr<BObject>& obj,
-                        const BGUID& interfaceGUID);
+	//returns true if it has been disconnected
+	//returns false on error or if already was not connected
+	bool disconnect_slot(SlotType* slot);
 
-    //returns true if all the slots has been succesfully disconnected
-    //returns false on error
-    bool disconnect_pin(PinType* pin);
+	//returns true if all the slots has been succesfully disconnected
+	//returns false on error
+	bool disconnect_pin(const RCPtr<BObject>& obj,
+						const BGUID& interfaceGUID);
 
-    void disconnectObject(const RCPtr<BObject>& obj);
+	//returns true if all the slots has been succesfully disconnected
+	//returns false on error
+	bool disconnect_pin(PinType* pin);
 
-    void removeObject(const RCPtr<BObject>& obj);
+	void disconnectObject(const RCPtr<BObject>& obj);
 
-    void disconnectAll();
+	void removeObject(const RCPtr<BObject>& obj);
 
-    void removeAllObjects();
+	void disconnectAll();
 
-    virtual ~ObjectChain();
+	void removeAllObjects();
 
+	virtual ~ObjectChain();
 
+
 private:
 
-    //Order objects in "destruction" order
-    //it stores the result in objs
-    void order_back_to_front(ordered_objs& objs);
+	//Order objects in "destruction" order
+	//it stores the result in objs
+	void order_back_to_front(ordered_objs& objs);
 
-    //Check for cycles created by edge obj0.pin <- obj1.slot
-    bool check_for_cycles(const RCPtr<BObject>& obj0,
-                          const RCPtr<BObject>& obj1);
-                 
-    friend struct ocExpand;
-    friend struct ocVisitRanks;
-    friend struct ocVisitCycles;
+	//Check for cycles created by edge obj0.pin <- obj1.slot
+	bool check_for_cycles(const RCPtr<BObject>& obj0,
+						  const RCPtr<BObject>& obj1);
+				 
+	friend struct ocExpand;
+	friend struct ocVisitRanks;
+	friend struct ocVisitCycles;
 
-    //returns true if it has been disconnected
-    //returns false in case of error or if already was not connected
-    //NULL pin and slot parameters are allowed
-    bool _disconnect(PinType* pin, SlotType* slot);
+	//returns true if it has been disconnected
+	//returns false in case of error or if already was not connected
+	//NULL pin and slot parameters are allowed
+	bool _disconnect(PinType* pin, SlotType* slot);
 
-    //searches in slot2pin
-    bool _find_slot(SlotType* slot, slot2pin_map::iterator& i);
+	//searches in slot2pin
+	bool _find_slot(SlotType* slot, slot2pin_map::iterator& i);
 
-    //searches in pin2slot
-    bool _find_pin(PinType* pin, SlotType* slot, pin2slot_map::iterator& i);
+	//searches in pin2slot
+	bool _find_pin(PinType* pin, SlotType* slot, pin2slot_map::iterator& i);
 
-    //searches in slot2pin
-    PinType* _match_pin(SlotType* slot);
+	//searches in slot2pin
+	PinType* _match_pin(SlotType* slot);
 
-    //searches in pin2that
-    BObject* _match_that(PinType* pin);
+	//searches in pin2that
+	BObject* _match_that(PinType* pin);
 
-    /* nonsense:
-    SlotType* _match_slot(PinType* pin, SlotType* slot);
-    }*/
+	/* nonsense:
+	SlotType* _match_slot(PinType* pin, SlotType* slot);
+	}*/
 
-    PinSlotDesc* _get_not_connected(BObject* obj, bool ifPin);
+	PinSlotDesc* _get_not_connected(BObject* obj, bool ifPin);
 };
 
 /////////////////////////////////////////////////////////////////////////////

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp	2007-07-04 01:34:12 UTC (rev 27891)
@@ -17,166 +17,185 @@
 /////////////////////////////////////////////////////////////////////////////
 // The ObjectRegistry
 
+ObjectRegistry* ObjectRegistry::_instance = NULL;
+
+/*static*/ ObjectRegistry* ObjectRegistry::get() {
+	if (!_instance)
+		_instance = new ObjectRegistry();
+
+	return _instance;
+}
+
+/*static*/ void ObjectRegistry::release() {
+	if (_instance)
+		delete _instance;
+	_instance = NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Plugin registering
+
 typedef Plugin::ObjectPlugins ObjectPlugins;
 
 //returns false if there were some conflicts
 bool ObjectRegistry::registerPlugin(PluginAccessor pluginAccessor, bool overwrite) {
-    const Plugin& plugin = pluginAccessor();
-    return registerPlugin(plugin, overwrite);
+	const Plugin& plugin = pluginAccessor();
+	return registerPlugin(plugin, overwrite);
 }
 
 //returns false if there were some conflicts
 bool ObjectRegistry::registerPlugin(const Plugin& plugin, bool overwrite) {
-    const ObjectPlugins& oplugs = plugin.getObjectPlugins();
+	const ObjectPlugins& oplugs = plugin.getObjectPlugins();
 
-    bool res = true;
+	bool res = true;
 
-    ObjectPlugins::const_iterator i;
-    for (i = oplugs.begin(); i != oplugs.end(); ++i)
-    {
-        const ObjectPlugin* oplug = i->second;
-        ASSERT(oplug);
-        const BGUID& oguid = oplug->getObjectGUID();
+	ObjectPlugins::const_iterator i;
+	for (i = oplugs.begin(); i != oplugs.end(); ++i)
+	{
+		const ObjectPlugin* oplug = i->second;
+		ASSERT(oplug);
+		const BGUID& oguid = oplug->getObjectGUID();
 
-        PluginsMap::iterator i;
-        i = _pluginsMap.find(oguid);
-        if (i != _pluginsMap.end()) {
-            res = false;
-            if(!overwrite)
-                continue;
-            i->second = oplug;
-        } else {
-            _pluginsMap.insert( std::make_pair(oguid, oplug) );
-        }
+		PluginsMap::iterator i;
+		i = _pluginsMap.find(oguid);
+		if (i != _pluginsMap.end()) {
+			res = false;
+			if(!overwrite)
+				continue;
+			i->second = oplug;
+		} else {
+			_pluginsMap.insert( std::make_pair(oguid, oplug) );
+		}
 
-        //register recognizers and resolvers in FileTypeRegistry
-        const BObjectDesc& objectDesc = oplug->get_desc();
-        if (objectDesc.get_flags() & IS_FILE_TYPE_RECOGNIZER)
-            FileTypeRegistry::get()->registerRecognizerPlugin(oplug);
-        if (objectDesc.get_flags() & IS_FILE_TYPE_RESOLVER)
-            FileTypeRegistry::get()->registerResolverPlugin(oplug);
-    }
+		//register recognizers and resolvers in FileTypeRegistry
+		const BObjectDesc& objectDesc = oplug->get_desc();
+		if (objectDesc.get_flags() & IS_FILE_TYPE_RECOGNIZER)
+			FileTypeRegistry::get()->registerRecognizerPlugin(oplug);
+		if (objectDesc.get_flags() & IS_FILE_TYPE_RESOLVER)
+			FileTypeRegistry::get()->registerResolverPlugin(oplug);
+	}
 
-    //TODO: make this thing below better
-    rebuildPinSlotMaps();
+	//TODO: make this thing below better
+	rebuildPinSlotMaps();
 
-    return res;
+	return res;
 }
 
 void ObjectRegistry::rebuildPinSlotMaps() {
-    _pinMap.clear();
-    _slotMap.clear();
+	_pinMap.clear();
+	_slotMap.clear();
 
-    PluginsMap::const_iterator j;
-    for (j = _pluginsMap.begin(); j != _pluginsMap.end(); ++j) {
+	PluginsMap::const_iterator j;
+	for (j = _pluginsMap.begin(); j != _pluginsMap.end(); ++j) {
 
-        const BGUID& objectGuid = j->first;
-        const ObjectPlugin* objectPlugin = j->second;
+		const BGUID& objectGuid = j->first;
+		const ObjectPlugin* objectPlugin = j->second;
 
-        //don't include recognizers nor resolvers
-        const BObjectDesc& objectDesc = objectPlugin->get_desc();
-        if ( objectDesc.get_flags() & IS_FILE_TYPE_RECOGNIZER ||
-             objectDesc.get_flags() & IS_FILE_TYPE_RESOLVER )
-             continue;
+		//don't include recognizers nor resolvers
+		const BObjectDesc& objectDesc = objectPlugin->get_desc();
+		if ( objectDesc.get_flags() & IS_FILE_TYPE_RECOGNIZER ||
+			 objectDesc.get_flags() & IS_FILE_TYPE_RESOLVER )
+			 continue;
 
-        PinSlotDescs::const_iterator i;
+		PinSlotDescs::const_iterator i;
 
-        const PinSlotDescs& pins = objectPlugin->get_pins();
-        for (i = pins.begin(); i != pins.end(); ++i)
-        {
-            const BGUID& pinGuid = i->first;
-            _pinMap.insert( PinSlotMap::value_type(pinGuid, objectGuid) );
-        }
+		const PinSlotDescs& pins = objectPlugin->get_pins();
+		for (i = pins.begin(); i != pins.end(); ++i)
+		{
+			const BGUID& pinGuid = i->first;
+			_pinMap.insert( PinSlotMap::value_type(pinGuid, objectGuid) );
+		}
 
-        const PinSlotDescs& slots = objectPlugin->get_slots();
-        for (i = slots.begin(); i != slots.end(); ++i)
-        {
-            const BGUID& slotGuid = i->first;
-            _slotMap.insert( PinSlotMap::value_type(slotGuid, objectGuid) );
-        }
-    }
+		const PinSlotDescs& slots = objectPlugin->get_slots();
+		for (i = slots.begin(); i != slots.end(); ++i)
+		{
+			const BGUID& slotGuid = i->first;
+			_slotMap.insert( PinSlotMap::value_type(slotGuid, objectGuid) );
+		}
+	}
 }
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 
 const ObjectPlugin* ObjectRegistry::findObjectPlugin(const BGUID& objectGuid) {
-    PluginsMap::const_iterator i;
-    i = _pluginsMap.find(objectGuid);
-    if (i == _pluginsMap.end())
-        return NULL;
-    return i->second;
+	PluginsMap::const_iterator i;
+	i = _pluginsMap.find(objectGuid);
+	if (i == _pluginsMap.end())
+		return NULL;
+	return i->second;
 }
 
 RCPtr<BObject> ObjectRegistry::getObject(const BGUID& objectGuid) {
-    const ObjectPlugin* plug = findObjectPlugin(objectGuid);
-    if (!plug)
-        return NULL;
-    return plug->newInstance();
+	const ObjectPlugin* plug = findObjectPlugin(objectGuid);
+	if (!plug)
+		return NULL;
+	return plug->newInstance();
 }
 
 RCPtr<BObject> ObjectRegistry::getObjectWithPin(const BGUID& pinGuid) {
-    const ObjectPlugin* plug = findObjectWithPin(pinGuid);
-    if (!plug)
-        return NULL;
-    return plug->newInstance();
+	const ObjectPlugin* plug = findObjectWithPin(pinGuid);
+	if (!plug)
+		return NULL;
+	return plug->newInstance();
 }
 
 RCPtr<BObject> ObjectRegistry::getObjectWithSlot(const BGUID& slotGuid) {
-    const ObjectPlugin* plug = findObjectWithSlot(slotGuid);
-    if (!plug)
-        return NULL;
-    return plug->newInstance();
+	const ObjectPlugin* plug = findObjectWithSlot(slotGuid);
+	if (!plug)
+		return NULL;
+	return plug->newInstance();
 }
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 
 const ObjectPlugin* ObjectRegistry::findObjectWithPinOrSlot(const BGUID& pinSlotGuid, bool ifPin) {
-    const PinSlotMap& pinSlotMap = ifPin ? _pinMap : _slotMap;
+	const PinSlotMap& pinSlotMap = ifPin ? _pinMap : _slotMap;
 
-    PinSlotMap::const_iterator i;
-    i = pinSlotMap.find(pinSlotGuid);
-    if (i != pinSlotMap.end())
-        return findObjectPlugin( i->second );
+	PinSlotMap::const_iterator i;
+	i = pinSlotMap.find(pinSlotGuid);
+	if (i != pinSlotMap.end())
+		return findObjectPlugin( i->second );
 
-    return NULL;
+	return NULL;
 }
 
 const ObjectPlugin* ObjectRegistry::findObjectWithPin(const BGUID& pinGuid) {
-    return findObjectWithPinOrSlot(pinGuid, true);
+	return findObjectWithPinOrSlot(pinGuid, true);
 }
 
 const ObjectPlugin* ObjectRegistry::findObjectWithSlot(const BGUID& slotGuid) {
-    return findObjectWithPinOrSlot(slotGuid, false);
+	return findObjectWithPinOrSlot(slotGuid, false);
 }
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 
 std::list<const ObjectPlugin*> ObjectRegistry::findObjectsWithPinOrSlot(const BGUID& pinSlotGuid, bool ifPin) {
-    const PinSlotMap& pinSlotMap = ifPin ? _pinMap : _slotMap;
+	const PinSlotMap& pinSlotMap = ifPin ? _pinMap : _slotMap;
 
-    PinSlotMap::const_iterator i;
-    i = pinSlotMap.find(pinSlotGuid);
+	PinSlotMap::const_iterator i;
+	i = pinSlotMap.find(pinSlotGuid);
 
-    std::list<const ObjectPlugin*> plugins;
-    for (; i != pinSlotMap.end() && i->first == pinSlotGuid; ++i) {
-        const ObjectPlugin* plugin = findObjectPlugin( i->second );
-        if (!plugin)
-            continue;
-        plugins.push_back( plugin );
-    }
+	std::list<const ObjectPlugin*> plugins;
+	for (; i != pinSlotMap.end() && i->first == pinSlotGuid; ++i) {
+		const ObjectPlugin* plugin = findObjectPlugin( i->second );
+		if (!plugin)
+			continue;
+		plugins.push_back( plugin );
+	}
 
-    return plugins;
+	return plugins;
 }
 
 std::list<const ObjectPlugin*> ObjectRegistry::findObjectsWithPin(const BGUID& pinGuid) {
-    return findObjectsWithPinOrSlot(pinGuid, true);
+	return findObjectsWithPinOrSlot(pinGuid, true);
 }
 
 std::list<const ObjectPlugin*> ObjectRegistry::findObjectsWithSlot(const BGUID& slotGuid) {
-    return findObjectsWithPinOrSlot(slotGuid, false);
+	return findObjectsWithPinOrSlot(slotGuid, false);
 }
 
 /////////////////////////////////////////////////////////////////////////////

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -23,55 +23,56 @@
 
 class ObjectRegistry {
 
-    //CAUTION: the Plugin::ObjectPlugins map is keyed with the plugins GUID, not
-    //         it's object's GUID.
-    //CAUTION: the PluginsMap map is keyed with the object's GUID, not
-    //         it's plugin's GUID.
-    typedef std::map<const BGUID, const ObjectPlugin*> PluginsMap;
-    PluginsMap _pluginsMap;
+	//CAUTION: the Plugin::ObjectPlugins map is keyed with the plugins GUID, not
+	//         it's object's GUID.
+	//CAUTION: the PluginsMap map is keyed with the object's GUID, not
+	//         it's plugin's GUID.
+	typedef std::map<const BGUID, const ObjectPlugin*> PluginsMap;
+	PluginsMap _pluginsMap;
 
-    //maps from pin/slot's GUID to object's GUID
-    typedef std::multimap<const BGUID, const BGUID> PinSlotMap;
-    PinSlotMap _pinMap;
-    PinSlotMap _slotMap;
+	//maps from pin/slot's GUID to object's GUID
+	typedef std::multimap<const BGUID, const BGUID> PinSlotMap;
+	PinSlotMap _pinMap;
+	PinSlotMap _slotMap;
 
-    typedef const Plugin& (*PluginAccessor)();
+	typedef const Plugin& (*PluginAccessor)();
 
 public:
-    //returns false if there were some conflicts
-    bool registerPlugin(PluginAccessor pluginAccessor, bool overwrite);
+	//returns false if there were some conflicts
+	bool registerPlugin(PluginAccessor pluginAccessor, bool overwrite);
 
-    //returns false if there were some conflicts
-    bool registerPlugin(const Plugin& plugin, bool overwrite);
+	//returns false if there were some conflicts
+	bool registerPlugin(const Plugin& plugin, bool overwrite);
 
-    const ObjectPlugin* findObjectPlugin(const BGUID& objectGuid);
+	const ObjectPlugin* findObjectPlugin(const BGUID& objectGuid);
 
-    RCPtr<BObject> getObject(const BGUID& objectGuid);
-    RCPtr<BObject> getObjectWithPin(const BGUID& pinGuid);
-    RCPtr<BObject> getObjectWithSlot(const BGUID& slotGuid);
+	RCPtr<BObject> getObject(const BGUID& objectGuid);
+	RCPtr<BObject> getObjectWithPin(const BGUID& pinGuid);
+	RCPtr<BObject> getObjectWithSlot(const BGUID& slotGuid);
 
-    template<typename T>
-    RCPtr<T> getObject() {
-        RCPtr<BObject> obj( getObject(T::static_GUID()) );
-        return static_cast<T*>(obj.get());
-    }
+	template<typename T>
+	RCPtr<T> getObject() {
+		RCPtr<BObject> obj( getObject(T::static_GUID()) );
+		return static_cast<T*>(obj.get());
+	}
 
-    std::list<const ObjectPlugin*> findObjectsWithPinOrSlot(const BGUID& pinSlotGuid, bool ifPin);
-    std::list<const ObjectPlugin*> findObjectsWithPin(const BGUID& pinGuid);
-    std::list<const ObjectPlugin*> findObjectsWithSlot(const BGUID& slotGuid);
+	std::list<const ObjectPlugin*> findObjectsWithPinOrSlot(const BGUID& pinSlotGuid, bool ifPin);
+	std::list<const ObjectPlugin*> findObjectsWithPin(const BGUID& pinGuid);
+	std::list<const ObjectPlugin*> findObjectsWithSlot(const BGUID& slotGuid);
 
-    const ObjectPlugin* findObjectWithPinOrSlot(const BGUID& pinSlotGuid, bool ifPin);
-    const ObjectPlugin* findObjectWithPin(const BGUID& pinGuid);
-    const ObjectPlugin* findObjectWithSlot(const BGUID& slotGuid);
+	const ObjectPlugin* findObjectWithPinOrSlot(const BGUID& pinSlotGuid, bool ifPin);
+	const ObjectPlugin* findObjectWithPin(const BGUID& pinGuid);
+	const ObjectPlugin* findObjectWithSlot(const BGUID& slotGuid);
 
 
-    static ObjectRegistry* get() {
-        static ObjectRegistry instance;
-        return &instance;
-    }
+	static ObjectRegistry* get();
+	static void release();
+private:
+	static ObjectRegistry* _instance;
+	ObjectRegistry() {}
 
 private:
-    void rebuildPinSlotMaps();
+	void rebuildPinSlotMaps();
 };
 
 /////////////////////////////////////////////////////////////////////////////

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp	2007-07-04 01:34:12 UTC (rev 27891)
@@ -22,14 +22,14 @@
 //   name          - a human readable name
 //   flags         - flags of a pin/slot (default/multicast/pin/slot...)
 
-    _PinSlotDesc::_PinSlotDesc(std::string _name, const BGUID& _interfaceGUID, int _flags)
-            : name(_name), interfaceGUID(_interfaceGUID),
-            flags(_flags) {}
+_PinSlotDesc::_PinSlotDesc(std::string _name, const BGUID& _interfaceGUID, int _flags)
+		: name(_name), interfaceGUID(_interfaceGUID),
+		flags(_flags) {}
 
-    std::ostream& operator<<(std::ostream& os, const _PinSlotDesc& desc) {
-        return os << "PinSlotDesc(" << desc.name << ", " << desc.interfaceGUID << ", "
-            << desc.flags << ")";
-    }
+std::ostream& operator<<(std::ostream& os, const _PinSlotDesc& desc) {
+	return os << "PinSlotDesc(" << desc.name << ", " << desc.interfaceGUID << ", "
+		<< desc.flags << ")";
+}
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
@@ -40,31 +40,31 @@
 //                                     an object
 // (see Makers and Accesors in pinslot_detail.h for more details)
 
-    PinSlotDesc::PinSlotDesc(std::string _name, const BGUID& _interfaceGUID, int _flags)
-        : _PinSlotDesc(_name, _interfaceGUID, _flags) {}
+PinSlotDesc::PinSlotDesc(std::string _name, const BGUID& _interfaceGUID, int _flags)
+	: _PinSlotDesc(_name, _interfaceGUID, _flags) {}
 
-    PinSlotDesc::PinSlotDesc(const _PinSlotDesc& desc)
-        : _PinSlotDesc(desc) {}
+PinSlotDesc::PinSlotDesc(const _PinSlotDesc& desc)
+	: _PinSlotDesc(desc) {}
 
-    PinSlotDesc::~PinSlotDesc() {}
+PinSlotDesc::~PinSlotDesc() {}
 
-    PinType* PinSlotDesc::get_pin(BObject* that) const {
-        ASSERT( that );
-        ASSERT( flags & IS_PIN ); //don't ask me for pin if I don't describe a pin
-        PinSlotType* pinSlot = getPinSlot(that);
-        ASSERT( pinSlot ); //there must be a pin I describe (I can't describe nothing)
-        ASSERT( pinSlot->get_desc().flags & IS_PIN ); //sanity check
-        return static_cast<PinType*>(pinSlot);
-    }
+PinType* PinSlotDesc::get_pin(BObject* that) const {
+	ASSERT( that );
+	ASSERT( flags & IS_PIN ); //don't ask me for pin if I don't describe a pin
+	PinSlotType* pinSlot = getPinSlot(that);
+	ASSERT( pinSlot ); //there must be a pin I describe (I can't describe nothing)
+	ASSERT( pinSlot->get_desc().flags & IS_PIN ); //sanity check
+	return static_cast<PinType*>(pinSlot);
+}
 
-    SlotType* PinSlotDesc::get_slot(BObject* that) const {
-        ASSERT( that );
-        ASSERT( flags & IS_SLOT ); //don't ask me for slot if I don't describe a slot
-        PinSlotType* pinSlot = getPinSlot(that);
-        ASSERT( pinSlot ); //there must be a slot I describe (I can't describe nothing)
-        ASSERT( pinSlot->get_desc().flags & IS_SLOT ); //sanity check
-        return static_cast<SlotType*>(pinSlot);
-    }
+SlotType* PinSlotDesc::get_slot(BObject* that) const {
+	ASSERT( that );
+	ASSERT( flags & IS_SLOT ); //don't ask me for slot if I don't describe a slot
+	PinSlotType* pinSlot = getPinSlot(that);
+	ASSERT( pinSlot ); //there must be a slot I describe (I can't describe nothing)
+	ASSERT( pinSlot->get_desc().flags & IS_SLOT ); //sanity check
+	return static_cast<SlotType*>(pinSlot);
+}
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
@@ -74,53 +74,53 @@
 
 namespace pinslot_detail {
 
-    typedef std::map<const BGUID,PinSlotDesc*> the_map;
-    typedef std::pair<const BGUID,PinSlotDesc*> the_pair;
+	typedef std::map<const BGUID,PinSlotDesc*> the_map;
+	typedef std::pair<const BGUID,PinSlotDesc*> the_pair;
 
-    annotation_map::annotation_map(bool _shared /*= false*/) : shared(_shared) {}
+	annotation_map::annotation_map(bool _shared /*= false*/) : shared(_shared) {}
 
-    annotation_map::annotation_map(const annotation_map& _map) {
-        shared = true;
-        insert(_map);
-    }
-    annotation_map::~annotation_map() {
-        if(shared)
-            return;
-        the_map::iterator i;
-        for(i = begin(); i != end(); ++i)
-            delete (i->second);
-    }
+	annotation_map::annotation_map(const annotation_map& _map) {
+		shared = true;
+		insert(_map);
+	}
+	annotation_map::~annotation_map() {
+		if(shared)
+			return;
+		the_map::iterator i;
+		for(i = begin(); i != end(); ++i)
+			delete (i->second);
+	}
 
-    PinSlotDesc* annotation_map::find(const BGUID& key) const {
-        the_map::const_iterator it = this->the_map::find(key);
-        if(it != end())
-            return it->second;
-        return NULL;
-    }
+	PinSlotDesc* annotation_map::find(const BGUID& key) const {
+		the_map::const_iterator it = this->the_map::find(key);
+		if(it != end())
+			return it->second;
+		return NULL;
+	}
 
-    annotation_map& annotation_map::insert(PinSlotDesc* val) {
-        std::pair<the_map::iterator, bool> res =
-            this->the_map::insert(the_pair(val->interfaceGUID,val));
-        if(!res.second) { //there is an element with the same BGUID
-            if(res.first->second)
-                delete res.first->second; //get rid of it...
-            res.first->second = val;      //...and overwrite
-        }
-        return *this;
-    }
+	annotation_map& annotation_map::insert(PinSlotDesc* val) {
+		std::pair<the_map::iterator, bool> res =
+			this->the_map::insert(the_pair(val->interfaceGUID,val));
+		if(!res.second) { //there is an element with the same BGUID
+			if(res.first->second)
+				delete res.first->second; //get rid of it...
+			res.first->second = val;      //...and overwrite
+		}
+		return *this;
+	}
 
-    annotation_map& annotation_map::insert(const annotation_map& cont) {
-        this->the_map::insert(cont.begin(), cont.end());
-        return *this;
-    }
+	annotation_map& annotation_map::insert(const annotation_map& cont) {
+		this->the_map::insert(cont.begin(), cont.end());
+		return *this;
+	}
 
-    annotation_map& annotation_map::insert_copy(const annotation_map& cont) {
-        ASSERT(this->empty());
-        annotation_map::const_iterator i;
-        for(i = cont.begin(); i != cont.end(); ++i)
-            this->the_map::insert( the_pair( i->first, i->second->copy() ) );
-        return *this;
-    }
+	annotation_map& annotation_map::insert_copy(const annotation_map& cont) {
+		ASSERT(this->empty());
+		annotation_map::const_iterator i;
+		for(i = cont.begin(); i != cont.end(); ++i)
+			this->the_map::insert( the_pair( i->first, i->second->copy() ) );
+		return *this;
+	}
 
 }
 
@@ -128,54 +128,54 @@
 /////////////////////////////////////////////////////////////////////////////
 // BObject is a reference counted object that is capable of holding pins and slots.
 
-    //do not call manually!
-    void BObject::init_pins_slots() {
-        PinSlotDescs::const_iterator i;
-        const PinSlotDescs& pdescs = get_pins();
-        for(i = pdescs.begin(); i != pdescs.end(); ++i)
-        {
-            PinSlotDesc* desc = i->second;
-            desc->makePinSlot(this);
-        }
-        const PinSlotDescs& sdescs = get_slots();
-        for(i = sdescs.begin(); i != sdescs.end(); ++i)
-        {
-            PinSlotDesc* desc = i->second;
-            desc->makePinSlot(this);
-        }
-    }
+//do not call manually!
+void BObject::init_pins_slots() {
+	PinSlotDescs::const_iterator i;
+	const PinSlotDescs& pdescs = get_pins();
+	for(i = pdescs.begin(); i != pdescs.end(); ++i)
+	{
+		PinSlotDesc* desc = i->second;
+		desc->makePinSlot(this);
+	}
+	const PinSlotDescs& sdescs = get_slots();
+	for(i = sdescs.begin(); i != sdescs.end(); ++i)
+	{
+		PinSlotDesc* desc = i->second;
+		desc->makePinSlot(this);
+	}
+}
 
-    //do not call manually!
-    void BObject::delete_pins_slots() {
-        PinSlotDescs::const_iterator i;
-        const PinSlotDescs& pdescs = get_pins();
-        for(i = pdescs.begin(); i != pdescs.end(); ++i)
-        {
-            PinSlotDesc* desc = i->second;
-            delete desc->getPinSlot(this);
-        }
-        const PinSlotDescs& sdescs = get_slots();
-        for(i = sdescs.begin(); i != sdescs.end(); ++i)
-        {
-            PinSlotDesc* desc = i->second;
-            delete desc->getPinSlot(this);
-        }
-    }
+//do not call manually!
+void BObject::delete_pins_slots() {
+	PinSlotDescs::const_iterator i;
+	const PinSlotDescs& pdescs = get_pins();
+	for(i = pdescs.begin(); i != pdescs.end(); ++i)
+	{
+		PinSlotDesc* desc = i->second;
+		delete desc->getPinSlot(this);
+	}
+	const PinSlotDescs& sdescs = get_slots();
+	for(i = sdescs.begin(); i != sdescs.end(); ++i)
+	{
+		PinSlotDesc* desc = i->second;
+		delete desc->getPinSlot(this);
+	}
+}
 
-    PinType* BObject::get_pin(const BGUID& interfaceGUID) {
-        return static_cast<PinType*>(get_pinSlot( interfaceGUID, get_pins() ));
-    }
+PinType* BObject::get_pin(const BGUID& interfaceGUID) {
+	return static_cast<PinType*>(get_pinSlot( interfaceGUID, get_pins() ));
+}
 
-    SlotType* BObject::get_slot(const BGUID& interfaceGUID) {
-        return static_cast<SlotType*>(get_pinSlot( interfaceGUID, get_slots() ));
-    }
+SlotType* BObject::get_slot(const BGUID& interfaceGUID) {
+	return static_cast<SlotType*>(get_pinSlot( interfaceGUID, get_slots() ));
+}
 
-    PinSlotType* BObject::get_pinSlot(const BGUID& interfaceGUID, const PinSlotDescs& descs) {
-        PinSlotDesc* desc = descs.find(interfaceGUID);
-        if(!desc)
-            return NULL;
-        return desc->getPinSlot(this);
-    }
+PinSlotType* BObject::get_pinSlot(const BGUID& interfaceGUID, const PinSlotDescs& descs) {
+	PinSlotDesc* desc = descs.find(interfaceGUID);
+	if(!desc)
+		return NULL;
+	return desc->getPinSlot(this);
+}
 
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////

Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h	2007-07-04 01:32:32 UTC (rev 27890)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h	2007-07-04 01:34:12 UTC (rev 27891)
@@ -25,21 +25,21 @@
 //         pin/slot connecting in the ObjectChain.
 //         I.e. you can't rely on a singlecast pin to be connected to only once.
 enum {
-    IS_PIN        = 1,
-    IS_SLOT       = 2,
-    PIN_DEFAULT   = 4,      //ObjectChain should try to connect it with some slot
-    SLOT_DEFAULT  = 8,      //ObjectChain should try to connect it with some pin
-    PIN_MULTICAST = 16,     //ObjectChain is allowed to connect many slots to this pin
+	IS_PIN        = 1,
+	IS_SLOT       = 2,
+	PIN_DEFAULT   = 4,      //ObjectChain should try to connect it with some slot
+	SLOT_DEFAULT  = 8,      //ObjectChain should try to connect it with some pin
+	PIN_MULTICAST = 16,     //ObjectChain is allowed to connect many slots to this pin
 };
 
 //TODO: introduce BObjectDesc
 //TODO: use IS_... in ObjectChain::complete() logic
 enum {
-    IS_FILE_TYPE_RECOGNIZER = 1,
-    IS_FILE_TYPE_RESOLVER = 2,
-    IS_PROVIDER = 4,             //unused for now
-    IS_FILTER = 8,               //unused for now
-    IS_PRESENTER = 16,            //unused for now
+	IS_FILE_TYPE_RECOGNIZER = 1,
+	IS_FILE_TYPE_RESOLVER = 2,
+	IS_PROVIDER = 4,             //unused for now
+	IS_FILTER = 8,               //unused for now
+	IS_PRESENTER = 16,            //unused for now
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -50,7 +50,7 @@
 
 class IInterface : public GUIDObject {
 public:
-    virtual ~IInterface() {} //not really needed - but for extra safety it's here
+	virtual ~IInterface() {} //not really needed - but for extra safety it's here
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -60,47 +60,47 @@
 struct _PinSlotDesc;
 
 struct PinSlotType {
-    virtual const _PinSlotDesc& get_desc() const = 0;
-    virtual ~PinSlotType() {}
+	virtual const _PinSlotDesc& get_desc() const = 0;
+	virtual ~PinSlotType() {}
 };
 
 struct PinType : PinSlotType {
-    virtual IInterface* getInterface() = 0;               //not typesafe
-    virtual void releaseInterface(IInterface* iface) = 0; //not typesafe
+	virtual IInterface* getInterface() = 0;               //not typesafe
+	virtual void releaseInterface(IInterface* iface) = 0; //not typesafe
 };
 
 struct SlotType : PinSlotType {
-    virtual IInterface* getInterface() = 0;               //not typesafe
-    virtual void releaseInterface() = 0;
-    virtual void connect(PinType* _pin) = 0;              //not typesafe
-    virtual void disconnect() = 0;
-    virtual bool isConnected() = 0;
+	virtual IInterface* getInterface() = 0;               //not typesafe
+	virtual void releaseInterface() = 0;
+	virtual void connect(PinType* _pin) = 0;              //not typesafe
+	virtual void disconnect() = 0;
+	virtual bool isConnected() = 0;
 };
 
 template<typename I>
 struct Pin : PinType {
-    virtual I* getInterface() = 0;
-    virtual void releaseInterface(I* iface) = 0;
+	virtual I* getInterface() = 0;
+	virtual void releaseInterface(I* iface) = 0;
 
-    /*virtual IInterface* getInterface() {

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list