Advertisement
Guest User

Atom and Mol Destructor

a guest
Jun 16th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. //Atom destructor
  2. OBAtom::~OBAtom()
  3.   {
  4.     if (_residue != NULL)
  5.       {
  6.         _residue->RemoveAtom(this);
  7.       }
  8.     /*
  9.       if (!_vdata.empty())
  10.       {
  11.       vector<OBGenericData*>::iterator m;
  12.       for (m = _vdata.begin();m != _vdata.end();++m)
  13.       delete *m;
  14.       _vdata.clear();
  15.       }
  16.     */
  17.   }
  18.  
  19. //OBMol destructor
  20. OBMol::~OBMol()
  21.   {
  22.     OBAtom    *atom;
  23.     OBBond    *bond;
  24.     OBResidue *residue;
  25.     vector<OBAtom*>::iterator i;
  26.     vector<OBBond*>::iterator j;
  27.     vector<OBResidue*>::iterator r;
  28.    
  29.     for (atom = BeginAtom(i);atom;atom = NextAtom(i))
  30.       DestroyAtom(atom);
  31.     for (bond = BeginBond(j);bond;bond = NextBond(j))
  32.       DestroyBond(bond);
  33.     for (residue = BeginResidue(r);residue;residue = NextResidue(r))
  34.       DestroyResidue(residue);
  35.  
  36.     //clear out the multiconformer data
  37.     vector<double*>::iterator k;
  38.     for (k = _vconf.begin();k != _vconf.end();++k)
  39.       delete [] *k;
  40.     _vconf.clear();
  41.   }
  42.  
  43. //function called within OBMol to destroy residue
  44. void OBMol::DestroyResidue(OBResidue *residue)
  45.   {
  46.     if (residue)
  47.       {
  48.         delete residue;
  49.         residue = NULL;
  50.       }
  51.   }
  52.  
  53. //Residue destructor
  54. OBResidue::~OBResidue()
  55.   {
  56.     vector<OBAtom*>::iterator a;
  57.     for ( a = _atoms.begin() ; a != _atoms.end() ; a++ )
  58.       (*a)->SetResidue(NULL);
  59.     _atoms.clear();
  60.  
  61.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement