home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Linux
/
Divers
/
freedraft.tar.gz
/
freedraft.tar
/
FREEdraft-050298
/
DATAENGINE
/
geombank.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-04-19
|
2KB
|
84 lines
// geombank.cpp
// Copyright (C) 1997, 1998 Cliff Johnson //
// //
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the GNU General Public //
// License as published by the Free Software Foundation; either //
// version 2 of the License, or (at your option) any later version. //
// //
// This software is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
// General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this software (see COPYING.LIB); if not, write to the //
// Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
#include <geombank.h> //THIS
#include <locale_enum.h>
#include <algo.h> //ITO
#include <bankexception.h>
Handle GeomBank::Create(Geom* gx)
{
Handle hx(gx,PERSISTENT);
handleArray.push_back(hx);
return hx;
}
bool GeomBank::Destroy(const Handle& h)
{
Handle tmp;
list<Handle>::iterator i;
i = find(handleArray.begin(),handleArray.end(),h);
if ( i != handleArray.end() ){
// delete the memory allocated by the handle
tmp = Handle(*i);
// remove the handle from the list
handleArray.erase(i++);
// toast it
return tmp.Destroy();
}
else return false;
}
void GeomBank::Print(ostream& os)
{
list<Handle>::iterator i;
for(i=handleArray.begin(); i!=handleArray.end(); i++)
os << Handle(*i) << '\n';
}
Handle GeomBank::GetHandleFromPointer(const Geom* ptr) const throw (BankException)
{
// find the handle with the input address or throw an exception
// by brute force of course! Actually I'm having trouble figgering
// out the proper operators to add to the handle class to make if work
// with find... So brute force it will be.
Handle tmp;
list<Handle>::const_iterator i;
for(i=handleArray.begin(); i!=handleArray.end(); i++)
{
tmp = Handle(*i);
if(tmp == ptr)return tmp;
}
throw BankException("GeomBank::GetHandleFromPointer() : geometry handle not found");
}