mirror of https://github.com/PCSX2/pcsx2.git
Resolve some Linux/GCC errors.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1976 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
eda5d1d834
commit
d30673c5ca
|
@ -94,5 +94,6 @@ class wxString;
|
|||
#include <cstring> // string.h under c++
|
||||
#include <cstdio> // stdio.h under c++
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
|
||||
#include "Utilities/Assertions.h"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <wx/event.h>
|
||||
|
||||
template< typename EvtType >
|
||||
|
@ -52,9 +53,9 @@ template< typename EvtType >
|
|||
class EventSource
|
||||
{
|
||||
public:
|
||||
typedef typename EventListener<EvtType> 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 )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -182,23 +183,30 @@ void EventSource<EvtType>::Add( const ListenerType& listener )
|
|||
AddFast( listener );
|
||||
}
|
||||
|
||||
// removes all listeners which reference the given object. Use for assuring object deletion.
|
||||
template< typename EvtType >
|
||||
void EventSource<EvtType>::RemoveObject( const void* object )
|
||||
{
|
||||
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 )
|
||||
bool operator()( const ListenerType& src ) const
|
||||
{
|
||||
return src.object == m_object_match;
|
||||
}
|
||||
};
|
||||
m_listeners.remove_if( PredicatesAreTheThingsOfNightmares( object ) );
|
||||
|
||||
// removes all listeners which reference the given object. Use for assuring object deletion.
|
||||
template< typename EvtType >
|
||||
void EventSource<EvtType>::RemoveObject( const void* object )
|
||||
{
|
||||
// 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. >_<
|
||||
|
||||
m_listeners.remove_if( PredicatesAreTheThingsOfNightmares<EvtType>( object ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
#include <cstring> // string.h under c++
|
||||
#include <cstdio> // stdio.h under c++
|
||||
|
|
Loading…
Reference in New Issue