reference.cc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /********************************************************************** <BR>
  2. This file is part of Crack dot Com's free source code release of
  3. Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
  4. information about compiling & licensing issues visit this URL</a>
  5. <PRE> If that doesn't help, contact Jonathan Clark at
  6. golgotha_source@usa.net (Subject should have "GOLG" in it)
  7. ***********************************************************************/
  8. #include "reference.hh"
  9. #include "g1_object.hh"
  10. void g1_reference_class::remove_ref()
  11. {
  12. i4_isl_list<g1_reference_class>::iterator i=ref->ref_list.begin(), last=ref->ref_list.end();
  13. for (; i!=ref->ref_list.end(); ++i)
  14. {
  15. if ((&*i)==this)
  16. {
  17. if (last==ref->ref_list.end())
  18. ref->ref_list.erase();
  19. else
  20. ref->ref_list.erase_after(last);
  21. ref=0;
  22. return;
  23. }
  24. last=i;
  25. }
  26. i4_error("remove reference : not found");
  27. }
  28. void g1_reference_class::reference_object(g1_object_class *object_being_referenced)
  29. {
  30. if (ref)
  31. remove_ref();
  32. if (object_being_referenced)
  33. {
  34. ref=object_being_referenced;
  35. ref->ref_list.insert(*this);
  36. }
  37. else
  38. ref=0;
  39. }
  40. g1_reference_class::~g1_reference_class()
  41. {
  42. if (ref) remove_ref();
  43. }