#if !defined(_INLINE)
static char cvsid[] = "@(#)$Id$";
static char debugFileId[] = __FILE__;
#endif
#include "containers/lists/List.hpp"
#include "events/EventAdapter.hpp"
#include "LinkManager.hpp"
#include "OGuard.hpp"
#include "Debug.hpp"
EventAdapter::EventAdapter( const Top *aSource ) :
source( aSource )
{
preC_( source != nil );
LinkManager::reg( this, source );
}
EventAdapter::~EventAdapter()
{
LinkManager::free( this, source );
}
const Top *EventAdapter::getSource() const
{
return source;
}
boolean EventAdapter::selfFire()
{
ObservationContext *context;
OGuard _this( this, this );
context = new ObservationContext();
OGuard _context( context, this );
return fire( this, context );
}
boolean EventAdapter::fire( Condition *aCondition,
ObservationContext *aContext )
{
preC_( aCondition != ( Condition * ) NIL );
preC_( aContext != ( ObservationContext * ) NIL );
OGuard _this( this, this );
OGuard _condition( aCondition, this );
OGuard _context( aContext, this );
return( ObservableAdapter::fire( aCondition, aContext ) &
fireOnList( ObservableAdapter::getClassPassives(),
aCondition, aContext ) );
}
List *EventAdapter::getClassPassives()
{
if( eventClassPassives == ( List * ) NIL )
{
eventClassPassives = new List();
eventClassPassives -> dontManage();
}
return eventClassPassives;
}
boolean EventAdapter::equals( const Top *anOther ) const
{
EventAdapter *other;
OGuard _this( this, this );
other = DCAST( anOther, EventAdapter );
if( other == ( EventAdapter * ) NIL )
{
return false;
}
else
{
OGuard _other( other, this );
return( getSource() -> equals( getSource() ) );
}
}
Top *EventAdapter::clone() const
{
return new EventAdapter( getSource() );
}
String EventAdapter::toString() const
{
return ObservableAdapter::toString() +
" source: " + getSource() -> toString();
}
String EventAdapter::getString() const
{
return ObservableAdapter::getString() +
" source: " + getSource() -> getString();
}
String EventAdapter::getClassName() const
{
return "EventAdapter";
}
List *EventAdapter::eventClassPassives = ( List * ) NIL;
#if defined(_INLINE)
#include "../src/Debug.ipp"
#endif