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

zbychs at users.sourceforge.net zbychs at users.sourceforge.net
Sun Jul 1 19:02:36 CEST 2007


Revision: 27829
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27829&view=rev
Author:   zbychs
Date:     2007-07-01 10:02:35 -0700 (Sun, 01 Jul 2007)

Log Message:
-----------
Unplayable starts of GUI.
Will be updated soon.

Modified Paths:
--------------
    scummex/branches/gsoc2007-gameresbrowser/src/ReadMe.txt

Added Paths:
-----------
    scummex/branches/gsoc2007-gameresbrowser/src/core/
    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/stdafx.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/core/stdafx.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h
    scummex/branches/gsoc2007-gameresbrowser/src/core/treealgos.h
    scummex/branches/gsoc2007-gameresbrowser/src/data/
    scummex/branches/gsoc2007-gameresbrowser/src/data/lalka.bmp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/
    scummex/branches/gsoc2007-gameresbrowser/src/gui/Browser.layout
    scummex/branches/gsoc2007-gameresbrowser/src/gui/BrowserApp.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/BrowserApp.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/BrowserApp.rc
    scummex/branches/gsoc2007-gameresbrowser/src/gui/BrowserDlg.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/BrowserDlg.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/BrowserDlg.wxform
    scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.h
    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/MainForm.wxform
    scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/guicon.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/gui/guicon.h
    scummex/branches/gsoc2007-gameresbrowser/src/gui/stdafx.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/
    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/common/
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/array.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/file.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/file.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/fs.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/func.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/hash-str.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/hashmap.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/hashmap.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/scummsys.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/simplefile.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/simplefile.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/stdafx.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/str.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/str.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/stream.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/stream.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/common/util.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/stdafx.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/stdafx.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/wx2scstream.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugins/wx2scstream.h
    scummex/branches/gsoc2007-gameresbrowser/src/samples/
    scummex/branches/gsoc2007-gameresbrowser/src/samples/myplugin.h
    scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_plugins.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/samples/pinslot_verbose.cpp
    scummex/branches/gsoc2007-gameresbrowser/vc8/
    scummex/branches/gsoc2007-gameresbrowser/vc8/Browser/
    scummex/branches/gsoc2007-gameresbrowser/vc8/Browser/Browser.vcproj
    scummex/branches/gsoc2007-gameresbrowser/vc8/core/
    scummex/branches/gsoc2007-gameresbrowser/vc8/core/ReadMe.txt
    scummex/branches/gsoc2007-gameresbrowser/vc8/core/core.vcproj
    scummex/branches/gsoc2007-gameresbrowser/vc8/plugin_sample1/
    scummex/branches/gsoc2007-gameresbrowser/vc8/plugin_sample1/plugin_sample1.vcproj
    scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/
    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/
    scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.dev
    scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout
    scummex/branches/gsoc2007-gameresbrowser/wxdev/Makefile.win

Removed Paths:
-------------
    scummex/branches/gsoc2007-gameresbrowser/src/debugmem.h
    scummex/branches/gsoc2007-gameresbrowser/src/functionalex.h
    scummex/branches/gsoc2007-gameresbrowser/src/guid.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/guid.h
    scummex/branches/gsoc2007-gameresbrowser/src/myplugin.h
    scummex/branches/gsoc2007-gameresbrowser/src/ochain.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/ochain.h
    scummex/branches/gsoc2007-gameresbrowser/src/oregistry.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/oregistry.h
    scummex/branches/gsoc2007-gameresbrowser/src/pinslot.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/pinslot.h
    scummex/branches/gsoc2007-gameresbrowser/src/pinslot_detail.h
    scummex/branches/gsoc2007-gameresbrowser/src/pinslot_plugins.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/pinslot_verbose.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/plugin.h
    scummex/branches/gsoc2007-gameresbrowser/src/plugin_detail.h
    scummex/branches/gsoc2007-gameresbrowser/src/rcobject.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/rcobject.h
    scummex/branches/gsoc2007-gameresbrowser/src/sigslot.h
    scummex/branches/gsoc2007-gameresbrowser/src/stdafx.cpp
    scummex/branches/gsoc2007-gameresbrowser/src/stdafx.h
    scummex/branches/gsoc2007-gameresbrowser/src/tostring.h
    scummex/branches/gsoc2007-gameresbrowser/src/treealgos.h

Modified: scummex/branches/gsoc2007-gameresbrowser/src/ReadMe.txt
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/ReadMe.txt	2007-07-01 16:31:26 UTC (rev 27828)
+++ scummex/branches/gsoc2007-gameresbrowser/src/ReadMe.txt	2007-07-01 17:02:35 UTC (rev 27829)
@@ -2,9 +2,18 @@
     Game Resource Browser
 ========================================================================
 
-List of example files:
-    pinslot_plugins.cpp
-    myplugin.h
-    pinslot_verbose.cpp
+Directories:
 
+    core - core files (pins/slots/plugins/registries/objects...)
+    gui  - wxWidgets gui
+    plugins - plugins
+    samples - sample usages of the core/gui modules
+
+
+List of sample files (samples directory):
+
+    pinslot_plugins.cpp - shows plugin/object chain usage
+    myplugin.h          - shows plugins in a verbose way
+    pinslot_verbose.cpp - shows pins and slots in a verbose way
+
 /////////////////////////////////////////////////////////////////////////////

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/debugmem.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,43 @@
+/* debugmem.h
+
+    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.
+
+    To kill the overloading write:
+        #undef new
+    To reenable it write:
+        #define new DEBUG_NEW
+*/
+
+#pragma once
+#ifndef ZZ_DEBUG_H
+#define ZZ_DEBUG_H
+
+#if defined(_MSC_VER) && defined(_DEBUG)
+
+#include <crtdbg.h>
+
+#define DEBUG_NEW         new( _CLIENT_BLOCK, __FILE__, __LINE__)
+
+#define DEBUG_MEM_SETUP() _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF )
+
+#define new               DEBUG_NEW
+
+#define ASSERT(e) _ASSERTE(e)
+
+#else   /* !_MSC_VER || !_DEBUG*/
+
+#define DEBUG_NEW         new
+
+#define DEBUG_MEM_SETUP()
+
+#include <assert.h>
+
+#define ASSERT(e) assert(e)
+
+#endif  /* _MSC_VER, _DEBUG */
+
+#endif /* ZZ_DEBUG_H */
\ No newline at end of file

