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:
Jake.Stine 2009-10-07 20:50:39 +00:00
parent eda5d1d834
commit d30673c5ca
3 changed files with 39 additions and 29 deletions

View File

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

View File

@ -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 )
{
}
}
@ -125,10 +126,10 @@ public:
typedef typename EventSource<EvtType>::Handle ConstIterator;
protected:
EventSource<EvtType>& m_source;
const ListenerHandle m_listener;
ConstIterator m_iter;
bool m_attached;
EventSource<EvtType>& m_source;
const ListenerHandle m_listener;
ConstIterator m_iter;
bool m_attached;
public:
EventListenerBinding( EventSource<EvtType>& source, const ListenerHandle& listener, bool autoAttach=true ) :
@ -182,23 +183,30 @@ void EventSource<EvtType>::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<EvtType>::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<EvtType>( object ) );
}

View File

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