diff options
author | Matthew Newhook <matthew@zeroc.com> | 2002-03-13 17:43:14 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2002-03-13 17:43:14 +0000 |
commit | eabb7836cb1261b2c8f4cc0a9ab6d46be5b23660 (patch) | |
tree | 155130cd807eef3c3233d0d73bca167904db55d0 /cpp/demo/Freeze/library/LibraryI.cpp | |
parent | Added Freeze/library demo. (diff) | |
download | ice-eabb7836cb1261b2c8f4cc0a9ab6d46be5b23660.tar.bz2 ice-eabb7836cb1261b2c8f4cc0a9ab6d46be5b23660.tar.xz ice-eabb7836cb1261b2c8f4cc0a9ab6d46be5b23660.zip |
minor cleanups.
Diffstat (limited to 'cpp/demo/Freeze/library/LibraryI.cpp')
-rw-r--r-- | cpp/demo/Freeze/library/LibraryI.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/cpp/demo/Freeze/library/LibraryI.cpp b/cpp/demo/Freeze/library/LibraryI.cpp index f9187c2c602..3c2242eb438 100644 --- a/cpp/demo/Freeze/library/LibraryI.cpp +++ b/cpp/demo/Freeze/library/LibraryI.cpp @@ -149,7 +149,6 @@ LibraryI::createBook(const ::BookDescription& description, const Ice::Current&) BookPrx book = IsbnToBook(_adapter)(description.isbn); try { - book = IsbnToBook(_adapter)(description.isbn); book->ice_ping(); // @@ -167,9 +166,19 @@ LibraryI::createBook(const ::BookDescription& description, const Ice::Current&) BookPtr bookI = new BookI(this, _evictor); bookI->_description = description; + // + // Create a new Ice Object in the evictor, using the new identity + // and the new Servant. + // + // This can throw EvictorDeactivatedException (which indicates an + // internal error). The exception is currently ignored. + // Ice::Identity ident = BookI::createIdentity(description.isbn); _evictor->createObject(ident, bookI); + // + // Add the isbn number to the authors map. + // Ice::StringSeq isbnSeq; StringIsbnSeqDict::iterator p = _authors.find(description.authors); @@ -195,7 +204,6 @@ LibraryI::findByIsbn(const string& isbn, const Ice::Current&) try { - Ice::Identity ident = BookI::createIdentity(isbn); BookPrx book = IsbnToBook(_adapter)(isbn); book->ice_ping(); return book; @@ -263,16 +271,26 @@ LibraryI::remove(const BookDescription& description) throw Freeze::DBNotFoundException(__FILE__, __LINE__); } + // + // Remove the isbn number from the sequence. + // Ice::StringSeq isbnSeq = p->second; isbnSeq.erase(remove_if(isbnSeq.begin(), isbnSeq.end(), bind2nd(equal_to<string>(), description.isbn)), isbnSeq.end()); if (isbnSeq.empty()) { + // + // If there are no further associated isbn numbers then remove + // the record. + // _authors.erase(p); } else { + // + // Otherwise, write back the new record. + // _authors.insert(make_pair(description.authors, isbnSeq)); } } |