Added: scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,54 @@
+/////////////////////////////////////////////////////////////////////////////
+// oregistry.h
+//
+// Declares ObjectRegistry
+// One can load a plugin into ObjectRegistry.
+// (Maybe I'll do unloading too - later.)
+//
+
+#pragma once
+#ifndef ZZ_FILE_TYPE_REGISTRY_H
+#define ZZ_FILE_TYPE_REGISTRY_H
+
+#include "plugin.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// The FileTypeRegistry
+
+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 const Plugin& (*PluginAccessor)();
+
+    //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);
+
+    template<typename T>
+    RCPtr<T> getObject() {
+        RCPtr<BObject> obj( getObject(T::static_GUID()) );
+        return static_cast<T*>(obj.get());
+    }
+    */
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif /* ZZ_FILE_TYPE_REGISTRY_H */


Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/core/ftregistry.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/functionalex.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/functionalex.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/functionalex.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/functionalex.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,316 @@
+/*
+*  Zbyl's extensions to STL's <functional>
+*  Derived from VC++ 7.1 STL implementation.
+*/
+
+#pragma once
+#ifndef ZZ_FUNCTIONALEX_H
+#define ZZ_FUNCTIONALEX_H
+
+#include <functional>
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+// TEMPLATE STRUCT nullary_function
+template<class _Result>
+struct nullary_function
+{	// base class for nullary functions
+    typedef _Result result_type;
+};
+
+// TEMPLATE STRUCT trinary_function
+template<class _Arg1,
+class _Arg2,
+class _Arg3,
+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;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// cast1st_unary_t
+
+// TEMPLATE CLASS cast1st_unary_t
+template<class NArg,
+         class _Fn1>
+class cast1st_unary_t
+    : public std::unary_function<NArg, typename _Fn1::result_type>
+{	// functor adapter func((NArg)left)
+public:
+    typedef typename _Fn1::result_type _Result;
+
+    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)));
+    }
+
+protected:
+    _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);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// cast2nd_binary_t
+
+// TEMPLATE CLASS cast1st_unary_t
+template<class NArg,
+         class _Fn2>
+class cast2nd_binary_t
+    : 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;
+
+    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)));
+    }
+
+protected:
+    _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)
+{	// return a cast2nd_binary_t functor adapter
+    return cast2nd_binary_t<NArg, _Fn2>(fn);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// cast_nullary_t
+
+// TEMPLATE CLASS cast_nullary_t
+template<class NResult, class _Fn>
+class cast_nullary_t
+    : public nullary_function<NResult>
+{	// functor adapter (_Result)_Func()
+public:
+    typedef NResult result_type;
+
+    cast_nullary_t(const _Fn& _Func)
+        : op(_Func)
+    {	// construct from functor
+    }
+
+    result_type operator()() const
+    {	// apply functor to operands
+        return static_cast<NResult>( op() );
+    }
+
+protected:
+    _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);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// binary_unary2nd_t
+
+// TEMPLATE CLASS binary_unary2nd_t
+template<class Arg1,
+         class _Fn1>
+class binary_unary2nd_t
+    : 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;
+
+    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);
+    }
+
+private:
+    _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);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// unary_binder
+
+// TEMPLATE CLASS unary_binder
+template<class _Fn1>
+class unary_binder
+    : 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;
+
+    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));
+    }
+
+protected:
+    _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)
+{	// return a unary_binder functor adapter
+    typename _Fn1::argument_type _Val(_Left);
+    return (unary_binder<_Fn1>(_Func, _Val));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// trinary_binder
+/*
+// 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>
+{	// 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;
+
+    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()(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
+};
+
+// TEMPLATE FUNCTION bind3rd
+template<class _Fn3, class _Ty> inline
+    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));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// ptr_fun
+
+// TEMPLATE CLASS pointer_to_trinary_function
+template<class _Arg1,
+         class _Arg2,
+         class _Arg3,
+         class _Result,
+         class _Fn = _Result (*)(_Arg1, _Arg2, _Arg3)>
+class pointer_to_trinary_function
+    : 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
+    }
+
+    _Result operator()(_Arg1 _Left, _Arg2 _Middle, _Arg3 _Right) const
+    {	// call function with operands
+        return (_Pfun(_Left, _Middle, _Right));
+    }
+
+protected:
+    _Fn _Pfun;	// the function pointer
+};
+*/
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif /* ZZ_FUNCTIONALEX_H */
+
+/*
+* Copyright (c) 1992-2005 by P.J. Plauger.  ALL RIGHTS RESERVED.
+* Consult your license regarding permissions and restrictions.
+*/
+
+/*
+* This file is derived from software bearing the following
+* restrictions:
+*
+* Copyright (c) 1994
+* Hewlett-Packard Company
+*
+* Permission to use, copy, modify, distribute and sell this
+* software and its documentation for any purpose is hereby
+* granted without fee, provided that the above copyright notice
+* appear in all copies and that both that copyright notice and
+* this permission notice appear in supporting documentation.
+* Hewlett-Packard Company makes no representations about the
+* suitability of this software for any purpose. It is provided
+* "as is" without express or implied warranty.
+V4.05:0009 */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/guid.cpp)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,68 @@
+/////////////////////////////////////////////////////////////////////////////
+// guid.cpp
+//
+// Declares GUID, GUIDObject and some helpers
+//
+
+#include "stdafx.h"
+
+#include "guid.h"
+
+// Plugins have GUIDs
+// ObjectPlugins have GUIDs
+// Objects have GUIDs
+// Interfaces have GUIDs
+//
+// Concrete interfaces should inherit GUIDs from their super-interfaces.
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+    BGUID::BGUID(std::string _facility, std::string _identifier, int _version)
+        : facility(_facility), identifier(_identifier), version(_version) {}
+
+    bool BGUID::operator==(const BGUID& other) const {
+        return facility == other.facility &&
+            identifier == other.identifier &&
+            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;
+    }*/
+
+    std::ostream& operator<<(std::ostream& os, const BGUID& guid) {
+        return os << "BGUID(" << guid.facility << ", " << guid.identifier << ", "
+            << guid.version << ")";
+    }
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/guid.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,71 @@
+/////////////////////////////////////////////////////////////////////////////
+// guid.h
+//
+// Declares BGUID, GUIDObject and some helpers
+//
+
+#pragma once
+#ifndef ZZ_GUID_H
+#define ZZ_GUID_H
+
+#include <string>
+#include <ostream>
+
+// Plugins have GUIDs
+// ObjectPlugins have GUIDs
+// Objects have GUIDs
+// Interfaces have GUIDs
+//
+// Concrete interfaces should inherit GUIDs from their super-interfaces.
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+struct BGUID {
+    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;
+
+private:
+    BGUID& operator=(const BGUID& other); //don't assign
+};
+
+std::ostream& operator<<(std::ostream& os, const BGUID& guid);
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class GUIDObject {
+public:
+    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; \
+    }
+
+#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)
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif /* ZZ_GUID_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.cpp (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/ochain.cpp)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.cpp	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.cpp	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,392 @@
+/////////////////////////////////////////////////////////////////////////////
+// ochain.cpp
+//
+// Declares an ObjectChain
+//
+
+#include "stdafx.h"
+
+#include "ochain.h"
+
+#include "treealgos.h"
+
+#include <functional>
+
+#include "debugmem.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+//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 on failure or 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;
+        bool ok = obj->realize(this);
+        if(ok) //the object initialized properly
+            return true;
+        objects.erase(obj);
+        return false;
+    }
+
+    bool ObjectChain::isContained(const RCPtr<BObject>& obj) {
+        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
+
+        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
+
+        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;
+    }
+
+    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
+
+        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
+
+        slot2pin_map::iterator i = slot2pin.find(slot);
+        if(i == slot2pin.end())
+            return false;
+
+        if(i->second != pin)
+            return false;
+
+        //ASSERT(slot->getPin() == pin);
+
+        return true;
+    }
+
+    //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);
+    }
+
+    //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);
+    }
+
+    //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);
+
+        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);
+    }
+
+    //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);
+
+        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);
+
+        return res;
+    }
+
+    void ObjectChain::disconnectObject(const RCPtr<BObject>& obj) {
+        ASSERT( objects.count(obj) == 1 ); // must be our object
+
+        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);
+        }
+        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
+    }
+
+    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
+    }
+
+    //TODO: make it in order
+    void ObjectChain::disconnectAll() {
+        object_set::const_iterator i;
+        for(i = objects.begin(); i != objects.end(); ++i) {
+            (*i)->unrealize(this);
+            disconnectObject(*i);
+        }
+    }
+
+    void ObjectChain::removeAllObjects() {
+        disconnectAll();
+        objects.clear(); //all the ref counts down
+    }
+
+    ObjectChain::~ObjectChain() {
+        removeAllObjects();
+    }
+
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// private:
+
+    typedef tree_algos::bfs_fringe<BObject*> bfsFringe;
+    struct Expand : std::binary_function<BObject*,bfsFringe,void> {
+        ObjectChain* that;
+        Expand(ObjectChain* _that) : that(_that) {}
+        void operator()(BObject* obj, bfsFringe fringe) {
+            _expand_node(that, obj, fringe);
+        }
+    };
+
+    //expand: for every slot in node add connected pin's owner
+    template<template<typename T> class Fringe>
+    void _expand_node(ObjectChain* ochain, BObject* obj, Fringe<BObject*> 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 = ochain->_match_pin(slot);
+            if(!pin)
+                continue;
+            BObject* other = ochain->_match_that(pin);
+            ASSERT(other);
+            fringe.push(other);
+        }
+    }
+
+    //visit: return true if node == obj1
+    int _visit_node(BObject* refobj, BObject* obj) {
+        return (refobj == obj) ? tree_algos::DONE : 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: raise the objects rank
+        
+        typedef std::map<BObject*, int> rank_map;
+        rank_map ranks;
+        object_set::const_iterator i;
+        for(i = objects.begin(); i != objects.end(); ++i)
+            ranks.insert( std::make_pair(i->get(), 0) );
+
+        struct Visit : std::unary_function<BObject*,bool> {
+            rank_map& ranks;
+            int cur_rank;
+            Visit(rank_map& _ranks) : ranks(_ranks), cur_rank(0) {}
+            int operator()(BObject* obj) {
+                rank_map::iterator i;
+                i = ranks.find(obj);
+                ASSERT( i != ranks.end() );
+                int rank = i->second;
+                if(rank > cur_rank)
+                    return tree_algos::SKIP;
+                i->second = cur_rank;
+                cur_rank++;
+                return tree_algos::CONTINUE;
+            }
+        };
+        Visit visit(ranks);
+        Expand expand(this);
+        for(i = objects.begin(); i != objects.end(); ++i)
+        {
+            visit.cur_rank = 0;
+            tree_algos::bfs(i->get(),visit,expand);
+        }
+
+        //sort
+        typedef std::pair<BObject*, int> the_pair;
+        typedef std::vector<the_pair> unrank_vec;
+        unrank_vec unranks( ranks.begin(), ranks.end() );
+        struct Util {
+            bool operator()(const the_pair& p0, const the_pair& p1) {
+                return p0.second < p1.second;
+            }
+            BObject* operator()(const the_pair& p) {
+                return p.first;
+            }
+        };
+        std::sort(unranks.begin(), unranks.end(), Util());
+        objs.resize(unranks.size());
+        std::transform(unranks.begin(), unranks.end(), objs.begin(), Util());
+    }
+
+    //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
+
+        //bfs:
+        //initial node: = obj0
+        //expand: for every slot in node add connected pin's owner
+        //visit: return true if node == obj1
+
+        Expand expand(this);
+        bool cycle = tree_algos::bfs(obj0.get(),
+            std::bind1st(std::ptr_fun(&_visit_node), obj1.get()),
+            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;
+
+        if(pin != i->second)
+            return false;
+
+        ASSERT(pin && slot);
+
+        slot->disconnect();
+
+        slot2pin.erase(slot);
+        pin2that.erase(pin);
+        pin2slot_map::iterator j;
+        if(!_find_pin(pin,slot,j))
+            ASSERT(false);
+        pin2slot.erase(j);
+
+        return true;
+    }
+
+    bool ObjectChain::_find_slot(SlotType* slot, slot2pin_map::iterator& i) {
+        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;
+    }
+
+    PinType* ObjectChain::_match_pin(SlotType* slot) {
+        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;
+    }
+
+    /* 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;
+    }*/
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/ochain.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/ochain.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,140 @@
+/////////////////////////////////////////////////////////////////////////////
+// ochain.h
+//
+// Declares an ObjectChain
+//
+
+#pragma once
+#ifndef ZZ_OCHAIN_H
+#define ZZ_OCHAIN_H
+
+#include "pinslot.h"
+
+#include <map>
+#include <set>
+#include <vector>
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+//Connecting Pins and Slots does not change ref counts.
+//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;
+
+    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;
+
+public:
+    
+    //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 realize();
+
+    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);
+
+    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);
+
+    //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 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(const RCPtr<BObject>& obj,
+                        const BGUID& interfaceGUID);
+
+    //returns true if all the slots has been succesfully disconnected
+    //returns false on error
+    bool disconnect_pin(PinType* pin);
+
+    void disconnectObject(const RCPtr<BObject>& obj);
+
+    void removeObject(const RCPtr<BObject>& obj);
+
+    void disconnectAll();
+
+    void removeAllObjects();
+
+    virtual ~ObjectChain();
+
+
+private:
+
+    //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);
+                 
+    //expand: for every slot in node add connected pin's owner
+    template<template<typename T> class Fringe>
+    friend void _expand_node(ObjectChain* ochain, BObject* obj, Fringe<BObject*> fringe);
+
+    //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 pin2slot
+    bool _find_pin(PinType* pin, SlotType* slot, pin2slot_map::iterator& i);
+
+    //searches in slot2pin
+    PinType* _match_pin(SlotType* slot);
+
+    //searches in pin2that
+    BObject* _match_that(PinType* pin);
+
+    /* nonsense:
+    SlotType* _match_slot(PinType* pin, SlotType* slot);
+    }*/
+
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif /* ZZ_OCHAIN_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/oregistry.cpp)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.cpp	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,69 @@
+/////////////////////////////////////////////////////////////////////////////
+// oregistry.cpp
+//
+// ObjectRegistry implementation.
+//
+
+#include "stdafx.h"
+
+#include "oregistry.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// The ObjectRegistry
+
+//returns false if there were some conflicts
+bool ObjectRegistry::registerPlugin(PluginAccessor pluginAccessor, bool 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();
+
+    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();
+
+        ObjectMap::iterator i;
+        i = objectMap.find(oguid);
+        if(i != objectMap.end()) {
+            res = false;
+            if(overwrite)
+                i->second = oplug;
+            continue;
+        }
+
+        objectMap.insert( std::make_pair(oguid, oplug) );
+    }
+
+    return res;
+}
+
+const ObjectPlugin* ObjectRegistry::findObjectPlugin(const BGUID& guid) {
+    ObjectPlugins::const_iterator i;
+    i = objectMap.find(guid);
+    if(i == objectMap.end())
+        return NULL;
+    return i->second;
+}
+
+RCPtr<BObject> ObjectRegistry::getObject(const BGUID& guid) {
+    const ObjectPlugin* plug = findObjectPlugin(guid);
+    if(!plug)
+        return NULL;
+    return plug->newInstance();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/oregistry.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/oregistry.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,52 @@
+/////////////////////////////////////////////////////////////////////////////
+// oregistry.h
+//
+// Declares ObjectRegistry
+// One can load a plugin into ObjectRegistry.
+// (Maybe I'll do unloading too - later.)
+//
+
+#pragma once
+#ifndef ZZ_OBJECT_REGISTRY_H
+#define ZZ_OBJECT_REGISTRY_H
+
+#include "plugin.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// The ObjectRegistry
+
+class ObjectRegistry {
+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 const Plugin& (*PluginAccessor)();
+
+    //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);
+
+    template<typename T>
+    RCPtr<T> getObject() {
+        RCPtr<BObject> obj( getObject(T::static_GUID()) );
+        return static_cast<T*>(obj.get());
+    }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif /* ZZ_OBJECT_REGISTRY_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/pinslot.cpp)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,183 @@
+/////////////////////////////////////////////////////////////////////////////
+// pinslot.cpp
+//
+// Declares Pins and Slots
+// (plus factories, templates and macros for them)
+//
+
+#include "stdafx.h"
+
+#include "pinslot.h"
+
+#include "debugmem.h" //turn memory debugging ON
+
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Desciptor of Slots and Pins
+// As for now a descriptor has:
+//   interfaceGUID - a guid of the interface that this pin/slot provides/accepts
+//   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) {}
+
+    std::ostream& operator<<(std::ostream& os, const _PinSlotDesc& desc) {
+        return os << "PinSlotDesc(" << desc.name << ", " << desc.interfaceGUID << ", "
+            << desc.flags << ")";
+    }
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Desciptors of Pins and Slots, that can be used to create and access pins and slots.
+//   void makePinSlot(BObject* that) - function used during the initialization of the
+//                                     object to create the pin/slot (do not use!)
+//   PinSlotType* getPinSlot(BObject* that) - function used to retrieve a pin/slot from
+//                                     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(const _PinSlotDesc& desc)
+        : _PinSlotDesc(desc) {}
+
+    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);
+    }
+
+    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);
+    }
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// 'annotation_map' is not too pretty. Maybe it should be cleaned up a bit - later.
+// It has one very concrete purpose - to hold pins' ans slots' descriptions.
+// Not for broad use.
+
+namespace pinslot_detail {
+
+    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(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;
+    }
+
+    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_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;
+    }
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// 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::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() ));
+    }
+
+    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);
+    }
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/pinslot.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,433 @@
+/////////////////////////////////////////////////////////////////////////////
+// pinslot.h
+//
+// Declares Pins and Slots
+// (plus factories, templates and macros for them)
+//
+
+#pragma once
+#ifndef ZZ_PINSLOT_H
+#define ZZ_PINSLOT_H
+
+#include <map>      // for PinSlotDescs
+#include "guid.h"
+#include "tostring.h"
+
+#include "debugmem.h" //turn memory debugging ON
+#include "rcobject.h" //Scott Meyers' reference counted object
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+//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 {
+    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
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Interface
+
+//Interfaces are not reference counted.
+
+class IInterface : public GUIDObject {
+public:
+    virtual ~IInterface() {} //not really needed - but for extra safety it's here
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Pins and Slots
+
+struct _PinSlotDesc;
+
+struct 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
+};
+
+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;
+};
+
+template<typename I>
+struct Pin : PinType {
+    virtual I* getInterface() = 0;
+    virtual void releaseInterface(I* iface) = 0;
+
+    /*virtual IInterface* getInterface() {
+        return static_cast<IInterface*>(I* (*)())getInterface();
+    }*/
+    virtual void releaseInterface(IInterface* iface) {
+        releaseInterface(static_cast<I*>(iface));
+    }
+};
+
+template<typename I>
+struct Slot : SlotType {
+    virtual I* getInterface() = 0;
+    virtual void connect(Pin<I>* _pin) = 0;
+
+    /*virtual IInterface* getInterface() {
+        return static_cast<IInterface*>(I* (*)())getInterface();
+    }*/
+    virtual void connect(PinType* _pin) {
+        connect(static_cast<Pin<I>*>(_pin));
+    }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Desciptor of Slots and Pins
+// As for now a descriptor has:
+//   interfaceGUID - a guid of the interface that this pin/slot provides/accepts
+//   name          - a human readable name
+//   flags         - flags of a pin/slot (default/multicast/pin/slot...)
+
+struct _PinSlotDesc {
+    const BGUID interfaceGUID;
+    int flags;
+    std::string name;
+
+    _PinSlotDesc(std::string _name, const BGUID& _interfaceGUID, int _flags);
+};
+
+std::ostream& operator<<(std::ostream& os, const _PinSlotDesc& desc);
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Desciptors of Pins and Slots, that can be used to create and access pins and slots.
+//   void makePinSlot(BObject* that) - function used during the initialization of the
+//                                     object to create the pin/slot (do not use!)
+//   PinSlotType* getPinSlot(BObject* that) - function used to retrieve a pin/slot from
+//                                     an object
+// (see Makers and Accesors in pinslot_detail.h for more details)
+
+class BObject;
+
+struct PinSlotDesc : _PinSlotDesc {
+    PinSlotDesc(std::string _name, const BGUID& _interfaceGUID, int _flags);
+    PinSlotDesc(const _PinSlotDesc& desc);
+
+    virtual void makePinSlot(BObject* that) const = 0;        //do not use manually
+    virtual PinSlotType* getPinSlot(BObject* that) const = 0;
+    virtual ~PinSlotDesc();
+    virtual PinSlotDesc* copy() const = 0;                    //do not use manually
+
+    PinType* get_pin(BObject* that) const;
+    SlotType* get_slot(BObject* that) const;
+
+    template<typename I>
+    Pin<I>* get_pin(BObject* that) const {
+        ASSERT( I::static_GUID() == interfaceGUID ); //don't ask for some other interface
+        PinType* pin = get_pin(that);
+        return static_cast<Pin<I>*>(pin);
+    }
+
+    template<typename I>
+    Slot<I>* get_slot(BObject* that) const {
+        ASSERT( I::static_GUID() == interfaceGUID ); //don't ask for some other interface
+        SlotType* slot = get_slot(that);
+        return static_cast<Slot<I>*>(slot);
+    }
+};
+
+// A pin/slot descriptor parametrized by 'maker' and 'accesor' functors.
+// PinSlotDescImpl uses those functors to implement it's 'makePinSlot' and
+// 'getPinSlot' methods.
+// (see Makers and Accessors in pinslot_detail.h for more details)
+template<typename GD, typename FD>
+struct PinSlotDescImpl : PinSlotDesc {
+    GD pinSlotGet;
+    FD pinSlotFactory;
+    PinSlotDescImpl(std::string _name, const BGUID& _interfaceGUID, int _flags,
+        const GD& _pinSlotGet, const FD& _pinSlotFactory)
+        : PinSlotDesc(_name, _interfaceGUID, _flags),
+        pinSlotGet(_pinSlotGet), pinSlotFactory(_pinSlotFactory) {}
+    PinSlotDescImpl(const _PinSlotDesc& desc, const GD& _pinSlotGet, const FD& _pinSlotFactory)
+        : PinSlotDesc(desc), pinSlotGet(_pinSlotGet), pinSlotFactory(_pinSlotFactory) {}
+    virtual void makePinSlot(BObject* that) const {
+        pinSlotFactory(that);
+    }
+    virtual PinSlotType* getPinSlot(BObject* that) const {
+        return pinSlotGet(that);
+    }
+    virtual PinSlotDesc* copy() const {
+        return new PinSlotDescImpl<GD,FD>(*this, pinSlotGet, pinSlotFactory);
+    }
+};
+
+template<typename GD, typename FD>
+PinSlotDesc* makePinSlotDesc(std::string _name, const BGUID& _interfaceGUID, int _flags,
+                             const GD& gd, const FD& fd) {
+                             //GD gd, FD fd) {
+    return new PinSlotDescImpl<GD, FD>(_name, _interfaceGUID, _flags, gd, fd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Pins implementation
+// DelegatingPin is a Pin parametrized by 'get' and 'release' functors.
+// DelegatingPin uses those functors to implement it's 'getInterface' and
+// 'releaseInterface' methods.
+// (see Makers in pinslot_detail.h to see more)
+
+template<typename I, int flags, typename GD, typename RD>
+struct DelegatingPin : Pin<I> {
+    GD getDelegate;
+    RD releaseDelegate;
+    DelegatingPin(const GD& gd, const RD& rd) :
+    getDelegate(gd),
+        releaseDelegate(rd)
+    {}
+    virtual I* getInterface() {
+        return getDelegate();
+    }
+    virtual void releaseInterface(I* iface) {
+        releaseDelegate(iface);
+    }
+
+    virtual const _PinSlotDesc& get_desc() const {
+        return static_desc();
+    }
+    static const _PinSlotDesc& static_desc() {
+        static _PinSlotDesc DESC(toString(I::static_GUID().identifier) + "-Pin",
+            I::static_GUID(), flags);
+        return DESC;
+    }
+};
+
+template<typename I, int flags, typename GD, typename RD>
+Pin<I>* makeDelegatingPin(const GD& gd, const RD& rd) {
+    return new DelegatingPin<I,flags,GD,RD>(gd,rd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Slots implementation
+
+template<typename I, typename T, int flags>
+struct SlotImpl : Slot<I> {
+    Pin<I>* pin;
+    I* iface;
+    SlotImpl() {
+        pin = NULL;
+        iface = NULL;
+    }
+    virtual ~SlotImpl() {
+        //the interface must be returned
+        ASSERT(pin == NULL && iface == NULL);
+    }
+    virtual I* getInterface() {
+        if(!pin)
+            return NULL;
+        if(!iface)
+            iface = pin->getInterface();
+        return iface;
+    }
+    virtual void releaseInterface() {
+        if(!pin)
+            return;
+        if(!iface)
+            return;
+        pin->releaseInterface(iface);
+        //pin = NULL;
+        iface = NULL;
+    }
+    virtual void connect(Pin<I>* _pin) {
+        pin = _pin;
+    }
+    virtual void disconnect() {
+        releaseInterface();
+        pin = NULL;
+    }
+    virtual bool isConnected() {
+        return pin != NULL;
+    }
+
+    virtual const _PinSlotDesc& get_desc() const {
+        return static_desc();
+    }
+    static const _PinSlotDesc& static_desc() {
+        static _PinSlotDesc DESC(toString(I::static_GUID().identifier) + "-Slot",
+            I::static_GUID(), flags);
+        return DESC;
+    }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// 'annotation_map' is not too pretty. Maybe it should be cleaned up a bit - later.
+// It has one very concrete purpose - to hold pins' ans slots' descriptions.
+// Not for broad use.
+
+namespace pinslot_detail {
+
+    struct annotation_map : std::map<const BGUID, PinSlotDesc*> {
+        bool shared;
+
+        annotation_map(bool _shared = false);
+        annotation_map(const annotation_map& _map);
+        ~annotation_map();
+
+        PinSlotDesc* find(const BGUID& key) const;
+
+        annotation_map& insert(PinSlotDesc* val);
+        annotation_map& insert(const annotation_map& cont);
+        annotation_map& insert_copy(const annotation_map& cont);
+    };
+}
+
+typedef pinslot_detail::annotation_map PinSlotDescs;
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// BObject is a reference counted object that is capable of holding pins and slots.
+
+class ObjectChain;
+
+class BObject : public RCObject, public GUIDObject {
+
+private:
+
+    //do not call manually!
+    void init_pins_slots();
+
+    //do not call manually!
+    void delete_pins_slots();
+
+public:
+
+    BObject() {
+        _realized = false;
+        _ochain = NULL;
+    }
+
+    // Those methods below are here, and not in the constructor/destructor, because
+    // they use virtual functions. So they need to be called on a fully constructed
+    // object.
+
+    //when overriding allways run super
+    virtual void initialize() {
+        RCObject::initialize();
+        init_pins_slots();
+    }
+
+    //when overriding allways run super
+    virtual void destroy() {
+        delete_pins_slots();
+        RCObject::destroy();
+    }
+
+    //other lifecycle methods:
+    //The implementations provided here are a good base for an object that can be
+    //realized only in one ObjectChain at once.
+
+    virtual bool isRealized(ObjectChain* ochain) {
+        return _realized && (_ochain == ochain);
+    }
+
+    //invoked to initialize the object in the ObjectChain
+    //realize can query the ObjectChain (the object is already a member of it)
+    virtual bool realize(ObjectChain* ochain) {
+        if(_realized)
+            return false;
+        _ochain = ochain;
+        _realized = true;
+        return true;
+    }
+
+    //invoked to uninitialize the object in the ObjectChain
+    //unrealize can query the ObjectChain (the object is still a member of it)
+    virtual void unrealize(ObjectChain* ochain) {
+        ASSERT( _realized && (_ochain == ochain) );
+        _ochain = NULL;
+        _realized = false;
+    }
+
+
+protected:
+    bool _realized;
+    ObjectChain* _ochain;
+
+public:
+
+    virtual const PinSlotDescs& get_pins() const {
+        return BObject::static_pins();
+    }
+    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;
+    }
+
+
+    //this should not be used - use pins explicitly instead
+    /*template<typename I>
+    I* getInterface() {
+        Pin<I>* pin = get_pin<I>();
+        if(!pin)
+            return NULL;
+        return pin->getInterface();
+    }
+    template<typename I>
+    void releaseInterface(I* iface) {
+        Pin<I>* pin = get_pin<I>();
+        if(!pin)
+            return;
+        pin->releaseInterface(iface);
+    }*/
+
+    template<typename I>
+    Pin<I>* get_pin() {
+        return static_cast<Pin<I>*>( get_pin(I::static_GUID()) );
+    }
+
+    template<typename I>
+    Slot<I>* get_slot() {
+        return static_cast<Slot<I>*>( get_slot(I::static_GUID()) );
+    }
+
+    PinType* get_pin(const BGUID& interfaceGUID);
+    SlotType* get_slot(const BGUID& interfaceGUID);
+
+private:
+    PinSlotType* get_pinSlot(const BGUID& interfaceGUID, const PinSlotDescs& descs);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Include all the hacky stuff
+
+} // namespace Browser
+
+#include "pinslot_detail.h"
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+#endif /* ZZ_PINSLOT_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot_detail.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/pinslot_detail.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot_detail.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot_detail.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,252 @@
+/////////////////////////////////////////////////////////////////////////////
+// pinslot_detail.h
+//
+// Declares various hacky macros and templates for Pins and Slots
+//
+
+#pragma once
+#ifndef ZZ_PINSLOT_DETAIL_H
+#define ZZ_PINSLOT_DETAIL_H
+
+#include "functionalex.h" // makers and accessors use that (includes <functional>)
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Helpful macros
+
+#define DECLARE_BOBJECT_CLASS(clazz, super) \
+private: \
+    typedef clazz this_class; \
+    typedef super super_class;
+
+#define THIS_CLASS_NAME  (typeid(this_class).name())
+#define SUPER_CLASS_NAME (typeid(super_class).name())
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Macros for defining Pins and Slots
+// (see pinslot_verbose.cpp to see what they produce)
+//
+// The code doesn't look that nice, but it is carefully planned.
+// It allows for getting static descriptions of all the pins and slots in
+// 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.
+
+//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();
+
+
+#define PIN_DESCS_EX(clazz) \
+    const PinSlotDescs& clazz::static_pins() { \
+        static PinSlotDescs descs( \
+            PinSlotDescs(true).insert_copy(clazz::super_class::static_pins())
+
+#define SLOT_DESCS_EX(clazz) \
+    const PinSlotDescs& clazz::static_slots() { \
+        static PinSlotDescs descs( \
+            PinSlotDescs(true).insert_copy(clazz::super_class::static_pins())
+
+//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())
+
+
+#define PIN_DESC(pin,flags,getFun,relFun) \
+            .insert( \
+                    makePinDesc<flags | IS_PIN>( \
+                                        #pin, \
+                                        &this_class::pin, \
+                                        &this_class::getFun, \
+                                        &this_class::relFun \
+                                      ) \
+                    )
+
+//iRel is a name of the concrete interface, that can be freed with it's
+//release() method
+#define PIN_DESC_r(pin,flags,getFun,iRel) \
+            .insert( \
+                    makePinDesc<flags | IS_PIN,iRel>( \
+                                        #pin, \
+                                        &this_class::pin, \
+                                        &this_class::getFun \
+                                      ) \
+                    )
+
+#define SLOT_DESC(pin,flags) \
+            .insert( \
+                    makeSlotDesc<flags | IS_SLOT>( \
+                                        #pin, \
+                                        &this_class::pin \
+                                      ) \
+                    )
+
+#define END_DESCS \
+        ); \
+        static bool dummy = (descs.shared = false); \
+        return descs; \
+    }
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Templates for use with PIN_DESC and SLOT_DESC macros.
+// They are only to force the compiler to guess types from the parameters,
+// so that they don't have to be explicitly written as macro parameters.
+// (Actually, only 'I' would have to written explicitly; 'flags' and 'Irel' too,
+// but those two are not guessed anyway.)
+
+// ISup is used here in two places - it's on purpose, for type safety.
+// (Without this template it wouldn't be type safe.)
+template<int flags, typename I, typename T, typename ISup>
+PinSlotDesc* makePinDesc(char* name, Pin<I>* T::* pin, ISup* (T::* getFun)(),
+                                                       void  (T::* relFun)(ISup*) ) {
+    return
+         makePinSlotDesc(std::string(typeid(T).name()) + "::" + name,
+                         I::static_GUID(),
+                         flags,
+                         accessPin(pin),
+                         makePin<flags>(
+                                 pin,
+                                 std::mem_fun(getFun),
+                                 cast2nd_binary<I*>(std::mem_fun(relFun))
+                                 )
+                         );
+}
+
+//can turn into a macro to allow for other release() function names
+template<int flags, typename Irel, typename I, typename T, typename ISup>
+PinSlotDesc* makePinDesc(char* name, Pin<I>* T::* pin, ISup* (T::* getFun)() ) {
+    return
+        makePinSlotDesc(std::string(typeid(T).name()) + "::" + name,
+                        I::static_GUID(),
+                        flags,
+                        accessPin(pin),
+                        makePin<flags>(
+                                 pin,
+                                 std::mem_fun(getFun),
+                                 binary_unary2nd<BObject*>(
+                                    cast1st_unary<I*>( std::mem_fun(&Irel::release) )
+                                    )
+                                  )
+                        );
+}
+
+template<int flags, typename I, typename T>
+PinSlotDesc* makeSlotDesc(char* name, Slot<I>* T::* slot) {
+    return
+        makePinSlotDesc(std::string(typeid(T).name()) + "::" + name,
+                         I::static_GUID(),
+                         flags,
+                         accessSlot(slot),
+                         makeSlot<flags>(slot)
+                         );
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Pin and Slot makers and accessors
+//
+// Makers are functors that can create a pin/slot with desired characteristics.
+// They are templatized to make the compiler guess the types of used sub-functors.
+// PinMaker takes two sub-functors:
+//    GD = I* gd(T* that)
+//      - get functor - it's an interface factory used by the Pin to produce interfaces
+//    RD = void rd(T* that, I* intf)
+//      - release functor - it's a functor used by the Pin to release created interfaces
+//
+// Accessors are functors that can be used to retrieve a pin/slot from an object:
+//
+//  maker(that);                  - creates appropriate pin/slot and injects it into 'that'
+//  Pin<I>* pin = accessor(that); - gives access to a partcular pin/slot
+
+template<int flags, typename I, typename T, typename GD, typename RD>
+struct PinMaker {
+    GD gd; // IDer* gd(T* that)
+    RD rd; // void rd(T* that, I* intf)
+    Pin<I>* T::*pin;
+    PinMaker(Pin<I>* T::*_pin, const GD& _gd, const RD& _rd)
+        : pin(_pin), gd(_gd), rd(_rd) {}
+    void operator()(BObject* that) const
+    {
+        (static_cast<T*>(that)) ->* pin =
+            makeDelegatingPin<I,flags>(
+            /*cast_nullary<I*>*/( bind_unary(gd, static_cast<T*>(that)) ),
+            /*cast1st_unary<I*>*/( bind1st(rd, static_cast<T*>(that)) )
+            );
+    }
+};
+
+template<int flags, typename I, typename T, typename GD, typename RD>
+PinMaker<flags,I,T,GD,RD> makePin(Pin<I>* T::*_pin, const GD& _gd, const RD& _rd) {
+    return PinMaker<flags,I,T,GD,RD>(_pin,_gd,_rd);
+}
+
+template<int flags, typename I, typename T>
+struct SlotMaker {
+    Slot<I>* T::*slot;
+    SlotMaker(Slot<I>* T::*_slot)
+        : slot(_slot) {}
+    void operator()(BObject* that) const
+    {
+        (static_cast<T*>(that)) ->* slot =
+            new SlotImpl<I,T,flags>();
+    }
+};
+
+template<int flags, typename I, typename T>
+SlotMaker<flags,I,T> makeSlot(Slot<I>* T::*_slot) {
+    return SlotMaker<flags,I,T>(_slot);
+}
+
+template<typename I, typename T, template<typename I2> class PS>
+struct PinSlotAccessor {
+    typename PS<I>* T::*pin;
+    PinSlotAccessor(typename PS<I>* T::*_pin)
+        : pin(_pin) {}
+    PinSlotType* operator()(BObject* that) const
+    {
+        return static_cast<PinSlotType*>( (static_cast<T*>(that))->*pin );
+    }
+};
+
+template<typename I, typename T>
+PinSlotAccessor<I,T,Pin> accessPin(Pin<I>* T::*_pin) {
+    return PinSlotAccessor<I,T,Pin>(_pin);
+}
+
+template<typename I, typename T>
+PinSlotAccessor<I,T,Slot> accessSlot(Slot<I>* T::*_slot) {
+    return PinSlotAccessor<I,T,Slot>(_slot);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif /* ZZ_PINSLOT_DETAIL_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/plugin.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/plugin.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/plugin.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/plugin.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,82 @@
+/////////////////////////////////////////////////////////////////////////////
+// plugin.h
+//
+// Declares plugin interface.
+// (see myplugin.h for an excample)
+//
+
+#pragma once
+#ifndef ZZ_PLUGIN_H
+#define ZZ_PLUGIN_H
+
+#include "guid.h"
+#include "pinslot.h"
+
+#include <map>
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ObjectPlugin;
+
+class Plugin : public GUIDObject {
+public:
+    //CAUTION: the ObjectPlugins map is keyed with the plugins GUID, not
+    //         it's object's GUID.
+    typedef std::map<const BGUID, const ObjectPlugin*> ObjectPlugins;
+
+    virtual const ObjectPlugins& getObjectPlugins() const = 0;
+
+    virtual ~Plugin() {}
+};
+
+class ObjectPlugin : public GUIDObject {
+public:
+
+    virtual const BGUID& getObjectGUID() const = 0;
+
+    virtual const PinSlotDescs& get_pins() const = 0;
+    virtual const PinSlotDescs& get_slots() const = 0;
+
+    virtual RCPtr<BObject> newInstance() const = 0;
+
+    virtual ~ObjectPlugin() {}
+};
+
+template<typename T>
+class ObjectPluginImpl : public ObjectPlugin {
+public:
+    
+    ASSIGN_GUID_VERBOSE( (std::string("ObjectPluginImpl<") + typeid(T).name() + ">"),
+                         "ObjectPlugins", 1)
+
+    virtual const BGUID& getObjectGUID() const {
+        return T::static_GUID();
+    }
+
+    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());
+    }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Include the macros
+
+} // namespace Browser
+
+#include "plugin_detail.h"
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+#endif /* ZZ_PLUGIN_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/plugin_detail.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/plugin_detail.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/plugin_detail.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/plugin_detail.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,63 @@
+/////////////////////////////////////////////////////////////////////////////
+// plugin_detail.h
+//
+// Declares macros for extra fast plugin generation.
+//
+
+#pragma once
+#ifndef ZZ_PLUGIN_DETAIL_H
+#define ZZ_PLUGIN_DETAIL_H
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Helper macros
+
+#define JOIN_TOKENS(x,y) JOIN_TOKENS2(x,y)
+#define JOIN_TOKENS2(x,y) x ## y
+#define GENERATE_UNIQUE_IDENTIFIER JOIN_TOKENS(z__unique_id_, __LINE__)
+#define GENERATE_UNIQUE_IDENTIFIER_SUB(subname) \
+    JOIN_TOKENS(GENERATE_UNIQUE_IDENTIFIER, JOIN_TOKENS(_,subname))
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Macros producing the Plugin
+// (see myplugin.h for an example of their output)
+
+#define PLUGIN_DESC(PluginClazz, facility, version) \
+ \
+class PluginClazz : public Plugin { \
+public: \
+    GUID_FOR(PluginClazz, facility, version) \
+ \
+    virtual const ObjectPlugins& getObjectPlugins() const { \
+        typedef std::pair<const BGUID, ObjectPlugin*> the_pair; \
+        typedef std::pair<ObjectPlugins::iterator, bool> ret_pair; \
+        static ObjectPlugins plugins;
+
+#define PLUGGED_OBJECT(ObjectClazz) \
+        static ObjectPluginImpl<ObjectClazz> GENERATE_UNIQUE_IDENTIFIER_SUB(plug); \
+        static ret_pair GENERATE_UNIQUE_IDENTIFIER_SUB(insert) = plugins.insert( \
+            the_pair(  GENERATE_UNIQUE_IDENTIFIER_SUB(plug).get_GUID(), \
+                      &GENERATE_UNIQUE_IDENTIFIER_SUB(plug)) );
+
+#define PLUGIN_END_EX2(PluginClazz, AccName) \
+        return plugins; \
+    } \
+}; \
+ \
+const Plugin& AccName() { \
+    static PluginClazz plugin; \
+    return plugin; \
+}
+
+#define PLUGIN_END_EX(PluginClazz) PLUGIN_END_EX2(PluginClazz, get##PluginClazz)
+#define PLUGIN_END(PluginClazz)    PLUGIN_END_EX2(PluginClazz, getPlugin)
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif /* ZZ_PLUGIN_DETAIL_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/rcobject.cpp (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/rcobject.cpp)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/rcobject.cpp	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/rcobject.cpp	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,83 @@
+//http://www.aristeia.com/BookErrata/M29Source_frames.html
+
+#include "stdafx.h"
+
+#include "rcobject.h"
+
+//#include "debugmem.h" no allocations here
+
+namespace Browser {
+
+/******************************************************************************
+*                                                                             *
+*        Code from Item 29 ("Reference Counting") of MORE EFFECTIVE C++       *
+*                                                                             *
+*                               Scott Meyers                                  *   
+*                                                                             *
+*            Copyright 1996 (c) Addison-Wesley Publishing Company             *
+*       You are free to use this code for non-commercial purposes only.       *
+*                                                                             *
+* The code here reflects all changes made to date in response to bug reports  *
+* from readers of the book.  (To see a complete list of known bugs in More    *
+* Effective C++, as well as whether they've been fixed yet, visit the         *
+* More Effective C++ Errata List.)  If you find any additional bugs, please   *
+* send them to me.                                                            *
+******************************************************************************/
+
+/******************************************************************************
+*                       Class RCObject (from pp. 204-205)                     *
+*                       Modified by Zbyl                                      *
+******************************************************************************/
+
+RCObject::RCObject()
+: refCount(0), shareable(true) {}
+
+RCObject::RCObject(const RCObject&)
+: refCount(0), shareable(true) {}
+
+RCObject& RCObject::operator=(const RCObject&)
+{
+    return *this;
+}  
+
+RCObject::~RCObject() {}
+
+void RCObject::addReference() 
+{
+    if (++refCount == 1) {
+        initialize();
+    }
+}
+
+void RCObject::removeReference()
+{
+    if (--refCount == 0) {
+        destroy();
+        delete this;
+    }
+}
+
+void RCObject::markUnshareable()
+{
+    shareable = false;
+}
+
+bool RCObject::isShareable() const
+{
+    return shareable;
+}
+
+bool RCObject::isShared() const
+{
+    return refCount > 1;
+}  
+
+int RCObject::getRefCount() const { //debug only
+    return refCount;
+}
+
+/******************************************************************************
+* END.                                                                        *
+******************************************************************************/  
+
+} // namespace Browser

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/rcobject.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/rcobject.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/rcobject.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/rcobject.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,504 @@
+//http://www.aristeia.com/BookErrata/M29Source_frames.html
+
+#pragma once
+#ifndef ZZ_MEYERS_H
+#define ZZ_MEYERS_H
+
+namespace Browser {
+
+/******************************************************************************
+*                                                                             *
+*        Code from Item 29 ("Reference Counting") of MORE EFFECTIVE C++       *
+*                                                                             *
+*                               Scott Meyers                                  *   
+*                                                                             *
+*            Copyright 1996 (c) Addison-Wesley Publishing Company             *
+*       You are free to use this code for non-commercial purposes only.       *
+*                                                                             *
+* This page contains the code for the classes and class templates making up   *
+* the Reference Counting Item of More Effective C++.  To use this code,       *
+* either copy this page and paste it into a C++ source file or save the       *
+* entire page as text into a C++ source file.  Don't save the HTML source     *
+* and expect that to compile :-)                                              *
+*                                                                             *
+* Each class or template in this file follows a block comment that shows the  *
+* corresponding pages in the book.  This page also contains a main function   *
+* that performs a VERY limited test of the code in this file.  You can        *
+* compile the code in this file as a stand-alone program, and you should get  *
+* this output:                                                                *
+*                                                                             *
+*     String with no changes.                                                 *
+*     String with    changes.                                                 *
+*     10                                                                      *
+*     -1                                                                      *
+*                                                                             *
+* The code here reflects all changes made to date in response to bug reports  *
+* from readers of the book.  (To see a complete list of known bugs in More    *
+* Effective C++, as well as whether they've been fixed yet, visit the         *
+* More Effective C++ Errata List.)  If you find any additional bugs, please   *
+* send them to me.                                                            *
+******************************************************************************/
+//#include <iostream>      // The iostream facilities are not used in the classes
+// in this file, but they are used in the code that 
+// tests the classes.
+
+//#include <cstring>       // This includes the C string functions, e.g.,
+// strlen, strcpy, etc.  They are used in the
+// implementation of class String::StringValue.
+
+// The following is for compilers that don't support bool.  Uncomment these
+// lines if your compilers lack bool support.  For details on this emulation
+// of bool, see More Effective C++, pp. 3-4.
+// typedef int bool;
+// const bool false = 0;
+// const bool true = 1;
+
+/******************************************************************************
+*                       Class RCObject (from pp. 204-205)                     *
+*                       Modified by Zbyl                                      *
+******************************************************************************/
+
+class RCObject {                       // base class for reference-
+public:                                // counted objects
+    void addReference();
+    void removeReference();
+    void markUnshareable();
+    bool isShareable() const;
+    bool isShared() const;
+
+    int getRefCount() const; //debug only
+
+    //Object Life Cycle:
+    //  b = new RCObject();
+    //  b->initialize();      //automatic (called by addReference)
+    //  ...
+    //  b->destroy();         //automatic (called by removeReference)
+    //If you don't use addReference/removeReference you have to call them manually.
+
+    //when overriding those allways run super first
+    virtual void initialize() {}
+    virtual void destroy() {}
+
+
+protected:
+    RCObject();
+    RCObject(const RCObject& rhs);
+    RCObject& operator=(const RCObject& rhs);
+    virtual ~RCObject() = 0;
+
+private:
+    int refCount;
+    bool shareable;
+};
+
+/******************************************************************************
+*                 Template Class RCPtr (from pp. 203, 206)                    *
+*                 Modified by Zbyl                                            *
+******************************************************************************/
+template<class T>                      // template class for smart
+class RCPtr {                          // pointers-to-T objects; T
+                                       // must support the RCObject interface
+    template<typename S>
+    friend class RCPtr;
+
+public:
+    RCPtr(T* realPtr = 0);
+    RCPtr(const RCPtr& rhs);
+    template<typename S>
+    RCPtr(const RCPtr<S>& rhs);
+    ~RCPtr();
+    RCPtr& operator=(const RCPtr& rhs);
+    template<typename S>
+    RCPtr& operator=(const RCPtr<S>& rhs);
+    T* operator->() const;
+    T& operator*() const;
+
+    T* get() const;
+
+private:
+    T *pointee;
+    void init();
+};
+
+template<class T>
+void RCPtr<T>::init()
+{
+    if (pointee == 0) return;
+
+    ASSERT( pointee->isShareable() );
+    /*if (pointee->isShareable() == false) {
+        pointee = new T(*pointee);
+    }*/
+
+    pointee->addReference();
+}
+
+template<class T>
+RCPtr<T>::RCPtr(T* realPtr)
+: pointee(realPtr)
+{
+    init();
+}
+
+template<class T>
+RCPtr<T>::RCPtr(const RCPtr& rhs)
+: pointee(rhs.pointee)
+{ 
+    init();
+}
+
+template<class T>
+template<class S>
+RCPtr<T>::RCPtr(const RCPtr<S>& rhs)
+: pointee(rhs.pointee)
+{ 
+    init();
+}
+
+template<class T>
+RCPtr<T>::~RCPtr()
+{
+    if (pointee) pointee->removeReference();
+}
+
+template<class T>
+RCPtr<T>& RCPtr<T>::operator=(const RCPtr& rhs)
+{
+    if (pointee != rhs.pointee) {                   // this code was modified
+        T *oldPointee = pointee;                    // for the book's 10th
+        // printing
+        pointee = rhs.pointee;
+        init(); 
+
+        if (oldPointee) oldPointee->removeReference();                
+    }
+
+    return *this;
+}
+
+template<class T>
+template<class S>
+RCPtr<T>& RCPtr<T>::operator=(const RCPtr<S>& rhs)
+{
+    if (pointee != rhs.pointee) {                   // this code was modified
+        T *oldPointee = pointee;                    // for the book's 10th
+        // printing
+        pointee = rhs.pointee;
+        init(); 
+
+        if (oldPointee) oldPointee->removeReference();                
+    }
+
+    return *this;
+}
+
+template<class T>
+T* RCPtr<T>::get() const 
+{
+    return pointee;
+}
+
+template<class T>
+T* RCPtr<T>::operator->() const 
+{
+    return pointee;
+}
+
+template<class T>
+T& RCPtr<T>::operator*() const
+{
+    return *pointee;
+}
+
+// taken from boost intrusive_ptr, and modified
+
+template<class T> inline bool operator==(RCPtr<T> const & a, RCPtr<T> const & b)
+{
+    return a.get() == b.get();
+}
+
+template<class T> inline bool operator!=(RCPtr<T> const & a, RCPtr<T> const & b)
+{
+    return a.get() != b.get();
+}
+
+/*template<class T> inline bool operator==(RCPtr<T> const & a, T * b)
+{
+    return a.get() == b;
+}
+
+template<class T> inline bool operator!=(RCPtr<T> const & a, T * b)
+{
+    return a.get() != b;
+}
+
+template<class T> inline bool operator==(T * a, RCPtr<T> const & b)
+{
+    return a == b.get();
+}
+
+template<class T> inline bool operator!=(T * a, RCPtr<T> const & b)
+{
+    return a != b.get();
+}*/
+
+template<class T> inline bool operator<(RCPtr<T> const & a, RCPtr<T> const & b)
+{
+    return std::less<T *>()(a.get(), b.get());
+}
+
+/******************************************************************************
+*           Classes String and StringValue (from pp. 204, 206-207)            *
+******************************************************************************
+class String {                          // class to be used by
+public:                                 // application developers
+    String(const char *value = "");
+
+    char operator[](int index) const;       
+    char& operator[](int index);
+
+private:
+    // class representing string values
+    struct StringValue: public RCObject {
+        char *data;
+
+        StringValue(const char *initValue);
+        StringValue(const StringValue& rhs);
+        void init(const char *initValue);
+        ~StringValue();
+    };
+
+    RCPtr<StringValue> value;                       
+
+    // This function is not in the book, but it's convenient for testing the
+    // class -- see below.
+    friend std::ostream& operator<<(std::ostream& stream, const String& string);
+};
+
+void String::StringValue::init(const char *initValue)
+{
+    using namespace std;
+
+    data = new char[strlen(initValue) + 1];
+    strcpy(data, initValue);
+}
+
+String::StringValue::StringValue(const char *initValue)
+{ 
+    init(initValue);
+}
+
+String::StringValue::StringValue(const StringValue& rhs)
+{
+    init(rhs.data);
+}
+
+String::StringValue::~StringValue()
+{
+    delete [] data;
+}
+
+
+String::String(const char *initValue)
+: value(new StringValue(initValue)) {}
+
+char String::operator[](int index) const
+{
+    return value->data[index];
+}
+
+char& String::operator[](int index)
+{ 
+    if (value->isShared()) {      
+        value = new StringValue(value->data);
+    }
+
+    value->markUnshareable();
+
+    return value->data[index];
+}
+
+std::ostream& operator<<(std::ostream& stream, const String& string)
+{
+    return stream << string.value->data;
+}
+
+
+/******************************************************************************
+*                  Template Class RCIPtr (from pp. 209-210)                   *
+*                                                                             *
+* The code for RCIPtr has changed over the years in response to errors        *
+* both in the original source code as well as in the subsequent fixes.  You   *
+* can find a complete list of changes at the More Effective C++ errata page.  *
+* The code here is accurate as of the 13th printing of the book.              *
+******************************************************************************
+template<class T>
+class RCIPtr {
+public:
+    RCIPtr(T* realPtr = 0);
+    RCIPtr(const RCIPtr& rhs);
+    ~RCIPtr();
+    RCIPtr& operator=(const RCIPtr& rhs);
+
+    T* operator->() const;
+    T& operator*() const;
+
+    RCObject& getRCObject()               // give clients access to
+    { return *counter; }                  // isShared, etc.
+
+private:
+    struct CountHolder: public RCObject {
+        ~CountHolder() { delete pointee; }
+        T *pointee;
+    };
+
+    CountHolder *counter;
+    void init();
+};
+
+template<class T>
+void RCIPtr<T>::init()
+{
+    if (counter->isShareable() == false) {
+        T *oldValue = counter->pointee;
+        counter = new CountHolder;
+        counter->pointee = oldValue ? new T(*oldValue) : 0;
+    } 
+
+    counter->addReference();
+}
+
+template<class T>
+RCIPtr<T>::RCIPtr(T* realPtr)
+: counter(new CountHolder)
+{ 
+    counter->pointee = realPtr;
+    init();
+}
+
+template<class T>
+RCIPtr<T>::RCIPtr(const RCIPtr& rhs)
+: counter(rhs.counter)
+{ init(); }
+
+template<class T>
+RCIPtr<T>::~RCIPtr()
+{ counter->removeReference(); }
+
+template<class T>
+RCIPtr<T>& RCIPtr<T>::operator=(const RCIPtr& rhs)
+{
+    if (counter != rhs.counter) {         
+        counter->removeReference();     
+        counter = rhs.counter;
+        init();
+    }
+    return *this;
+}
+
+template<class T>
+T* RCIPtr<T>::operator->() const
+{ return counter->pointee; }
+
+template<class T>
+T& RCIPtr<T>::operator*() const
+{ return *(counter->pointee); }
+
+
+/******************************************************************************
+*                          Class Widget (from p. 210)                         *
+*                                                                             *
+* This class is the same as that in the book, but I've added an               *
+* implementation so that RCIPtr can be tested.                                *
+******************************************************************************
+class Widget {
+public:
+    Widget(int size): value(size) {}
+    Widget(const Widget& rhs): value(rhs.value) {}
+    ~Widget() {}
+
+    Widget& operator=(const Widget& rhs)
+    {
+        value = rhs.value;
+        return *this; 
+    }
+
+    void doThis()
+    { value = -1; }
+
+    int showThat() const
+    { return value; }
+
+private:
+    int value;
+};
+
+
+/******************************************************************************
+*                         Class RCWidget (from p. 210)                        *
+*                                                                             *
+* I modified this class for the 13th printing of the book.  For details on    *
+* why, consult the erratum affecting pages 209, 210, and 316 that was fixed   *
+* on 7/15/02 in the book's errata list.                                       *
+******************************************************************************
+class RCWidget {
+public:
+    RCWidget(int size)
+        : value(new Widget(size)) {}
+
+    void doThis()
+    {
+        if (value.getRCObject().isShared()) {         // do COW if 
+            value = new Widget(*value);                 // Widget is shared
+        }
+        value->doThis();
+    }
+
+    int showThat() const
+    { return value->showThat(); }
+
+private:
+    RCIPtr<Widget> value;
+};
+
+
+/******************************************************************************
+* Functions to perform VERY simple test of the above.                         *
+******************************************************************************  
+void testRCPtr()
+{
+    String s1 = "String with no changes.";
+    String s2(s1);
+
+    s2[12] = s2[13] = ' ';
+
+    std::cout << s1 << '\n';      // prints "String with no changes."
+    std::cout << s2 << '\n';      // prints "String with    changes."
+}
+
+void testRCIPtr()
+{
+    RCWidget w1(10);
+    RCWidget w2(w1);
+
+    w2.doThis();
+
+    std::cout << w1.showThat() << '\n';       // prints 10
+    std::cout << w2.showThat() << '\n';       // prints -1
+}
+
+int main()
+{
+    testRCPtr();
+    testRCIPtr();
+
+    return 0;
+}
+
+/******************************************************************************
+* END.                                                                        *
+******************************************************************************/  
+
+} // namespace Browser
+
+#endif /* ZZ_MEYERS_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/stdafx.cpp (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/stdafx.cpp)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/stdafx.cpp	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/stdafx.cpp	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// PinSlot.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/stdafx.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/stdafx.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/stdafx.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/stdafx.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+//#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
+//#include <stdio.h>
+//#include <tchar.h>
+
+
+
+// TODO: reference additional headers your program requires here

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/tostring.h)
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h	                        (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h	2007-07-01 17:02:35 UTC (rev 27829)
@@ -0,0 +1,32 @@
+/////////////////////////////////////////////////////////////////////////////
+// tostring.h
+//
+// Declares toString() template
+//
+
+#pragma once
+#ifndef ZZ_TO_STRING_H
+#define ZZ_TO_STRING_H
+
+#include <string>
+#include <sstream> // only for implementation
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+template<typename T>
+inline /* inline just for now */
+std::string toString(T& obj) {
+    std::ostringstream oss;
+    oss << obj;
+    return oss.str();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
+
+#endif /* ZZ_TO_STRING_H */

Copied: scummex/branches/gsoc2007-gameresbrowser/src/core/treealgos.h (from rev 27702, scummex/branches/gsoc2007-gameresbrowser/src/treealgos.h)
===================================================================

@@ 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