From d30673c5ca1c3f3f5bbbcadd3e0d4471a71cbe89 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 7 Oct 2009 20:50:39 +0000 Subject: [PATCH] Resolve some Linux/GCC errors. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1976 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Utilities/Dependencies.h | 5 +- common/include/Utilities/Listeners.h | 62 ++++++++++++++----------- pcsx2/PrecompiledHeader.h | 1 + 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/common/include/Utilities/Dependencies.h b/common/include/Utilities/Dependencies.h index 0f40db2b0c..4875f1d7b7 100644 --- a/common/include/Utilities/Dependencies.h +++ b/common/include/Utilities/Dependencies.h @@ -1,6 +1,6 @@ /* PCSX2 - PS2 Emulator for PCs * Copyright (C) 2002-2009 PCSX2 Dev Team - * + * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -64,7 +64,7 @@ protected: // Use this macro/class as a base to seal a class from being derived from. // This macro works by providing a unique base class with a protected constructor -// for every class that derives from it. +// for every class that derives from it. #define Sealed private virtual __BaseSealed<__COUNTER__> @@ -94,5 +94,6 @@ class wxString; #include // string.h under c++ #include // stdio.h under c++ #include +#include #include "Utilities/Assertions.h" diff --git a/common/include/Utilities/Listeners.h b/common/include/Utilities/Listeners.h index e1ee2b4ed9..c19ab14c3b 100644 --- a/common/include/Utilities/Listeners.h +++ b/common/include/Utilities/Listeners.h @@ -15,6 +15,7 @@ #pragma once +#include #include template< typename EvtType > @@ -24,7 +25,7 @@ struct EventListener void* object; FuncType* OnEvent; - + EventListener( FuncType* fnptr ) { object = NULL; @@ -36,12 +37,12 @@ struct EventListener object = objhandle; OnEvent = fnptr; } - + bool operator ==( const EventListener& right ) const { return (object == right.object) && (OnEvent == right.OnEvent); } - + bool operator !=( const EventListener& right ) const { return this->operator ==(right); @@ -52,10 +53,10 @@ template< typename EvtType > class EventSource { public: - typedef typename EventListener ListenerType; + typedef EventListener< EvtType > ListenerType; typedef typename std::list< ListenerType > ListenerList; - typedef typename ListenerList::const_iterator Handle; - + typedef typename ListenerList::iterator Handle; + protected: ListenerList m_listeners; @@ -103,9 +104,9 @@ public: } catch( Exception::RuntimeError& ex ) { - Console::Error( L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage() ); + Console.Error( L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage() ); } - catch( BaseException& ex ) + catch( Exception::BaseException& ex ) { } } @@ -125,10 +126,10 @@ public: typedef typename EventSource::Handle ConstIterator; protected: - EventSource& m_source; - const ListenerHandle m_listener; - ConstIterator m_iter; - bool m_attached; + EventSource& m_source; + const ListenerHandle m_listener; + ConstIterator m_iter; + bool m_attached; public: EventListenerBinding( EventSource& source, const ListenerHandle& listener, bool autoAttach=true ) : @@ -141,12 +142,12 @@ public: //if( !pxAssertDev( listener.OnEvent != NULL, "NULL listener callback function." ) ) return; if( autoAttach ) Attach(); } - + virtual ~EventListenerBinding() throw() { Detach(); } - + void Detach() { if( !m_attached ) return; @@ -182,23 +183,30 @@ void EventSource::Add( const ListenerType& listener ) AddFast( listener ); } +template< typename EvtType > +class PredicatesAreTheThingsOfNightmares +{ + typedef EventListener< EvtType > ListenerType; + +protected: + const void* const m_object_match; + +public: + PredicatesAreTheThingsOfNightmares( const void* objmatch ) : m_object_match( objmatch ) { } + + bool operator()( const ListenerType& src ) const + { + return src.object == m_object_match; + } +}; + // removes all listeners which reference the given object. Use for assuring object deletion. template< typename EvtType > void EventSource::RemoveObject( const void* object ) { - class PredicatesAreTheThingsOfNightmares - { - protected: - const void* const m_object_match; + // Iso C++ rules regarding temporaries, specifically that non-const temporaries are disallowed, + // also removes any actual convenience factor that unary predicates may have actually offered. >_< - public: - PredicatesAreTheThingsOfNightmares( const void* objmatch ) : m_object_match( objmatch ) { } - - bool operator()( const ListenerType& src ) - { - return src.object == m_object_match; - } - }; - m_listeners.remove_if( PredicatesAreTheThingsOfNightmares( object ) ); + m_listeners.remove_if( PredicatesAreTheThingsOfNightmares( object ) ); } diff --git a/pcsx2/PrecompiledHeader.h b/pcsx2/PrecompiledHeader.h index 3212393c92..2f4c10604b 100644 --- a/pcsx2/PrecompiledHeader.h +++ b/pcsx2/PrecompiledHeader.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include // string.h under c++ #include // stdio.h under c++