From a15264b4c7f270181b0fea3db6b30896596f4ec1 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Thu, 19 Dec 2002 21:57:28 +0000 Subject: adding destroy flag --- cpp/demo/Freeze/library/LibraryI.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'cpp/demo/Freeze/library/LibraryI.cpp') diff --git a/cpp/demo/Freeze/library/LibraryI.cpp b/cpp/demo/Freeze/library/LibraryI.cpp index f24f413033c..8eaed395b37 100644 --- a/cpp/demo/Freeze/library/LibraryI.cpp +++ b/cpp/demo/Freeze/library/LibraryI.cpp @@ -18,7 +18,7 @@ using namespace std; BookI::BookI(const LibraryIPtr& library) : - _library(library) + _library(library), _destroyed(false) { } @@ -31,6 +31,13 @@ BookI::destroy(const Ice::Current&) { IceUtil::RWRecMutex::RLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + + _destroyed = true; + try { _library->remove(description); @@ -52,6 +59,13 @@ BookI::destroy(const Ice::Current&) ::BookDescription BookI::getBookDescription(const Ice::Current&) const { + IceUtil::RWRecMutex::RLock sync(*this); + + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + // Immutable return description; } @@ -61,6 +75,11 @@ BookI::getRenterName(const Ice::Current&) const { IceUtil::RWRecMutex::RLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + if(rentalCustomerName.empty()) { throw BookNotRentedException(); @@ -73,6 +92,11 @@ BookI::rentBook(const ::std::string& name, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + if(!rentalCustomerName.empty()) { throw BookRentedException(); @@ -85,6 +109,11 @@ BookI::returnBook(const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + if(rentalCustomerName.empty()) { throw BookNotRentedException(); -- cgit v1.2.3