source: golgotha/src/golg/reference.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.3 KB
Line 
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
9#include "reference.hh"
10#include "g1_object.hh"
11
12
13void g1_reference_class::remove_ref()
14{
15  i4_isl_list<g1_reference_class>::iterator i=ref->ref_list.begin(), last=ref->ref_list.end();
16
17  for (; i!=ref->ref_list.end(); ++i)
18  {
19    if ((&*i)==this)
20    {
21      if (last==ref->ref_list.end())
22        ref->ref_list.erase();
23      else       
24        ref->ref_list.erase_after(last);
25      ref=0;
26      return;
27    }
28    last=i;
29  }
30  i4_error("remove reference : not found");
31}
32
33void g1_reference_class::reference_object(g1_object_class *object_being_referenced)
34{
35  if (ref)
36    remove_ref();
37
38  if (object_being_referenced)
39  {
40    ref=object_being_referenced;
41
42    ref->ref_list.insert(*this);
43  }
44  else
45    ref=0;
46}
47
48g1_reference_class::~g1_reference_class()
49{
50  if (ref) remove_ref();
51}
Note: See TracBrowser for help on using the repository browser.