[Scummvm-cvs-logs] SF.net SVN: scummvm: [27883] scummex/branches/gsoc2007-gameresbrowser
zbychs at users.sourceforge.net
zbychs at users.sourceforge.net
Tue Jul 3 18:58:16 CEST 2007
Revision: 27883
http://scummvm.svn.sourceforge.net/scummvm/?rev=27883&view=rev
Author: zbychs
Date: 2007-07-03 09:58:16 -0700 (Tue, 03 Jul 2007)
Log Message:
-----------
Added file type recognition facility.
Modified Paths:
--------------
scummex/branches/gsoc2007-gameresbrowser/gcc/Makefile
scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h
scummex/branches/gsoc2007-gameresbrowser/src/core/common/stream.h
scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h
scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp
scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h
scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp
scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h
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/gui/DirectoryPresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.h
scummex/branches/gsoc2007-gameresbrowser/src/gui/FilePresenter.h
scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h
scummex/branches/gsoc2007-gameresbrowser/src/gui/PanelProvider.h
scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/BMPParser.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/DiskFileProvider.h
scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_plugins.cpp
scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_verbose.cpp
scummex/branches/gsoc2007-gameresbrowser/vc8/core/ReadMe.txt
scummex/branches/gsoc2007-gameresbrowser/vc8/core/core.vcproj
scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/ReadMe.txt
scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/plugins.vcproj
scummex/branches/gsoc2007-gameresbrowser/vc8/vc8.sln
scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout
Added Paths:
-----------
scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.cpp
scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.h
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/
scummex/branches/gsoc2007-gameresbrowser/src/core/common/ReadMe.txt
scummex/branches/gsoc2007-gameresbrowser/src/plugins/FileTypeRecognizer.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/ftregistry.cpp
Removed Paths:
-------------
scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/
Modified: scummex/branches/gsoc2007-gameresbrowser/gcc/Makefile
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/gcc/Makefile 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/gcc/Makefile 2007-07-03 16:58:16 UTC (rev 27883)
@@ -13,42 +13,39 @@
SOURCES_DIR = ../src
HEADERS_DIRS = $(SOURCES_DIR)/core $(SOURCES_DIR)/plugins $(SOURCES_DIR)/gui
+COMMON_DIR = $(SOURCES_DIR)/core/common
CORE_DIR = $(SOURCES_DIR)/core
-PLUGINS_DIR_BASE = $(SOURCES_DIR)/plugins
-PLUGINS_DIR_EXT = $(SOURCES_DIR)/plugins/common
+PLUGINS_DIR = $(SOURCES_DIR)/plugins
GUI_DIR = $(SOURCES_DIR)/gui
+COMMON_SOURCES = $(wildcard $(COMMON_DIR)/*.cpp)
+COMMON_OUTPUT = ./out/core/common
+
CORE_SOURCES = $(wildcard $(CORE_DIR)/*.cpp)
CORE_OUTPUT = ./out/core
CORE_LIB = core
CORE_TARGET = $(CORE_OUTPUT)/lib$(CORE_LIB).a
-PLUGINS_SOURCES_BASE = $(wildcard $(PLUGINS_DIR_BASE)/*.cpp)
-PLUGINS_SOURCES_EXT = $(wildcard $(PLUGINS_DIR_EXT)/*.cpp)
-PLUGINS_SOURCES = $(PLUGINS_SOURCES_BASE) $(PLUGINS_SOURCES_EXT)
-PLUGINS_OUTPUT_BASE = ./out/plugins
-PLUGINS_OUTPUT_EXT = ./out/plugins/common
-PLUGINS_OUTPUT = $(PLUGINS_OUTPUT_BASE) $(PLUGINS_OUTPUT_EXT)
+PLUGINS_SOURCES = $(wildcard $(PLUGINS_DIR)/*.cpp)
+PLUGINS_OUTPUT = ./out/plugins
PLUGINS_LIB = plugins
-PLUGINS_TARGET = $(PLUGINS_OUTPUT_BASE)/lib$(PLUGINS_LIB).a
+PLUGINS_TARGET = $(PLUGINS_OUTPUT)/lib$(PLUGINS_LIB).a
GUI_SOURCES = $(wildcard $(GUI_DIR)/*.cpp)
GUI_OUTPUT = ./out/gui
GUI_TARGET = $(GUI_OUTPUT)/browser
+COMMON_OBJECTS_ = $(patsubst %.cpp,%.o, $(COMMON_SOURCES) )
CORE_OBJECTS_ = $(patsubst %.cpp,%.o, $(CORE_SOURCES) )
-PLUGINS_OBJECTS_BASE_ = $(patsubst %.cpp,%.o, $(PLUGINS_SOURCES_BASE) )
-PLUGINS_OBJECTS_EXT_ = $(patsubst %.cpp,%.o, $(PLUGINS_SOURCES_EXT) )
-PLUGINS_OBJECTS_ = $(PLUGINS_OBJECTS_BASE_) $(PLUGINS_OBJECTS_EXT_)
+PLUGINS_OBJECTS_ = $(patsubst %.cpp,%.o, $(PLUGINS_SOURCES) )
GUI_OBJECTS_ = $(patsubst %.cpp,%.o, $(GUI_SOURCES) )
+COMMON_OBJECTS = $(patsubst %, $(COMMON_OUTPUT)/%, $(notdir $(COMMON_OBJECTS_) ) )
CORE_OBJECTS = $(patsubst %, $(CORE_OUTPUT)/%, $(notdir $(CORE_OBJECTS_) ) )
-PLUGINS_OBJECTS_BASE = $(patsubst %, $(PLUGINS_OUTPUT_BASE)/%, $(notdir $(PLUGINS_OBJECTS_BASE_) ) )
-PLUGINS_OBJECTS_EXT = $(patsubst %, $(PLUGINS_OUTPUT_EXT)/%, $(notdir $(PLUGINS_OBJECTS_EXT_) ) )
-PLUGINS_OBJECTS = $(PLUGINS_OBJECTS_BASE) $(PLUGINS_OBJECTS_EXT)
+PLUGINS_OBJECTS = $(patsubst %, $(PLUGINS_OUTPUT)/%, $(notdir $(PLUGINS_OBJECTS_) ) )
GUI_OBJECTS = $(patsubst %, $(GUI_OUTPUT)/%, $(notdir $(GUI_OBJECTS_) ) )
-ALL_SOURCES = $(CORE_SOURCES) $(PLUGINS_SOURCES) $(GUI_SOURCES)
+ALL_SOURCES = $(COMMON_SOURCES) $(CORE_SOURCES) $(PLUGINS_SOURCES) $(GUI_SOURCES)
#ALL_OBJECTS = $(CORE_OBJECTS) $(PLUGINS_OBJECTS) $(GUI_OBJECTS)
#ALL_OUTPUT = $(CORE_OUTPUT) $(PLUGINS_OUTPUT) $(GUI_OUTPUT)
@@ -80,10 +77,10 @@
###########################################################################################
clean_core:
- rm -f $(CORE_OBJECTS) $(CORE_TARGET)
+ rm -f $(COMMON_OBJECTS) $(CORE_OBJECTS) $(CORE_TARGET)
clean_plugins:
- rm -f $(PLUGINS_OBJECTS_BASE) $(PLUGINS_OBJECTS_EXT) $(PLUGINS_TARGET)
+ rm -f $(PLUGINS_OBJECTS) $(PLUGINS_TARGET)
clean_gui:
rm -f $(GUI_OBJECTS) $(GUI_TARGET)
@@ -108,10 +105,10 @@
$(CORE_OBJECTS) : $(CORE_DIR)/$$(notdir $$(basename $$@) ).cpp
g++ $(CFLAGS) -c $< -o $@
-$(PLUGINS_OBJECTS_BASE) : $(PLUGINS_DIR_BASE)/$$(notdir $$(basename $$@) ).cpp
+$(PLUGINS_OBJECTS) : $(PLUGINS_DIR)/$$(notdir $$(basename $$@) ).cpp
g++ $(CFLAGS) -c $< -o $@
-$(PLUGINS_OBJECTS_EXT) : $(PLUGINS_DIR_EXT)/$$(notdir $$(basename $$@) ).cpp
+$(COMMON_OBJECTS) : $(COMMON_DIR)/$$(notdir $$(basename $$@) ).cpp
g++ $(CFLAGS) -c $< -o $@
$(GUI_OBJECTS) : $(GUI_DIR)/$$(notdir $$(basename $$@) ).cpp
@@ -120,18 +117,18 @@
###########################################################################################
core_dir:
+ $(MKDIR) $(COMMON_OUTPUT)
$(MKDIR) $(CORE_OUTPUT)
core: core_dir $(CORE_TARGET)
-$(CORE_TARGET) : $(CORE_OBJECTS)
+$(CORE_TARGET) : $(COMMON_OBJECTS) $(CORE_OBJECTS)
ar rcs $@ $^
###########################################################################################
plugins_dir:
- $(MKDIR) $(PLUGINS_OUTPUT_BASE)
- $(MKDIR) $(PLUGINS_OUTPUT_EXT)
+ $(MKDIR) $(PLUGINS_OUTPUT)
plugins: plugins_dir $(PLUGINS_TARGET)
@@ -146,7 +143,7 @@
gui: gui_dir $(GUI_TARGET)
$(GUI_TARGET): $(GUI_OBJECTS) core plugins
- g++ $(CFLAGS) -o $@ $(GUI_OBJECTS) $(WX_LIBS) -L$(CORE_OUTPUT) -L$(PLUGINS_OUTPUT_BASE) -l$(CORE_LIB) -l$(PLUGINS_LIB)
+ g++ $(CFLAGS) -o $@ $(GUI_OBJECTS) $(WX_LIBS) -L$(CORE_OUTPUT) -L$(PLUGINS_OUTPUT) -l$(CORE_LIB) -l$(PLUGINS_LIB)
###########################################################################################
Added: scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.cpp (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,23 @@
+/////////////////////////////////////////////////////////////////////////////
+// CoreFileTypes.cpp
+
+#include "stdafx.h"
+
+#include "CoreFileTypes.h"
+
+#include "debugmem.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// FileTypes
+
+BGUID binaryFileType("CoreFileTypes", "Binary File", 1);
+
+BGUID bmpFileType("CoreFileTypes", "Windows Bitmap File (BMP)", 1);
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.h (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,24 @@
+/////////////////////////////////////////////////////////////////////////////
+// CoreFileTypes.h
+
+#ifndef _CORE_FILE_TYPES_H_
+#define _CORE_FILE_TYPES_H_
+
+#include "guid.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// FileTypes
+
+extern BGUID binaryFileType;
+
+extern BGUID bmpFileType;
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif // _CORE_FILE_TYPES_H_
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/core/CoreFileTypes.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.cpp (from rev 27876, scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.cpp)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.cpp (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,47 @@
+/////////////////////////////////////////////////////////////////////////////
+// CoreIntf.cpp
+
+#include "stdafx.h"
+
+#include "CoreIntf.h"
+
+#include <iostream>
+
+#include "debugmem.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Concrete implementations of the interfaces
+
+IStreamImpl::IStreamImpl(Common::SeekableReadStream* stream, bool ownStream /*= false*/)
+ : _stream(stream), _ownStream(ownStream) {}
+
+Common::SeekableReadStream* IStreamImpl::getStream() {
+ std::cout << "IStreamImpl::getStream()" << std::endl;
+ return _stream;
+}
+
+IStreamImpl::~IStreamImpl() {
+ if(_ownStream)
+ delete _stream;
+}
+
+
+IFileImpl::IFileImpl(std::string name, Common::SeekableReadStream* stream, bool ownStream /*= false*/)
+ : _streamImpl(stream,ownStream), _name(name) {}
+
+const std::string& IFileImpl::getName() {
+ std::cout << "IFileImpl::getName() = " << _name << std::endl;
+ return _name;
+}
+
+Common::SeekableReadStream* IFileImpl::getStream() {
+ return _streamImpl.getStream();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.h (from rev 27876, scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.h (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/CoreIntf.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,72 @@
+/////////////////////////////////////////////////////////////////////////////
+// CoreIntf.h
+
+#ifndef _CORE_INTERFACES_H_
+#define _CORE_INTERFACES_H_
+
+#include "pinslot.h"
+
+#include <list>
+#include "common/stream.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Interfaces
+
+class IStream : public IInterface {
+public:
+ 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;
+};
+
+class IDirectory : public IInterface {
+public:
+ GUID_FOR(IDirectory, "CoreInterfaces", 1);
+ virtual const std::list<IFile*>& getFiles() = 0;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Concrete implementations of the interfaces
+
+class IStreamImpl : public IStream {
+protected:
+ 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();
+};
+
+// Limitation: can't inherit from IFile and IStreamImpl, cause I'll have to inherit
+// virtually from IStream to IStreamImpl and from IStream to IFile. It can't be done,
+// since virtual inheritance disallows casting from virtual base class (here:
+// IInterface) to a derived class (here: IFile).
+// Instead of multiple inheritance - I use encapsulation: _streamImpl member.
+class IFileImpl : public IFile {
+protected:
+ 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();
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif // _CORE_INTERFACES_H_
Added: scummex/branches/gsoc2007-gameresbrowser/src/core/FileTypeRecognizer.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/FileTypeRecognizer.h (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/FileTypeRecognizer.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,190 @@
+/////////////////////////////////////////////////////////////////////////////
+// FileTypeRecognizer.h
+
+#ifndef _FILE_TYPE_RECOGNIZER_H_
+#define _FILE_TYPE_RECOGNIZER_H_
+
+#include "pinslot.h"
+
+#include "CoreIntf.h"
+#include "CoreFileTypes.h"
+
+#include <list>
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+// When a VirtualFile is to be presented the following happens:
+// - recognize() is run on all FileTypeRecognizers found
+// -- we get a list of file type GUID's
+// - we find all FileTypeParsers for each file type GUID and choose one of them
+
+// How the priorities work:
+// - FileTypeMatch can be IDEAL, GOOD or POOR, example:
+// BMP: BMPFileType - IDEAL,
+// BinaryFileType - POOR
+// - ResolvedParsersPriority can be IDEAL, GOOD or POOR, example:
+// BMPFileType: BMPParser + BMPInformationParser - IDEAL,
+// BinaryParser - POOR
+
+enum FileTypeMatch {
+ 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,
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+struct RecognizedFileType {
+ static RecognizedFileType NotRecognized;
+
+ 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;
+ }*/
+
+ bool isOk() {
+ return _match != NO_MATCH;
+ }
+ bool operator<(const RecognizedFileType& other) {
+ return this->_match < other._match;
+ }
+};
+
+typedef std::list<RecognizedFileType> RecognizedFileTypes;
+
+
+typedef std::list<const BGUID> guid_list;
+
+struct ResolvedFileTypeParsers {
+ static ResolvedFileTypeParsers NoParsers;
+
+ 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) {
+ return this->_priority < other._priority;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class VirtualFile;
+
+class FileTypeRecognizer {
+public:
+ virtual RecognizedFileType recognize(VirtualFile* file) = 0;
+};
+
+class FileTypeParserResolver {
+public:
+ virtual ResolvedFileTypeParsers resolve(const BGUID& fileType) = 0;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+//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)
+
+public:
+ ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
+
+ virtual RecognizedFileType recognize(VirtualFile* file);
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+//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)
+
+public:
+ ASSIGN_DESC(IS_FILE_TYPE_RESOLVER, "CoreObjects", 1)
+
+ virtual ResolvedFileTypeParsers resolve(const BGUID& fileType);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+//utility base class for FileTypeRecognizers
+class GenericFileTypeRecognizer : public BObject, public FileTypeRecognizer {
+ DECLARE_BOBJECT_CLASS(GenericFileTypeRecognizer, BObject)
+
+protected:
+ Slot<IFile>* _fileSlot;
+
+public:
+ ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
+
+ SLOT_DESCS
+ SLOT_DESC(_fileSlot, SLOT_DEFAULT)
+ END_DESCS
+
+ virtual RecognizedFileType recognize(VirtualFile* file);
+
+ //subclasses need to provide this method
+ virtual RecognizedFileType doRecognize(VirtualFile* file, IFile* ifile) = 0;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class BMPFileTypeRecognizer : public GenericFileTypeRecognizer {
+ DECLARE_BOBJECT_CLASS(BMPFileTypeRecognizer, BObject)
+
+public:
+ ASSIGN_DESC(IS_FILE_TYPE_RECOGNIZER, "CoreObjects", 1)
+
+ virtual RecognizedFileType doRecognize(VirtualFile* file, IFile* ifile);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class BMPFileTypeParserResolver : public BObject, public FileTypeParserResolver {
+ DECLARE_BOBJECT_CLASS(BMPFileTypeParserResolver, BObject)
+
+public:
+ ASSIGN_DESC(IS_FILE_TYPE_RESOLVER, "CoreObjects", 1)
+
+ virtual ResolvedFileTypeParsers resolve(const BGUID& fileType);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif // _FILE_TYPE_RECOGNIZER_H_
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/core/FileTypeRecognizer.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/common (from rev 27854, scummex/branches/gsoc2007-gameresbrowser/src/plugins/common)
Added: scummex/branches/gsoc2007-gameresbrowser/src/core/common/ReadMe.txt
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/common/ReadMe.txt (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/common/ReadMe.txt 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,12 @@
+
+Game Resource Browser
+----------------------
+
+common
+-------
+
+In this catalog there are files taken from scummvm/common, plus some other related files.
+They are heavilly modified, primarilly to reduce the dependencies.
+
+Classes defined here are *not* compatible with scummvm's classes, but they are *somewhat*
+compatible. This is to aid porting code between the Browser and scummvm.
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/core/common/ReadMe.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/scummsys.h 2007-07-02 13:52:33 UTC (rev 27854)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -21,6 +21,8 @@
*
*/
+//Modified for the Game Resource Browser
+
#ifndef COMMON_SCUMMSYS_H
#define COMMON_SCUMMSYS_H
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/common/stream.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/stream.h 2007-07-02 13:52:33 UTC (rev 27854)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/common/stream.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -20,6 +20,8 @@
*
*/
+//Modified for the Game Resource Browser
+
#ifndef COMMON_STREAM_H
#define COMMON_STREAM_H
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -1,49 +1,47 @@
/////////////////////////////////////////////////////////////////////////////
-// oregistry.h
+// ftregistry.h
//
-// Declares ObjectRegistry
-// One can load a plugin into ObjectRegistry.
-// (Maybe I'll do unloading too - later.)
+// Declares FileTypeRegistry
+// Plugins are registered into FileTypeRegistry by ObjectRegistry.
//
#pragma once
-#ifndef ZZ_FILE_TYPE_REGISTRY_H
-#define ZZ_FILE_TYPE_REGISTRY_H
+#ifndef _FILE_TYPE_REGISTRY_H_
+#define _FILE_TYPE_REGISTRY_H_
#include "plugin.h"
+#include "FileTypeRecognizer.h"
+
+#include <list>
+
namespace Browser {
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// The FileTypeRegistry
+class VirtualFile;
+
class FileTypeRegistry {
public:
- /*
- //CAUTION: the Plugin::ObjectPlugins map is keyed with the plugins GUID, not
- // it's object's GUID.
- //CAUTION: the ObjectMap map is keyed with the object's GUID, not
- // it's plugin's GUID.
- typedef Plugin::ObjectPlugins ObjectPlugins;
- typedef std::map<const BGUID, const ObjectPlugin*> ObjectMap;
- ObjectMap objectMap;
+ typedef std::list< RCPtr<BObject> > object_list;
+ object_list _recognizers;
+ object_list _resolvers;
- typedef const Plugin& (*PluginAccessor)();
+ void registerRecognizerPlugin(const ObjectPlugin* oplugin);
- //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);
- const ObjectPlugin* findObjectPlugin(const BGUID& guid);
- RCPtr<BObject> getObject(const BGUID& guid);
+ void registerResolverPlugin(const ObjectPlugin* oplugin);
- template<typename T>
- RCPtr<T> getObject() {
- RCPtr<BObject> obj( getObject(T::static_GUID()) );
- return static_cast<T*>(obj.get());
- }
- */
+ //return properly sorted list of fileTypes
+ RecognizedFileTypes recognizeFileType(VirtualFile* file);
+
+ guid_list resolveParsers(VirtualFile* file);
+
+ ResolvedFileTypeParsers resolveParsers(const BGUID& fileType);
+
+ static FileTypeRegistry* get();
+
};
/////////////////////////////////////////////////////////////////////////////
@@ -51,4 +49,4 @@
} // namespace Browser
-#endif /* ZZ_FILE_TYPE_REGISTRY_H */
+#endif /* _FILE_TYPE_REGISTRY_H_ */
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -20,48 +20,50 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
- BGUID::BGUID(std::string _facility, std::string _identifier, int _version)
- : facility(_facility), identifier(_identifier), version(_version) {}
+BGUID BGUID::Unknown("Unknown Facility", "Unknown GUID", 1);
- bool BGUID::operator==(const BGUID& other) const {
- return facility == other.facility &&
- identifier == other.identifier &&
- version == other.version;
- }
+BGUID::BGUID(std::string _facility, std::string _identifier, int _version)
+ : facility(_facility), identifier(_identifier), version(_version) {}
- bool BGUID::operator!=(const BGUID& other) const {
- return !(*this == other);
- }
+bool BGUID::operator==(const BGUID& other) const {
+ return facility == other.facility &&
+ identifier == other.identifier &&
+ 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;
- }
+bool BGUID::operator!=(const BGUID& other) const {
+ 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;
- }
+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;
+}
- /*
- 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;
- }*/
+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;
+}
- std::ostream& operator<<(std::ostream& os, const BGUID& guid) {
- return os << "BGUID(" << guid.facility << ", " << guid.identifier << ", "
- << guid.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;
+}*/
+std::ostream& operator<<(std::ostream& os, const BGUID& guid) {
+ 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-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -24,6 +24,8 @@
/////////////////////////////////////////////////////////////////////////////
struct BGUID {
+ static BGUID Unknown;
+
std::string facility;
std::string identifier;
int version;
@@ -34,8 +36,8 @@
bool operator<(const BGUID& other) const;
bool operator>(const BGUID& other) const;
-private:
- BGUID& operator=(const BGUID& other); //don't assign
+//private:
+ //BGUID& operator=(const BGUID& other); //don't assign
};
std::ostream& operator<<(std::ostream& os, const BGUID& guid);
@@ -60,8 +62,8 @@
#define GUID_FOR(clazz, facility, version) \
ASSIGN_GUID_VERBOSE(#clazz, facility, version)
-#define ASSIGN_GUID(facility, version) \
- ASSIGN_GUID_VERBOSE(typeid(this_class).name(), facility, version)
+//#define ASSIGN_GUID(facility, version) \
+// ASSIGN_GUID_VERBOSE(typeid(this_class).name(), facility, version)
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -7,6 +7,7 @@
#include "stdafx.h"
#include "oregistry.h"
+#include "ftregistry.h"
#include "debugmem.h"
@@ -41,12 +42,19 @@
i = _pluginsMap.find(oguid);
if (i != _pluginsMap.end()) {
res = false;
- if(overwrite)
- i->second = oplug;
- continue;
+ if(!overwrite)
+ continue;
+ i->second = oplug;
+ } else {
+ _pluginsMap.insert( std::make_pair(oguid, oplug) );
}
- _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);
}
//TODO: make this thing below better
@@ -65,6 +73,12 @@
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;
+
PinSlotDescs::const_iterator i;
const PinSlotDescs& pins = objectPlugin->get_pins();
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -7,11 +7,12 @@
//
#pragma once
-#ifndef ZZ_OBJECT_REGISTRY_H
-#define ZZ_OBJECT_REGISTRY_H
+#ifndef _OBJECT_REGISTRY_H_
+#define _OBJECT_REGISTRY_H_
#include "plugin.h"
+#include <map>
#include <list>
namespace Browser {
@@ -78,4 +79,4 @@
} // namespace Browser
-#endif /* ZZ_OBJECT_REGISTRY_H */
+#endif /* _OBJECT_REGISTRY_H_ */
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -21,7 +21,7 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-//CAUTION: Flags (besides IS_PIN and IS_SLOT) are *only* hints for the automatic
+//CAUTION: Flags (besides IS_PIN and IS_SLOT) are only *hints* for the automatic
// pin/slot connecting in the ObjectChain.
// I.e. you can't rely on a singlecast pin to be connected to only once.
enum {
@@ -32,6 +32,16 @@
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
+};
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Interface
@@ -299,6 +309,39 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+
+struct BObjectDesc {
+ const BGUID _objectGUID;
+ int _flags;
+ std::string _name;
+ const PinSlotDescs& _pinDescs;
+ const PinSlotDescs& _slotDescs;
+
+ BObjectDesc(std::string name, const BGUID& objectGUID, int flags,
+ const PinSlotDescs& pinDescs, const PinSlotDescs& slotDescs)
+ : _name(name), _objectGUID(objectGUID), _flags(flags),
+ _pinDescs(pinDescs), _slotDescs(slotDescs)
+ {}
+
+ int get_flags() const {
+ return _flags;
+ }
+ const std::string& get_name() const {
+ return _name;
+ }
+ const BGUID& get_GUID() const {
+ return _objectGUID;
+ }
+ const PinSlotDescs& get_pins() const {
+ return _pinDescs;
+ }
+ const PinSlotDescs& get_slots() const {
+ return _slotDescs;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
// BObject is a reference counted object that is capable of holding pins and slots.
class ObjectChain;
@@ -370,17 +413,29 @@
public:
- virtual const PinSlotDescs& get_pins() const {
- return BObject::static_pins();
+ virtual const BObjectDesc& get_desc() const = 0;
+ /*GUID_FOR(BObject, "CoreObjects", 1)
+ virtual const BObjectDesc& get_desc() const {
+ return BObject::static_desc();
}
+ static const BObjectDesc& static_desc() {
+ static BObjectDesc desc("BObject", BObject::static_GUID(), 0,
+ BObject::static_pins(), BObject::static_slots());
+ return desc;
+ }*/
+
+ /*virtual*/ const PinSlotDescs& get_pins() const {
+ return this->get_desc().get_pins();
+ }
+ /*virtual*/ const PinSlotDescs& get_slots() const {
+ return this->get_desc().get_slots();
+ }
+
static const PinSlotDescs& static_pins() {
static PinSlotDescs descs;
return descs;
}
- virtual const PinSlotDescs& get_slots() const {
- return BObject::static_slots();
- }
static const PinSlotDescs& static_slots() {
static PinSlotDescs descs;
return descs;
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot_detail.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot_detail.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot_detail.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -19,10 +19,18 @@
#define DECLARE_BOBJECT_CLASS(clazz, super) \
private: \
typedef clazz this_class; \
- typedef super super_class;
+ typedef super super_class; \
+ static const char* _this_class_name() { \
+ return #clazz; \
+ } \
+ static const char* _super_class_name() { \
+ return #super; \
+ }
-#define THIS_CLASS_NAME (typeid(this_class).name())
-#define SUPER_CLASS_NAME (typeid(super_class).name())
+#define THIS_CLASS_NAME (_this_class_name())
+#define SUPER_CLASS_NAME (_super_class_name())
+//#define THIS_CLASS_NAME (typeid(this_class).name())
+//#define SUPER_CLASS_NAME (typeid(super_class).name())
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -34,18 +42,23 @@
// the class, and dynamic construction of those pins and slots.
// It's also in this shape so that it can be as user friendly as possible.
+#define ASSIGN_DESC(flags, facility, version) \
+ ASSIGN_GUID_VERBOSE(THIS_CLASS_NAME, facility, version) \
+ virtual const BObjectDesc& get_desc() const { \
+ return this_class::static_desc(); \
+ } \
+ static const BObjectDesc& static_desc() { \
+ static BObjectDesc desc(THIS_CLASS_NAME, this_class::static_GUID(), flags, \
+ this_class::static_pins(), this_class::static_slots()); \
+ return desc; \
+ }
+
//separate definition and implementation
#define PINS_DECL \
- virtual const PinSlotDescs& get_pins() const { \
- return this_class::static_pins(); \
- } \
static const PinSlotDescs& static_pins();
#define SLOTS_DECL \
- virtual const PinSlotDescs& get_slots() const { \
- return this_class::static_slots(); \
- } \
static const PinSlotDescs& static_slots();
@@ -62,17 +75,11 @@
//inline definitions in the class
#define PIN_DESCS \
- virtual const PinSlotDescs& get_pins() const { \
- return this_class::static_pins(); \
- } \
static const PinSlotDescs& static_pins() { \
static PinSlotDescs descs( \
PinSlotDescs(true).insert_copy(super_class::static_pins())
#define SLOT_DESCS \
- virtual const PinSlotDescs& get_slots() const { \
- return this_class::static_slots(); \
- } \
static const PinSlotDescs& static_slots() { \
static PinSlotDescs descs( \
PinSlotDescs(true).insert_copy(super_class::static_pins())
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/plugin.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/plugin.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/plugin.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -35,14 +35,22 @@
class ObjectPlugin : public GUIDObject {
public:
- virtual const BGUID& getObjectGUID() const = 0;
+ virtual const BObjectDesc& get_desc() const = 0;
- virtual const PinSlotDescs& get_pins() const = 0;
- virtual const PinSlotDescs& get_slots() const = 0;
-
virtual RCPtr<BObject> newInstance() const = 0;
virtual ~ObjectPlugin() {}
+
+ /*virtual*/ const BGUID& getObjectGUID() const {
+ return this->get_desc().get_GUID();
+ }
+ /*virtual*/ const PinSlotDescs& get_pins() const {
+ return this->get_desc().get_pins();
+ }
+ /*virtual*/ const PinSlotDescs& get_slots() const {
+ return this->get_desc().get_slots();
+ }
+
};
template<typename T>
@@ -52,17 +60,10 @@
ASSIGN_GUID_VERBOSE( (std::string("ObjectPluginImpl<") + typeid(T).name() + ">"),
"ObjectPlugins", 1)
- virtual const BGUID& getObjectGUID() const {
- return T::static_GUID();
+ virtual const BObjectDesc& get_desc() const {
+ return T::static_desc();
}
- virtual const PinSlotDescs& get_pins() const {
- return T::static_pins();
- }
- virtual const PinSlotDescs& get_slots() const {
- return T::static_slots();
- }
-
virtual RCPtr<BObject> newInstance() const {
return RCPtr<BObject>(new T());
}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.cpp 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -10,7 +10,9 @@
#include "DirectoryPresenter.h"
#include "ExplorationTree.h"
#include "VirtualNode.h"
-#include "FilePresenter.h"
+//#include "FilePresenter.h"
+#include "oregistry.h"
+#include "ftregistry.h"
#include <iostream>
@@ -97,9 +99,31 @@
ExplorationTree::_getTree()->SetItemData(kidTreeItem,
new VirtualNodeItemData( virtualFile.get() ) );
+ //Here we try to figure the fileType and the best parsers for it:
+
+ guid_list parsers = FileTypeRegistry::get()->resolveParsers( virtualFile.get() );
+
+ //Ok, we've got the best parsers, so create a dedicated ObjectChain:
+
ObjectChain* kidchain = new ObjectChain();
- if ( !kidchain->addObject(virtualFile) ) {
+ bool addingOk = true;
+
+ addingOk &= kidchain->addObject(virtualFile);
+
+ guid_list::iterator i;
+ for (i = parsers.begin(); i != parsers.end(); ++i) {
+ if (!addingOk)
+ break;
+ RCPtr<BObject> parser = ObjectRegistry::get()->getObject( *i );
+ if (parser.get() == NULL) {
+ addingOk = false;
+ break;
+ }
+ addingOk &= kidchain->addObject( parser );
+ }
+
+ if (!addingOk) {
ASSERT(false); //failure here virtually impossible
delete kidchain;
//virtualFile is deleted automatically
@@ -109,6 +133,7 @@
_kidChains.push_back( kidchain );
}
+ //now realize those chains:
if (!realizeKidChains()) {
deleteKidChains();
std::cout << "ERROR: DirectoryPresenter::expand(): can't realize kids." << std::endl;
@@ -132,9 +157,9 @@
ObjectChain* kidchain = *i;
kidchain->complete();
- RCPtr<FilePresenter> fpres(new FilePresenter());
+ /*RCPtr<FilePresenter> fpres(new FilePresenter());
kidchain->addObject(fpres);
- kidchain->complete();
+ kidchain->complete();*/
res &= kidchain->realize();
}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -31,7 +31,7 @@
bool _expanded;
public:
- ASSIGN_GUID("CoreObjects", 1)
+ ASSIGN_DESC(0,"CoreObjects", 1)
SLOTS_DECL
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/FilePresenter.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/FilePresenter.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/FilePresenter.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -25,7 +25,7 @@
wxPanel* _bmpPanel;
public:
- ASSIGN_GUID("CoreObjects", 1)
+ ASSIGN_DESC(0,"CoreObjects", 1)
PINS_DECL
SLOTS_DECL
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -25,7 +25,7 @@
wxPanel* _bmpPanel;
public:
- ASSIGN_GUID("CoreObjects", 1)
+ ASSIGN_DESC(0,"CoreObjects", 1)
PINS_DECL
SLOTS_DECL
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/PanelProvider.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/PanelProvider.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/PanelProvider.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -69,7 +69,7 @@
IPanelReciever* _ipanelreciever;
INodeProvider* _inodeprovider;
public:
- ASSIGN_GUID("CoreObjects", 1)
+ ASSIGN_DESC(0,"CoreObjects", 1)
SLOTS_DECL
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -8,6 +8,8 @@
#endif
#include "VirtualNode.h"
+
+#include "ExplorationTree.h"
#include "common/simplefile.h"
#include <iostream>
@@ -19,6 +21,22 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+VirtualNodeItemData::VirtualNodeItemData(VirtualNode* node)
+ : _node(node) {}
+
+/*static*/ VirtualNode* VirtualNodeItemData::getNode(const wxTreeItemId& item) {
+ if (!item.IsOk())
+ return NULL;
+ VirtualNodeItemData* data = static_cast<VirtualNodeItemData*>
+ (ExplorationTree::_getTree()->GetItemData(item));
+ if (!data)
+ return NULL;
+ return data->_node;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
class INodeProviderImpl : public INodeProvider {
protected:
VirtualNode* _node;
Deleted: scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -1,161 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// VirtualNode.h
-
-#ifndef _VIRTUAL_NODE_H_
-#define _VIRTUAL_NODE_H_
-
-#include "pinslot.h"
-
-#include "CoreIntf.h"
-#include "ExplorationTree.h"
-
-#include <list>
-
-namespace Browser {
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-class VirtualNode;
-
-struct VirtualNodeItemData : public wxTreeItemData {
- VirtualNode* _node;
-
- VirtualNodeItemData(VirtualNode* node)
- : _node(node) {}
-
- //virtual ~VirtualNodeItemData() {}
-
- static VirtualNode* getNode(const wxTreeItemId& item) {
- if (!item.IsOk())
- return NULL;
- VirtualNodeItemData* data = static_cast<VirtualNodeItemData*>
- (ExplorationTree::_getTree()->GetItemData(item));
- if (!data)
- return NULL;
- return data->_node;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-class INodeProvider : public IInterface {
-public:
- GUID_FOR(INodeProvider, "CoreInterfaces", 1);
- virtual VirtualNode* getNode() = 0;
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-class INodeProviderImpl;
-
-//TODO: make it realizable in multiple chains
-class VirtualNode : public BObject {
- DECLARE_BOBJECT_CLASS(VirtualNode, BObject)
-
- //std::string _name;
- wxTreeItemId _mineTreeItem;
-
-protected:
- Pin<INodeProvider>* _nodePin;
-
- VirtualNode() {}
-public:
- ASSIGN_GUID("CoreObjects", 1)
-
- PINS_DECL
-
- VirtualNode(wxTreeItemId mineTreeItem)
- : _mineTreeItem(mineTreeItem) {}
-
- /*const std::string& getName() {
- return _name;
- }*/
-
- wxTreeItemId getTreeItem() {
- return _mineTreeItem;
- }
-
- void setTreeItem(wxTreeItemId mineTreeItem) {
- _mineTreeItem = mineTreeItem;
- }
-
- VirtualNode* getParent();
-
- INodeProviderImpl* getNodeProviderImpl();
- void releaseNodeProviderImpl(INodeProviderImpl* iface);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-//this class defines an object that can deliver given IFile interface
-class VirtualFile : public VirtualNode {
- DECLARE_BOBJECT_CLASS(VirtualFile, VirtualNode)
-
-protected:
- Pin<IFile>* _filePin;
-
- int _taken;
- IFile* _ifile;
-
-public:
- ASSIGN_GUID("CoreObjects", 1)
-
- PIN_DESCS
- PIN_DESC(_filePin, PIN_DEFAULT | PIN_MULTICAST, getFile, releaseFile)
- END_DESCS
-
- VirtualFile(wxTreeItemId mineTreeItem, IFile* ifile)
- : VirtualNode(mineTreeItem), _taken(0), _ifile(ifile) {}
-
- IFile* getFile() {
- _taken++;
- return _ifile;
- }
- void releaseFile(IFile* iface) {
- _taken--;
- }
-
- bool isTaken() {
- return _taken > 0;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-class IDirectoryImpl;
-
-class RootDirectory : public VirtualNode {
- DECLARE_BOBJECT_CLASS(RootDirectory, VirtualNode)
-
-protected:
- Pin<IDirectory>* _directoryPin;
-
- typedef std::list< std::pair< std::string, std::string > > file_list;
- file_list _files;
-
-public:
- ASSIGN_GUID("CoreObjects", 1)
-
- PINS_DECL
-
- RootDirectory(wxTreeItemId mineTreeItem)
- : VirtualNode(mineTreeItem) {}
-
- bool addFile(std::string name, std::string fullpath);
-
- IDirectoryImpl* getDirectoryImpl();
- void releaseDirectoryImpl(IDirectoryImpl* iface);
-
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-}
-
-#endif //_VIRTUAL_NODE_H_
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/BMPParser.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/BMPParser.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/BMPParser.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -22,7 +22,7 @@
Pin<IImage>* _imagePin;
public:
- ASSIGN_GUID("CoreObjects", 1)
+ ASSIGN_DESC(0,"CoreObjects", 1)
PINS_DECL
SLOTS_DECL
Deleted: scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.cpp 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -1,47 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// CoreIntf.cpp
-
-#include "stdafx.h"
-
-#include "CoreIntf.h"
-
-#include <iostream>
-
-#include "debugmem.h"
-
-namespace Browser {
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Concrete implementations of the interfaces
-
-IStreamImpl::IStreamImpl(Common::SeekableReadStream* stream, bool ownStream /*= false*/)
- : _stream(stream), _ownStream(ownStream) {}
-
-Common::SeekableReadStream* IStreamImpl::getStream() {
- std::cout << "IStreamImpl::getStream()" << std::endl;
- return _stream;
-}
-
-IStreamImpl::~IStreamImpl() {
- if(_ownStream)
- delete _stream;
-}
-
-
-IFileImpl::IFileImpl(std::string name, Common::SeekableReadStream* stream, bool ownStream /*= false*/)
- : _streamImpl(stream,ownStream), _name(name) {}
-
-const std::string& IFileImpl::getName() {
- std::cout << "IFileImpl::getName() = " << _name << std::endl;
- return _name;
-}
-
-Common::SeekableReadStream* IFileImpl::getStream() {
- return _streamImpl.getStream();
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-} // namespace Browser
Deleted: scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/CoreIntf.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -1,72 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// CoreIntf.h
-
-#ifndef _CORE_INTERFACES_H_
-#define _CORE_INTERFACES_H_
-
-#include "pinslot.h"
-
-#include <list>
-#include "common/stream.h"
-
-namespace Browser {
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Interfaces
-
-class IStream : public IInterface {
-public:
- 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;
-};
-
-class IDirectory : public IInterface {
-public:
- GUID_FOR(IDirectory, "CoreInterfaces", 1);
- virtual const std::list<IFile*>& getFiles() = 0;
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Concrete implementations of the interfaces
-
-class IStreamImpl : public IStream {
-protected:
- 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();
-};
-
-// Limitation: can't inherit from IFile and IStreamImpl, cause I'll have to inherit
-// virtually from IStream to IStreamImpl and from IStream to IFile. It can't be done,
-// since virtual inheritance disallows casting from virtual base class (here:
-// IInterface) to a derived class (here: IFile).
-// Instead of multiple inheritance - I use encapsulation: _streamImpl member.
-class IFileImpl : public IFile {
-protected:
- 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();
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-} // namespace Browser
-
-#endif // _CORE_INTERFACES_H_
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/DiskFileProvider.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/DiskFileProvider.h 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/DiskFileProvider.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -22,7 +22,7 @@
std::string _diskFileName;
public:
- ASSIGN_GUID("CoreObjects", 1)
+ ASSIGN_DESC(0,"CoreObjects", 1)
PINS_DECL
Added: scummex/branches/gsoc2007-gameresbrowser/src/plugins/FileTypeRecognizer.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/FileTypeRecognizer.cpp (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/FileTypeRecognizer.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,106 @@
+/////////////////////////////////////////////////////////////////////////////
+// FileTypeRecognizer.cpp
+
+#include "stdafx.h"
+
+#include "FileTypeRecognizer.h"
+
+#include "VirtualNode.h"
+#include "ochain.h"
+
+#include "debugmem.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Static fields
+
+RecognizedFileType RecognizedFileType::NotRecognized(NO_MATCH, BGUID::Unknown);
+
+guid_list _empty_guid_list;
+ResolvedFileTypeParsers ResolvedFileTypeParsers::NoParsers(NO_PARSERS, _empty_guid_list);
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+RecognizedFileType BinaryFileTypeRecognizer::recognize(VirtualFile* file) {
+ return RecognizedFileType(POOR_MATCH, binaryFileType);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+ResolvedFileTypeParsers BinaryFileTypeParserResolver::resolve(const BGUID& fileType) {
+ guid_list parsers;
+ if(fileType != binaryFileType)
+ return ResolvedFileTypeParsers::NoParsers;
+
+ //FIXME: this is temporary
+ static BGUID filePresenterGUID("CoreObjects", "FilePresenter", 1);
+ parsers.push_back(filePresenterGUID);
+
+ return ResolvedFileTypeParsers(IDEAL_PARSERS, parsers);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+RecognizedFileType GenericFileTypeRecognizer::recognize(VirtualFile* file) {
+ RCPtr<BObject> _file(file);
+ RCPtr<BObject> _this(this);
+
+ ObjectChain chain; //it will be automatically unrealized
+ chain.addObject( _file );
+ chain.addObject( _this );
+ chain.connect(_file, _this, IFile::static_GUID());
+ if (!chain.realize())
+ return RecognizedFileType::NotRecognized;
+
+ IFile* ifile = _fileSlot->getInterface();
+ if(!ifile)
+ return RecognizedFileType::NotRecognized;
+
+ RecognizedFileType recognized = doRecognize(file, ifile);
+
+ _fileSlot->releaseInterface();
+
+ return recognized;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+RecognizedFileType BMPFileTypeRecognizer::doRecognize(VirtualFile* file, IFile* ifile) {
+ Common::SeekableReadStream* stream = ifile->getStream();
+ stream->seek(0, SEEK_SET);
+ byte b = stream->readByte();
+ byte m = stream->readByte();
+
+ if ( b != 'B' || m != 'M' )
+ return RecognizedFileType::NotRecognized;
+
+ return RecognizedFileType(IDEAL_MATCH, bmpFileType);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+ResolvedFileTypeParsers BMPFileTypeParserResolver::resolve(const BGUID& fileType) {
+ guid_list parsers;
+ if(fileType != bmpFileType)
+ return ResolvedFileTypeParsers(NO_PARSERS, parsers);
+
+ //FIXME: this is temporary
+ static BGUID bmpParserGUID("CoreObjects", "BMPParser", 1);
+ parsers.push_back(bmpParserGUID);
+ static BGUID filePresenterGUID("CoreObjects", "FilePresenter", 1);
+ parsers.push_back(filePresenterGUID);
+
+ return ResolvedFileTypeParsers(IDEAL_PARSERS, parsers);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/plugins/FileTypeRecognizer.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h (from rev 27876, scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,154 @@
+/////////////////////////////////////////////////////////////////////////////
+// VirtualNode.h
+
+#ifndef _VIRTUAL_NODE_H_
+#define _VIRTUAL_NODE_H_
+
+#include "pinslot.h"
+
+#include "CoreIntf.h"
+
+#include <wx/treectrl.h> //for wxTreeItemId
+
+#include <list>
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class VirtualNode;
+
+struct VirtualNodeItemData : public wxTreeItemData {
+ VirtualNode* _node;
+
+ VirtualNodeItemData(VirtualNode* node);
+ //virtual ~VirtualNodeItemData() {}
+
+ static VirtualNode* getNode(const wxTreeItemId& item);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class INodeProvider : public IInterface {
+public:
+ GUID_FOR(INodeProvider, "CoreInterfaces", 1);
+ virtual VirtualNode* getNode() = 0;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class INodeProviderImpl;
+
+//TODO: make it realizable in multiple chains
+class VirtualNode : public BObject {
+ DECLARE_BOBJECT_CLASS(VirtualNode, BObject)
+
+ //std::string _name;
+ wxTreeItemId _mineTreeItem;
+
+protected:
+ Pin<INodeProvider>* _nodePin;
+
+ VirtualNode() {}
+public:
+ ASSIGN_DESC(0,"CoreObjects", 1)
+
+ PINS_DECL
+
+ VirtualNode(wxTreeItemId mineTreeItem)
+ : _mineTreeItem(mineTreeItem) {}
+
+ /*const std::string& getName() {
+ return _name;
+ }*/
+
+ wxTreeItemId getTreeItem() {
+ return _mineTreeItem;
+ }
+
+ void setTreeItem(wxTreeItemId mineTreeItem) {
+ _mineTreeItem = mineTreeItem;
+ }
+
+ VirtualNode* getParent();
+
+ INodeProviderImpl* getNodeProviderImpl();
+ void releaseNodeProviderImpl(INodeProviderImpl* iface);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+//this class defines an object that can deliver given IFile interface
+class VirtualFile : public VirtualNode {
+ DECLARE_BOBJECT_CLASS(VirtualFile, VirtualNode)
+
+protected:
+ Pin<IFile>* _filePin;
+ Pin<IStream>* _streamPin;
+
+ int _taken;
+ IFile* _ifile;
+
+public:
+ ASSIGN_DESC(0,"CoreObjects", 1)
+
+ PIN_DESCS
+ PIN_DESC(_filePin, PIN_DEFAULT | PIN_MULTICAST, getFile, releaseFile)
+ PIN_DESC(_streamPin, PIN_DEFAULT | PIN_MULTICAST, getFile, releaseFile)
+ END_DESCS
+
+ VirtualFile(wxTreeItemId mineTreeItem, IFile* ifile)
+ : VirtualNode(mineTreeItem), _taken(0), _ifile(ifile) {}
+
+ IFile* getFile() {
+ _taken++;
+ return _ifile;
+ }
+ void releaseFile(IFile* iface) {
+ _taken--;
+ }
+
+ bool isTaken() {
+ return _taken > 0;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class IDirectoryImpl;
+
+class RootDirectory : public VirtualNode {
+ DECLARE_BOBJECT_CLASS(RootDirectory, VirtualNode)
+
+protected:
+ Pin<IDirectory>* _directoryPin;
+
+ typedef std::list< std::pair< std::string, std::string > > file_list;
+ file_list _files;
+
+public:
+ ASSIGN_DESC(0,"CoreObjects", 1)
+
+ PINS_DECL
+
+ RootDirectory(wxTreeItemId mineTreeItem)
+ : VirtualNode(mineTreeItem) {}
+
+ bool addFile(std::string name, std::string fullpath);
+
+ IDirectoryImpl* getDirectoryImpl();
+ void releaseDirectoryImpl(IDirectoryImpl* iface);
+
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+}
+
+#endif //_VIRTUAL_NODE_H_
Added: scummex/branches/gsoc2007-gameresbrowser/src/plugins/ftregistry.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/ftregistry.cpp (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/ftregistry.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -0,0 +1,98 @@
+/////////////////////////////////////////////////////////////////////////////
+// ftregistry.cpp
+//
+// Declares FileTypeRegistry
+// Plugins are registered into FileTypeRegistry by ObjectRegistry.
+//
+
+#include "stdafx.h"
+
+#include "ftregistry.h"
+
+#include <algorithm>
+#include <vector>
+
+#include "debugmem.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// The FileTypeRegistry
+
+void FileTypeRegistry::registerRecognizerPlugin(const ObjectPlugin* oplugin) {
+ RCPtr<BObject> recognizer( oplugin->newInstance() );
+ _recognizers.push_back(recognizer);
+}
+
+void FileTypeRegistry::registerResolverPlugin(const ObjectPlugin* oplugin) {
+ RCPtr<BObject> resolver( oplugin->newInstance() );
+ _resolvers.push_back(resolver);
+}
+
+//return properly sorted list of fileTypes
+RecognizedFileTypes FileTypeRegistry::recognizeFileType(VirtualFile* file) {
+ RecognizedFileTypes fileTypes;
+
+ object_list::iterator i;
+ for (i = _recognizers.begin(); i != _recognizers.end(); ++i) {
+ BObject* obj = (*i).get();
+ FileTypeRecognizer* recognizer = dynamic_cast<FileTypeRecognizer*>(obj);
+ RecognizedFileType fileType = recognizer->recognize(file);
+ if (fileType.isOk())
+ fileTypes.push_back( fileType );
+ }
+
+ //FIXME: VC++'s STL can't sort std::list - Ughhh...
+ std::vector<RecognizedFileType> types( fileTypes.begin(), fileTypes.end() );
+ std::sort( types.begin(), types.end() );
+ RecognizedFileTypes outTypes( types.begin(), types.end() );
+
+ return outTypes;
+}
+
+guid_list FileTypeRegistry::resolveParsers(VirtualFile* file) {
+ RecognizedFileTypes fileTypes( recognizeFileType(file) );
+
+ RecognizedFileTypes::iterator i;
+ for (i = fileTypes.begin(); i != fileTypes.end(); ++i) {
+ BGUID fileType = i->_fileTypeGUID;
+
+ ResolvedFileTypeParsers parsers( resolveParsers(fileType) );
+ if (parsers.isOk())
+ return parsers._parserGUIDs;
+ }
+
+ return guid_list();
+}
+
+ResolvedFileTypeParsers FileTypeRegistry::resolveParsers(const BGUID& fileType) {
+ ResolvedFileTypeParsers bestParsers(ResolvedFileTypeParsers::NoParsers);
+
+ object_list::iterator i;
+ for (i = _recognizers.begin(); i != _recognizers.end(); ++i) {
+ BObject* obj = (*i).get();
+ FileTypeParserResolver* resolver = dynamic_cast<FileTypeParserResolver*>(obj);
+ ResolvedFileTypeParsers parsers = resolver->resolve(fileType);
+ if (parsers.isOk()) {
+ if (!bestParsers.isOk())
+ bestParsers = parsers;
+ if (parsers < bestParsers)
+ bestParsers = parsers;
+ if (bestParsers._priority == IDEAL_PARSERS)
+ return bestParsers;
+ }
+ }
+
+ return bestParsers;
+}
+
+/*static*/ FileTypeRegistry* FileTypeRegistry::get() {
+ static FileTypeRegistry instance;
+ return &instance;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/plugins/ftregistry.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_plugins.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_plugins.cpp 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_plugins.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -108,7 +108,7 @@
Pin<IFile>* filePin;
public:
- ASSIGN_GUID("MyObjects", 1)
+ ASSIGN_DESC(0,"MyObjects", 1)
IFileImpl* getFileImpl() {
std::cout << "FileProvider::getFileImpl()" << std::endl;
@@ -133,7 +133,7 @@
Pin<IBitmap>* bitmapPin;
public:
- ASSIGN_GUID("MyObjects", 1)
+ ASSIGN_DESC(0,"MyObjects", 1)
IBitmapImpl* getBitmapImpl() {
std::cout << "BMPFileType::getBitmapImpl()" << std::endl;
@@ -166,7 +166,7 @@
Slot<IBitmap>* bitmapSlot;
public:
- ASSIGN_GUID("Generic", 1)
+ ASSIGN_DESC(0,"Generic", 1)
SLOT_DESCS
SLOT_DESC(bitmapSlot, SLOT_DEFAULT)
END_DESCS
Modified: scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_verbose.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_verbose.cpp 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_verbose.cpp 2007-07-03 16:58:16 UTC (rev 27883)
@@ -2,6 +2,7 @@
// pinslot_verbose.cpp
//
// Shows how setting up pins and slots works.
+// (It is a bit outdated at the moment... But only a bit.)
//
#include "stdafx.h"
Modified: scummex/branches/gsoc2007-gameresbrowser/vc8/core/ReadMe.txt
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/vc8/core/ReadMe.txt 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/vc8/core/ReadMe.txt 2007-07-03 16:58:16 UTC (rev 27883)
@@ -2,163 +2,21 @@
STATIC LIBRARY : core Project Overview
========================================================================
+Library with core objects for the Game Resource Browser.
+
+
Guidelines:
+
When passing an BObject, pass: const RCPtr<BObject>&
When returning an BObject, return: RCPtr<BObject>
+
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
-AppWizard has created this core library project for you.
-
-This file contains a summary of what you will find in each of the files that
-make up your core application.
-
-
-core.vcproj
- This is the main project file for VC++ projects generated using an Application Wizard.
- It contains information about the version of Visual C++ that generated the file, and
- information about the platforms, configurations, and project features selected with the
- Application Wizard.
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-StdAfx.h, StdAfx.cpp
- These files are used to build a precompiled header (PCH) file
- named core.pch and a precompiled types file named StdAfx.obj.
-
-/////////////////////////////////////////////////////////////////////////////
-Other notes:
-
-AppWizard uses "TODO:" comments to indicate parts of the source code you
-should add to or customize.
-
-/////////////////////////////////////////////////////////////////////////////
-
-
-Listing 3: test.cpp -- Demonstrating console redirection
-
-#include <windows.h>
-
-#include <iostream>
-
-#include <fstream>
-
-#include <conio.h>
-
-#include <stdio.h>
-
-#ifndef _USE_OLD_OSTREAMS
-
-using namespace std;
-
-#endif
-
-#include "guicon.h"
-
-
-
-
-
-#include <crtdbg.h>
-
-
-
-int APIENTRY WinMain(HINSTANCE hInstance,
-
-HINSTANCE hPrevInstance,
-
-LPTSTR lpCmdLine,
-
-int nCmdShow)
-
-{
-
-#ifdef _DEBUG
-
-RedirectIOToConsole();
-
-#endif
-
-int iVar;
-
-// test stdio
-
-fprintf(stdout, "Test output to stdout\n");
-
-fprintf(stderr, "Test output to stderr\n");
-
-fprintf(stdout, "Enter an integer to test stdin: ");
-
-scanf("%d", &iVar);
-
-printf("You entered %d\n", iVar);
-
-//test iostreams
-
-cout << "Test output to cout" << endl;
-
-cerr << "Test output to cerr" << endl;
-
-clog << "Test output to clog" << endl;
-
-cout << "Enter an integer to test cin: ";
-
-cin >> iVar;
-
-cout << "You entered " << iVar << endl;
-
-#ifndef _USE_OLD_IOSTREAMS
-
-// test wide iostreams
-
-wcout << L"Test output to wcout" << endl;
-
-wcerr << L"Test output to wcerr" << endl;
-
-wclog << L"Test output to wclog" << endl;
-
-wcout << L"Enter an integer to test wcin: ";
-
-wcin >> iVar;
-
-wcout << L"You entered " << iVar << endl;
-
-#endif
-
-
-
-// test CrtDbg output
-
-_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
-
-_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
-
-_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
-
-_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR);
-
-_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
-
-_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR);
-
-_RPT0(_CRT_WARN, "This is testing _CRT_WARN output\n");
-
-_RPT0(_CRT_ERROR, "This is testing _CRT_ERROR output\n");
-
-_ASSERT( 0 && "testing _ASSERT" );
-
-_ASSERTE( 0 && "testing _ASSERTE" );
-
-Sleep(2000);
-
-return 0;
-
-}
-
-//End of File
+========================================================================
Modified: scummex/branches/gsoc2007-gameresbrowser/vc8/core/core.vcproj
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/vc8/core/core.vcproj 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/vc8/core/core.vcproj 2007-07-03 16:58:16 UTC (rev 27883)
@@ -40,6 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
+ AdditionalIncludeDirectories="..\..\src\core"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -149,6 +150,14 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
+ RelativePath="..\..\src\core\CoreFileTypes.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\core\CoreIntf.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\src\core\guid.cpp"
>
</File>
@@ -187,10 +196,22 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
+ RelativePath="..\..\src\core\CoreFileTypes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\core\CoreIntf.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\core\debugmem.h"
>
</File>
<File
+ RelativePath="..\..\src\core\FileTypeRecognizer.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\core\ftregistry.h"
>
</File>
@@ -249,6 +270,38 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
+ <Filter
+ Name="common"
+ >
+ <File
+ RelativePath="..\..\src\core\common\ReadMe.txt"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\core\common\scummsys.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\core\common\simplefile.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\core\common\simplefile.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\core\common\stdafx.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\core\common\stream.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\core\common\stream.h"
+ >
+ </File>
+ </Filter>
<File
RelativePath=".\ReadMe.txt"
>
Modified: scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/ReadMe.txt
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/ReadMe.txt 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/ReadMe.txt 2007-07-03 16:58:16 UTC (rev 27883)
@@ -2,21 +2,6 @@
STATIC LIBRARY : plugins Project Overview
========================================================================
-AppWizard has created this plugins library project for you.
+Library with extra objects for the Game Resource Browser.
-No source files were created as part of your project.
-
-
-plugins.vcproj
- This is the main project file for VC++ projects generated using an Application Wizard.
- It contains information about the version of Visual C++ that generated the file, and
- information about the platforms, configurations, and project features selected with the
- Application Wizard.
-
-/////////////////////////////////////////////////////////////////////////////
-Other notes:
-
-AppWizard uses "TODO:" comments to indicate parts of the source code you
-should add to or customize.
-
-/////////////////////////////////////////////////////////////////////////////
+========================================================================
Modified: scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/plugins.vcproj
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/plugins.vcproj 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/plugins.vcproj 2007-07-03 16:58:16 UTC (rev 27883)
@@ -153,14 +153,18 @@
>
</File>
<File
- RelativePath="..\..\src\plugins\CoreIntf.cpp"
+ RelativePath="..\..\src\plugins\DiskFileProvider.cpp"
>
</File>
<File
- RelativePath="..\..\src\plugins\DiskFileProvider.cpp"
+ RelativePath="..\..\src\plugins\FileTypeRecognizer.cpp"
>
</File>
<File
+ RelativePath="..\..\src\plugins\ftregistry.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\src\plugins\GUIIntf.cpp"
>
</File>
@@ -191,10 +195,6 @@
>
</File>
<File
- RelativePath="..\..\src\plugins\CoreIntf.h"
- >
- </File>
- <File
RelativePath="..\..\src\plugins\DiskFileProvider.h"
>
</File>
@@ -207,6 +207,10 @@
>
</File>
<File
+ RelativePath="..\..\src\plugins\VirtualNode.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\plugins\wx2scstream.h"
>
</File>
@@ -217,42 +221,6 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
- <Filter
- Name="scummvm"
- >
- <File
- RelativePath="..\..\src\plugins\common\scummsys.h"
- >
- </File>
- <File
- RelativePath="..\..\src\plugins\common\simplefile.cpp"
- >
- </File>
- <File
- RelativePath="..\..\src\plugins\common\simplefile.h"
- >
- </File>
- <File
- RelativePath="..\..\src\plugins\common\stdafx.h"
- >
- </File>
- <File
- RelativePath="..\..\src\plugins\common\stream.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- ForcedIncludeFiles="stdafx.h"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\src\plugins\common\stream.h"
- >
- </File>
- </Filter>
<File
RelativePath=".\ReadMe.txt"
>
Modified: scummex/branches/gsoc2007-gameresbrowser/vc8/vc8.sln
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/vc8/vc8.sln 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/vc8/vc8.sln 2007-07-03 16:58:16 UTC (rev 27883)
@@ -3,6 +3,7 @@
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugin_sample1", "plugin_sample1\plugin_sample1.vcproj", "{D419FCD3-F34A-4937-BAFD-A90720366618}"
ProjectSection(ProjectDependencies) = postProject
+ {9337C90F-B184-46B9-BAFF-48B7EA025E32} = {9337C90F-B184-46B9-BAFF-48B7EA025E32}
{A763B1FF-FE5B-493E-9AB9-722E038ED4A0} = {A763B1FF-FE5B-493E-9AB9-722E038ED4A0}
EndProjectSection
EndProject
@@ -10,8 +11,8 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Browser", "Browser\Browser.vcproj", "{74AEC031-608A-4F84-9200-FEAB7A3E94FA}"
ProjectSection(ProjectDependencies) = postProject
+ {A763B1FF-FE5B-493E-9AB9-722E038ED4A0} = {A763B1FF-FE5B-493E-9AB9-722E038ED4A0}
{9337C90F-B184-46B9-BAFF-48B7EA025E32} = {9337C90F-B184-46B9-BAFF-48B7EA025E32}
- {A763B1FF-FE5B-493E-9AB9-722E038ED4A0} = {A763B1FF-FE5B-493E-9AB9-722E038ED4A0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugins", "plugins\plugins.vcproj", "{9337C90F-B184-46B9-BAFF-48B7EA025E32}"
Modified: scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout 2007-07-03 16:28:46 UTC (rev 27882)
+++ scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout 2007-07-03 16:58:16 UTC (rev 27883)
@@ -1,17 +1,17 @@
[Editor_4]
-CursorCol=3
-CursorRow=97
-TopLine=68
+CursorCol=42
+CursorRow=51
+TopLine=40
LeftChar=1
-Open=0
+Open=1
Top=0
[Editor_5]
CursorCol=1
-CursorRow=40
-TopLine=39
+CursorRow=1
+TopLine=1
LeftChar=1
-Open=0
-Top=0
+Open=1
+Top=1
[Editor_0]
CursorCol=1
CursorRow=1
@@ -24,7 +24,7 @@
CursorRow=1
TopLine=1
LeftChar=1
-Open=0
+Open=1
Top=0
[Editor_1]
CursorCol=1
@@ -35,7 +35,7 @@
Top=0
[Editors]
Focused=-1
-Order=
+Order=-1
[Editor_2]
Open=0
Top=0
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