summaryrefslogtreecommitdiff
path: root/cpp/demo/Freeze/library/Collocated.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-04-17 18:18:56 +0000
committerMarc Laukien <marc@zeroc.com>2002-04-17 18:18:56 +0000
commitba3284190a5c6d7ded9645f00e965c5162393a5b (patch)
tree9d036f1baef585b57bad59e17de5516d9f9882b0 /cpp/demo/Freeze/library/Collocated.cpp
parentgetPropertyAsInt (diff)
downloadice-ba3284190a5c6d7ded9645f00e965c5162393a5b.tar.bz2
ice-ba3284190a5c6d7ded9645f00e965c5162393a5b.tar.xz
ice-ba3284190a5c6d7ded9645f00e965c5162393a5b.zip
property convenience operations
Diffstat (limited to 'cpp/demo/Freeze/library/Collocated.cpp')
-rw-r--r--cpp/demo/Freeze/library/Collocated.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/cpp/demo/Freeze/library/Collocated.cpp b/cpp/demo/Freeze/library/Collocated.cpp
index e3245ee9c5d..5cbd6c29603 100644
--- a/cpp/demo/Freeze/library/Collocated.cpp
+++ b/cpp/demo/Freeze/library/Collocated.cpp
@@ -13,6 +13,8 @@
#include <Parser.h>
using namespace std;
+using namespace Ice;
+using namespace Freeze;
class LibraryCollocated : public Freeze::Application
{
@@ -23,7 +25,7 @@ public:
{
}
- virtual int runFreeze(int argc, char* argv[], const Freeze::DBEnvironmentPtr&);
+ virtual int runFreeze(int argc, char* argv[], const DBEnvironmentPtr&);
};
int
@@ -34,57 +36,54 @@ main(int argc, char* argv[])
}
int
-LibraryCollocated::runFreeze(int argc, char* argv[], const Freeze::DBEnvironmentPtr& dbEnv)
+LibraryCollocated::runFreeze(int argc, char* argv[], const DBEnvironmentPtr& dbEnv)
{
- Ice::PropertiesPtr properties = communicator()->getProperties();
+ PropertiesPtr properties = communicator()->getProperties();
string value;
- Freeze::DBPtr dbBooks = dbEnv->openDB("books", true);
- Freeze::DBPtr dbAuthors = dbEnv->openDB("authors", true);
+ DBPtr dbBooks = dbEnv->openDB("books", true);
+ DBPtr dbAuthors = dbEnv->openDB("authors", true);
//
// Create an Evictor for books.
//
- Freeze::EvictorPersistenceMode mode;
- value = properties->getProperty("Library.SaveAfterMutatingOperation");
- if(!value.empty() && atoi(value.c_str()) > 0)
+ EvictorPtr evictor;
+ if(properties->getPropertyAsInt("Library.SaveAfterMutatingOperation") > 0)
{
- mode = Freeze::SaveAfterMutatingOperation;
+ evictor = dbBooks->createEvictor(SaveAfterMutatingOperation);
}
else
{
- mode = Freeze::SaveUponEviction;
+ evictor = dbBooks->createEvictor(SaveUponEviction);
}
-
- Freeze::EvictorPtr evictor = dbBooks->createEvictor(mode);
- value = properties->getProperty("Library.EvictorSize");
- if(!value.empty())
+ Int evictorSize = properties->getPropertyAsInt("Library.EvictorSize");
+ if(evictorSize > 0)
{
- evictor->setSize(atoi(value.c_str()));
+ evictor->setSize(evictorSize);
}
//
// Create an Object Adapter, use the Evictor as Servant Locator.
//
- Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("LibraryAdapter");
+ ObjectAdapterPtr adapter = communicator()->createObjectAdapter("LibraryAdapter");
adapter->addServantLocator(evictor, "book");
//
// Create the library, and add it to the Object Adapter.
//
LibraryIPtr library = new LibraryI(adapter, dbAuthors, evictor);
- adapter->add(library, Ice::stringToIdentity("library"));
+ adapter->add(library, stringToIdentity("library"));
//
// Create and install a factory and initializer for books.
//
- Ice::ObjectFactoryPtr bookFactory = new BookFactory(library);
+ ObjectFactoryPtr bookFactory = new BookFactory(library);
communicator()->addObjectFactory(bookFactory, "::Book");
//
// Everything ok, let's go.
//
- int runParser(int, char*[], const Ice::CommunicatorPtr&);
+ int runParser(int, char*[], const CommunicatorPtr&);
int status = runParser(argc, argv, communicator());
adapter->deactivate();