diff options
author | Matthew Newhook <matthew@zeroc.com> | 2001-12-05 19:44:24 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2001-12-05 19:44:24 +0000 |
commit | e4418f42b61488dd93424f467757acc985c4fce8 (patch) | |
tree | 9acd35f169de1912920954acf13af8e940ded959 /cpp/src | |
parent | fixes (diff) | |
download | ice-e4418f42b61488dd93424f467757acc985c4fce8.tar.bz2 ice-e4418f42b61488dd93424f467757acc985c4fce8.tar.xz ice-e4418f42b61488dd93424f467757acc985c4fce8.zip |
Freeze::DBMap updates. Removed DBWrapper, operator[]. Added set method to
the iterator.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/DBI.cpp | 33 | ||||
-rw-r--r-- | cpp/src/Freeze/DBI.h | 1 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 8 |
3 files changed, 38 insertions, 4 deletions
diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp index 86bf0f275f9..e68457aaf70 100644 --- a/cpp/src/Freeze/DBI.cpp +++ b/cpp/src/Freeze/DBI.cpp @@ -370,6 +370,39 @@ DBCursorI::curr(Key& key, Value& value) value = Value(static_cast<Byte*>(dbData.data), static_cast<Byte*>(dbData.data) + dbData.size); } +void +DBCursorI::set(const Value& value) +{ + JTCSyncT<JTCMutex> sync(*this); + + if (!_cursor) + { + ostringstream s; + s << _errorPrefix << "\"" << _name << "\" has been closed"; + DBException ex; + ex.message = s.str(); + throw ex; + } + + DBT dbKey, dbData; + memset(&dbKey, 0, sizeof(dbKey)); + memset(&dbData, 0, sizeof(dbData)); + dbData.data = const_cast<void*>(static_cast<const void*>(value.begin())); + dbData.size = value.size(); + + if (_trace >= 1) + { + ostringstream s; + s << "reading current value from database \"" << _name << "\""; + _communicator->getLogger()->trace("DBCursor", s.str()); + } + + // + // Note that the dbKey element is ignored. + // + checkBerkeleyDBReturn(_cursor->c_put(_cursor, &dbKey, &dbData, DB_CURRENT), _errorPrefix, "DBcursor->c_set"); +} + bool DBCursorI::next() { diff --git a/cpp/src/Freeze/DBI.h b/cpp/src/Freeze/DBI.h index 173c874f6d1..e134e272fd9 100644 --- a/cpp/src/Freeze/DBI.h +++ b/cpp/src/Freeze/DBI.h @@ -93,6 +93,7 @@ public: virtual ::Ice::CommunicatorPtr getCommunicator(); virtual void curr(Key& key, Value& value); + virtual void set(const Value& value); virtual bool next(); virtual bool prev(); virtual void del(); diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index 8d32ac46059..0dc0267bba7 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -109,7 +109,7 @@ Freeze::EvictorI::createObject(const Identity& ident, const ObjectPtr& servant) // // Save the new Ice Object to the database. // - _dict[ident] = servant; + _dict.insert(make_pair(ident, servant)); add(ident, servant); if (_trace >= 1) @@ -224,7 +224,7 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const Current& current // This should work - but with MSVC for some reason it does not. Re-examine. // //ObjectPtr servant = p->second; - ObjectPtr servant = p->second.get_value(); + ObjectPtr servant = p->second; // // Add the new Servant to the evictor queue. @@ -288,7 +288,7 @@ Freeze::EvictorI::finished(const ObjectAdapterPtr&, const Current& current, { if (!current.nonmutating) { - _dict[current.identity] = servant; + _dict.insert(make_pair(current.identity, servant)); } } @@ -364,7 +364,7 @@ Freeze::EvictorI::evict() // if (_persistenceMode == SaveUponEviction) { - _dict[ident] = element->servant; + _dict.insert(make_pair(ident, element->servant)); } // |