Created mechanism for listeners to hear about object death.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@535 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-10-23 23:56:12 +00:00
parent 218eea6dc2
commit 15ff048a27
2 changed files with 33 additions and 4 deletions
@@ -0,0 +1,21 @@
//
// $Id: ObjectDeathListener.java,v 1.1 2001/10/23 23:56:12 mdb Exp $
package com.threerings.presents.dobj;
/**
* Implemented by entites which wish to hear about object destruction
* events.
*
* @see DObject#addListener
*/
public interface ObjectDeathListener
{
/**
* Called when this object has been destroyed. This will be called
* <em>after</em> the event has been applied to the object.
*
* @param event The event that was dispatched on the object.
*/
public void objectDestroyed (ObjectDestroyedEvent event);
}
@@ -1,5 +1,5 @@
// //
// $Id: ObjectDestroyedEvent.java,v 1.2 2001/10/11 04:07:52 mdb Exp $ // $Id: ObjectDestroyedEvent.java,v 1.3 2001/10/23 23:56:12 mdb Exp $
package com.threerings.presents.dobj; package com.threerings.presents.dobj;
@@ -39,9 +39,7 @@ public class ObjectDestroyedEvent extends TypedEvent
{ {
} }
/** // documentation inherited
* Applies this attribute change to the object.
*/
public boolean applyToObject (DObject target) public boolean applyToObject (DObject target)
throws ObjectAccessException throws ObjectAccessException
{ {
@@ -50,11 +48,21 @@ public class ObjectDestroyedEvent extends TypedEvent
return true; return true;
} }
// documentation inherited
public short getType () public short getType ()
{ {
return TYPE; return TYPE;
} }
// documentation inherited
protected void notifyListener (Object listener)
{
if (listener instanceof ObjectDeathListener) {
((ObjectDeathListener)listener).objectDestroyed(this);
}
}
// documentation inherited
protected void toString (StringBuffer buf) protected void toString (StringBuffer buf)
{ {
buf.append("DESTROY:"); buf.append("DESTROY:");