/******************************************************************************
 **
 **	C++ Class Library for the Amiga© system software.
 **
 **	Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
 **	All Rights Reserved.
 **
 **	$Source: apphome:APlusPlus/RCS/libsource/ObjectList.cxx,v $
 **	$Revision: 1.3 $
 **	$Date: 1994/04/23 21:02:13 $
 **	$Author: Armin_Vogt $
 **
 ******************************************************************************/


#include <APlusPlus/exec/ObjectList.h>
#include <APlusPlus/environment/APPObject.h>


volatile static char rcs_id[] = "$Id: ObjectList.cxx,v 1.3 1994/04/23 21:02:13 Armin_Vogt Exp Armin_Vogt $";


TObjList::~TObjList()
   /* Delete all traced objects at the end of the programm.
   */
{
   FOREACHSAFE(TObjNode, this)
   {
      delete node;
   }
   NEXTSAFE
   _dout("~TObjList done\n");
}

ReferenceNode *ReferenceList::findObject(APTR objectptr,UBYTE objtype)
{
   FOREACHOF(ReferenceNode,this)
      if (objectptr==NULL || node->object() == objectptr)
         if (objtype==0 || node->type() == objtype) return node;

   return NULL;
}

void TObjList::deleteTObj(APTR obj)
{
   TObjNode *node;

   if (node = (TObjNode*)findObject(obj))
   {
      delete node;   // remove node, free resource and free memory
   }
}
