diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-09-12 02:46:32 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-09-12 02:46:32 +0000 |
commit | 759f7f34281a2c3d406ce93e52e63272a9d4beba (patch) | |
tree | 491339afc3ba74316d9d9019318836ffb6621ce8 /cpp | |
parent | bug fix to the icepack hello demo. (diff) | |
download | ice-759f7f34281a2c3d406ce93e52e63272a9d4beba.tar.bz2 ice-759f7f34281a2c3d406ce93e52e63272a9d4beba.tar.xz ice-759f7f34281a2c3d406ce93e52e63272a9d4beba.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=335
Diffstat (limited to 'cpp')
60 files changed, 1576 insertions, 888 deletions
diff --git a/cpp/all.dsw b/cpp/all.dsw index e581ac9d682..fc31665dd70 100644 --- a/cpp/all.dsw +++ b/cpp/all.dsw @@ -584,6 +584,12 @@ Package=<4> Begin Project Dependency
Project_Dep_Name icegridupdateS
End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name minimalC
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name minimalS
+ End Project Dependency
}}}
###############################################################################
@@ -2853,6 +2859,48 @@ Package=<4> ###############################################################################
+Project: "minimalC"=.\demo\Ice\minimal\minimalC.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name ice
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name icessl
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name iceutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "minimalS"=.\demo\Ice\minimal\minimalS.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name ice
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name icessl
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name iceutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
Project: "nestedC"=.\demo\ice\nested\nestedC.dsp - Package Owner=<4>
Package=<5>
diff --git a/cpp/demo/Freeze/bench/Client.cpp b/cpp/demo/Freeze/bench/Client.cpp index 9defee7c7f3..43a2d4d4610 100644 --- a/cpp/demo/Freeze/bench/Client.cpp +++ b/cpp/demo/Freeze/bench/Client.cpp @@ -12,8 +12,6 @@ #include <BenchTypes.h> #include <cstdlib> -using namespace Freeze; -using namespace Ice; using namespace std; using namespace Demo; @@ -98,7 +96,7 @@ public: private: - int _max; + const int _max; }; class SequentialGenerator : public Generator @@ -134,8 +132,8 @@ public: private: - int _min; - int _max; + const int _min; + const int _max; int _current; }; @@ -165,7 +163,7 @@ private: int i; _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { #if defined(_MSC_VER) && (_MSC_VER < 1310) @@ -208,7 +206,7 @@ private: // _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { m.erase(i); @@ -262,7 +260,7 @@ private: int i; _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { s1.l = i; @@ -314,7 +312,7 @@ private: // _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { s1.l = i; @@ -345,7 +343,7 @@ private: int i; _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { s1.l = i; @@ -396,7 +394,7 @@ private: // _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { s1.l = i; @@ -424,7 +422,7 @@ private: int i; _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { #if defined(_MSC_VER) && (_MSC_VER < 1310) @@ -604,7 +602,7 @@ TestApp::Struct1ObjectMapTest() int i; _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { s1.l = i; @@ -669,7 +667,7 @@ TestApp::Struct1ObjectMapTest() // _watch.start(); { - TransactionHolder txHolder(_connection); + Freeze::TransactionHolder txHolder(_connection); for(i = 0; i < _repetitions; ++i) { s1.l = i; @@ -719,7 +717,7 @@ typedef IceUtil::Handle<MyFactory> MyFactoryPtr; int TestApp::run(int argc, char* argv[]) { - _connection = createConnection(communicator(), _envName); + _connection = Freeze::createConnection(communicator(), _envName); cout << "IntIntMap" << endl; diff --git a/cpp/demo/Freeze/bench/bench.dsp b/cpp/demo/Freeze/bench/bench.dsp index 8ad5a0b50c4..278ed0489ea 100644 --- a/cpp/demo/Freeze/bench/bench.dsp +++ b/cpp/demo/Freeze/bench/bench.dsp @@ -91,7 +91,7 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
-SOURCE=.\benchTypes.cpp
+SOURCE=.\BenchTypes.cpp
# End Source File
# Begin Source File
@@ -107,7 +107,7 @@ SOURCE=.\Test.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
-SOURCE=.\benchTypes.h
+SOURCE=.\BenchTypes.h
# End Source File
# Begin Source File
@@ -129,7 +129,7 @@ InputPath=.\Test.ice BuildCmds= \
..\..\..\bin\slice2cpp.exe Test.ice \
- ..\..\..\bin\slice2freeze.exe --dict Demo::IntIntMap,int,int --dict Demo::Struct1Struct2Map,Demo::Struct1,Demo::Struct2 --dict Demo::Struct1Class1Map,Demo::Struct1,Demo::Class1 --dict Demo::Struct1ObjectMap,Demo::Struct1,Object --dict Demo::IndexedIntIntMap,int,int --dict-index Demo::IndexedIntIntMap --dict Demo::IndexedStruct1Struct2Map,Demo::Struct1,Demo::Struct2 --dict-index Demo::IndexedStruct1Struct2Map,s,case-insensitive --dict-index Demo::IndexedStruct1Struct2Map,s1 --dict Demo::IndexedStruct1Class1Map,Demo::Struct1,Demo::Class1 --dict-index Demo::IndexedStruct1Class1Map,s,case-sensitive benchTypes Test.ice \
+ ..\..\..\bin\slice2freeze.exe --dict Demo::IntIntMap,int,int --dict Demo::Struct1Struct2Map,Demo::Struct1,Demo::Struct2 --dict Demo::Struct1Class1Map,Demo::Struct1,Demo::Class1 --dict Demo::Struct1ObjectMap,Demo::Struct1,Object --dict Demo::IndexedIntIntMap,int,int --dict-index Demo::IndexedIntIntMap --dict Demo::IndexedStruct1Struct2Map,Demo::Struct1,Demo::Struct2 --dict-index Demo::IndexedStruct1Struct2Map,s,case-insensitive --dict-index Demo::IndexedStruct1Struct2Map,s1 --dict Demo::IndexedStruct1Class1Map,Demo::Struct1,Demo::Class1 --dict-index Demo::IndexedStruct1Class1Map,s,case-sensitive BenchTypes Test.ice \
"Test.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
@@ -138,10 +138,10 @@ BuildCmds= \ "Test.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
-"benchTypes.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"BenchTypes.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
-"benchTypes.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"BenchTypes.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
@@ -153,7 +153,7 @@ InputPath=.\Test.ice BuildCmds= \
..\..\..\bin\slice2cpp.exe Test.ice \
- ..\..\..\bin\slice2freeze.exe --dict Demo::IntIntMap,int,int --dict Demo::Struct1Struct2Map,Demo::Struct1,Demo::Struct2 --dict Demo::Struct1Class1Map,Demo::Struct1,Demo::Class1 --dict Demo::Struct1ObjectMap,Demo::Struct1,Object --dict Demo::IndexedIntIntMap,int,int --dict-index Demo::IndexedIntIntMap --dict Demo::IndexedStruct1Struct2Map,Demo::Struct1,Demo::Struct2 --dict-index Demo::IndexedStruct1Struct2Map,s,case-insensitive --dict-index Demo::IndexedStruct1Struct2Map,s1 --dict Demo::IndexedStruct1Class1Map,Demo::Struct1,Demo::Class1 --dict-index Demo::IndexedStruct1Class1Map,s,case-sensitive benchTypes Test.ice \
+ ..\..\..\bin\slice2freeze.exe --dict Demo::IntIntMap,int,int --dict Demo::Struct1Struct2Map,Demo::Struct1,Demo::Struct2 --dict Demo::Struct1Class1Map,Demo::Struct1,Demo::Class1 --dict Demo::Struct1ObjectMap,Demo::Struct1,Object --dict Demo::IndexedIntIntMap,int,int --dict-index Demo::IndexedIntIntMap --dict Demo::IndexedStruct1Struct2Map,Demo::Struct1,Demo::Struct2 --dict-index Demo::IndexedStruct1Struct2Map,s,case-insensitive --dict-index Demo::IndexedStruct1Struct2Map,s1 --dict Demo::IndexedStruct1Class1Map,Demo::Struct1,Demo::Class1 --dict-index Demo::IndexedStruct1Class1Map,s,case-sensitive BenchTypes Test.ice \
"Test.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
@@ -162,10 +162,10 @@ BuildCmds= \ "Test.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
-"benchTypes.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"BenchTypes.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
-"benchTypes.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"BenchTypes.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
diff --git a/cpp/demo/Freeze/library/BookFactory.cpp b/cpp/demo/Freeze/library/BookFactory.cpp index c7fff6b108d..a44161b8a1d 100644 --- a/cpp/demo/Freeze/library/BookFactory.cpp +++ b/cpp/demo/Freeze/library/BookFactory.cpp @@ -10,16 +10,16 @@ #include <BookFactory.h> using namespace std; -using namespace Ice; BookFactory::BookFactory(const LibraryIPtr& library) : _library(library) { } -ObjectPtr +Ice::ObjectPtr BookFactory::create(const string& type) { + assert(_library); assert(type == "::Demo::Book"); return new BookI(_library); } diff --git a/cpp/demo/Freeze/library/BookFactory.h b/cpp/demo/Freeze/library/BookFactory.h index 7f057dce6e1..b223412f984 100644 --- a/cpp/demo/Freeze/library/BookFactory.h +++ b/cpp/demo/Freeze/library/BookFactory.h @@ -12,7 +12,7 @@ #include <LibraryI.h> -class BookFactory : virtual public Ice::ObjectFactory +class BookFactory : public Ice::ObjectFactory { public: diff --git a/cpp/demo/Freeze/library/Client.cpp b/cpp/demo/Freeze/library/Client.cpp index 2cea64924f9..bb8c4497d3b 100644 --- a/cpp/demo/Freeze/library/Client.cpp +++ b/cpp/demo/Freeze/library/Client.cpp @@ -7,8 +7,8 @@ // // ********************************************************************** -#include <Ice/Application.h> #include <Parser.h> +#include <Ice/Application.h> using namespace std; diff --git a/cpp/demo/Freeze/library/Collocated.cpp b/cpp/demo/Freeze/library/Collocated.cpp index a4b922348fc..ad498b10f4d 100644 --- a/cpp/demo/Freeze/library/Collocated.cpp +++ b/cpp/demo/Freeze/library/Collocated.cpp @@ -13,8 +13,6 @@ #include <Freeze/Freeze.h> using namespace std; -using namespace Ice; -using namespace Freeze; class LibraryCollocated : public Ice::Application { @@ -28,6 +26,7 @@ public: virtual int run(int argc, char* argv[]); private: + const string _envName; }; @@ -41,18 +40,18 @@ main(int argc, char* argv[]) int LibraryCollocated::run(int argc, char* argv[]) { - PropertiesPtr properties = communicator()->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); // // Create an object adapter // - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Library"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Library"); // // Create an evictor for books. // Freeze::EvictorPtr evictor = Freeze::createEvictor(adapter, _envName, "books"); - Int evictorSize = properties->getPropertyAsInt("Library.EvictorSize"); + Ice::Int evictorSize = properties->getPropertyAsInt("Library.EvictorSize"); if(evictorSize > 0) { evictor->setSize(evictorSize); @@ -67,18 +66,18 @@ LibraryCollocated::run(int argc, char* argv[]) // Create the library, and add it to the Object Adapter. // LibraryIPtr library = new LibraryI(communicator(), _envName, "authors", evictor); - adapter->add(library, stringToIdentity("library")); + adapter->add(library, Ice::stringToIdentity("library")); // // Create and install a factory for books. // - ObjectFactoryPtr bookFactory = new BookFactory(library); + Ice::ObjectFactoryPtr bookFactory = new BookFactory(library); communicator()->addObjectFactory(bookFactory, "::Demo::Book"); // // Everything ok, let's go. // - int runParser(int, char*[], const CommunicatorPtr&); + int runParser(int, char*[], const Ice::CommunicatorPtr&); int status = runParser(argc, argv, communicator()); adapter->deactivate(); adapter->waitForDeactivate(); diff --git a/cpp/demo/Freeze/library/Grammar.y b/cpp/demo/Freeze/library/Grammar.y index 6343cd955d3..b76b60c746d 100644 --- a/cpp/demo/Freeze/library/Grammar.y +++ b/cpp/demo/Freeze/library/Grammar.y @@ -9,7 +9,6 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <Parser.h> #ifdef _MSC_VER @@ -21,7 +20,6 @@ #endif using namespace std; -using namespace Ice; void yyerror(const char* s) diff --git a/cpp/demo/Freeze/library/LibraryI.cpp b/cpp/demo/Freeze/library/LibraryI.cpp index 079c282a43f..96d33c9e61b 100644 --- a/cpp/demo/Freeze/library/LibraryI.cpp +++ b/cpp/demo/Freeze/library/LibraryI.cpp @@ -18,14 +18,10 @@ BookI::BookI(const LibraryIPtr& library) : { } -BookI::~BookI() -{ -} - void BookI::destroy(const Ice::Current&) { - IceUtil::RWRecMutex::RLock sync(*this); + RLock sync(*this); if(_destroyed) { @@ -55,7 +51,7 @@ BookI::destroy(const Ice::Current&) Demo::BookDescription BookI::getBookDescription(const Ice::Current&) const { - IceUtil::RWRecMutex::RLock sync(*this); + RLock sync(*this); if(_destroyed) { @@ -66,10 +62,10 @@ BookI::getBookDescription(const Ice::Current&) const return description; } -::std::string +string BookI::getRenterName(const Ice::Current&) const { - IceUtil::RWRecMutex::RLock sync(*this); + RLock sync(*this); if(_destroyed) { @@ -84,9 +80,9 @@ BookI::getRenterName(const Ice::Current&) const } void -BookI::rentBook(const ::std::string& name, const Ice::Current&) +BookI::rentBook(const string& name, const Ice::Current&) { - IceUtil::RWRecMutex::WLock sync(*this); + WLock sync(*this); if(_destroyed) { @@ -103,7 +99,7 @@ BookI::rentBook(const ::std::string& name, const Ice::Current&) void BookI::returnBook(const Ice::Current&) { - IceUtil::RWRecMutex::WLock sync(*this); + WLock sync(*this); if(_destroyed) { @@ -150,7 +146,7 @@ public: private: - Ice::ObjectAdapterPtr _adapter; + const Ice::ObjectAdapterPtr _adapter; }; LibraryI::LibraryI(const Ice::CommunicatorPtr& communicator, @@ -162,14 +158,10 @@ LibraryI::LibraryI(const Ice::CommunicatorPtr& communicator, { } -LibraryI::~LibraryI() -{ -} - Demo::BookPrx LibraryI::createBook(const Demo::BookDescription& description, const Ice::Current& c) { - IceUtil::RWRecMutex::WLock sync(*this); + WLock sync(*this); #if defined(__SUNPRO_CC) // @@ -235,7 +227,7 @@ LibraryI::findByIsbn(const string& isbn, const Ice::Current& c) const // No locking is necessary since no internal mutable state is // accessed. // - //IceUtil::RWRecMutex::RLock sync(*this); + //RLock sync(*this); try { @@ -255,7 +247,7 @@ LibraryI::findByIsbn(const string& isbn, const Ice::Current& c) const Demo::BookPrxSeq LibraryI::findByAuthors(const string& authors, const Ice::Current& c) const { - IceUtil::RWRecMutex::RLock sync(*this); + RLock sync(*this); // // Lookup all books that match the given authors, and return them @@ -292,7 +284,7 @@ LibraryI::shutdown(const Ice::Current& current) void LibraryI::remove(const BookDescription& description) { - IceUtil::RWRecMutex::WLock sync(*this); + WLock sync(*this); try { @@ -343,4 +335,3 @@ LibraryI::remove(const BookDescription& description) throw e; } } - diff --git a/cpp/demo/Freeze/library/LibraryI.h b/cpp/demo/Freeze/library/LibraryI.h index 372faa99f40..6bbb875c866 100644 --- a/cpp/demo/Freeze/library/LibraryI.h +++ b/cpp/demo/Freeze/library/LibraryI.h @@ -11,10 +11,10 @@ #define LIBRARY_I_H #include <IceUtil/RWRecMutex.h> +#include <IceUtil/AbstractMutex.h> #include <Freeze/Evictor.h> #include <Library.h> #include <LibraryTypes.h> -#include <IceUtil/AbstractMutex.h> class LibraryI : public Demo::Library, public IceUtil::RWRecMutex { @@ -23,11 +23,10 @@ public: LibraryI(const Ice::CommunicatorPtr& communicator, const std::string& envName, const std::string& dbName, const Freeze::EvictorPtr& evictor); - virtual ~LibraryI(); - virtual ::Demo::BookPrx createBook(const ::Demo::BookDescription&, const Ice::Current&); - virtual ::Demo::BookPrx findByIsbn(const ::std::string&, const Ice::Current&) const; - virtual ::Demo::BookPrxSeq findByAuthors(const ::std::string&, const Ice::Current&) const; + virtual Demo::BookPrx createBook(const Demo::BookDescription&, const Ice::Current&); + virtual Demo::BookPrx findByIsbn(const std::string&, const Ice::Current&) const; + virtual Demo::BookPrxSeq findByAuthors(const std::string&, const Ice::Current&) const; virtual void setEvictorSize(::Ice::Int, const Ice::Current&); virtual void shutdown(const Ice::Current&); @@ -35,9 +34,9 @@ public: private: - Freeze::EvictorPtr _evictor; + const Freeze::EvictorPtr _evictor; + const Freeze::ConnectionPtr _connection; - Freeze::ConnectionPtr _connection; // // This is a dictionary of authors to a sequence of isbn numbers // for efficient lookup of books by authors. @@ -52,17 +51,16 @@ class BookI : public Demo::Book, public IceUtil::AbstractMutexReadI<IceUtil::RWR public: BookI(const LibraryIPtr&); - virtual ~BookI(); - virtual ::Demo::BookDescription getBookDescription(const Ice::Current&) const; + virtual Demo::BookDescription getBookDescription(const Ice::Current&) const; virtual void destroy(const Ice::Current&); - virtual void rentBook(const ::std::string&, const Ice::Current&); - virtual ::std::string getRenterName(const Ice::Current&) const; + virtual void rentBook(const std::string&, const Ice::Current&); + virtual std::string getRenterName(const Ice::Current&) const; virtual void returnBook(const Ice::Current&); private: - LibraryIPtr _library; + const LibraryIPtr _library; bool _destroyed; }; diff --git a/cpp/demo/Freeze/library/Parser.cpp b/cpp/demo/Freeze/library/Parser.cpp index 4e83e00984a..43cc2e107bc 100644 --- a/cpp/demo/Freeze/library/Parser.cpp +++ b/cpp/demo/Freeze/library/Parser.cpp @@ -7,7 +7,6 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <Parser.h> #ifdef HAVE_READLINE @@ -16,7 +15,6 @@ #endif using namespace std; -using namespace Ice; using namespace Demo; extern FILE* yyin; @@ -42,9 +40,9 @@ Parser::usage() } ParserPtr -Parser::createParser(const CommunicatorPtr& communicator, const LibraryPrx& library) +Parser::createParser(const LibraryPrx& library) { - return new Parser(communicator, library); + return new Parser(library); } void @@ -78,7 +76,7 @@ Parser::addBook(const list<string>& _args) { error("the book already exists."); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -116,7 +114,7 @@ Parser::findIsbn(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -144,7 +142,7 @@ Parser::findAuthors(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -197,7 +195,7 @@ Parser::printCurrent() { cout << "current book no longer exists" << endl; } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -238,7 +236,7 @@ Parser::rentCurrent(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -273,7 +271,7 @@ Parser::returnCurrent() { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -304,7 +302,7 @@ Parser::removeCurrent() { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -329,7 +327,7 @@ Parser::setEvictorSize(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -344,7 +342,7 @@ Parser::shutdown() { _library->shutdown(); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -590,7 +588,7 @@ Parser::parse(const string& commands, bool debug) return status; } -Parser::Parser(const CommunicatorPtr& communicator, const LibraryPrx& library) : +Parser::Parser(const LibraryPrx& library) : _library(library) { } diff --git a/cpp/demo/Freeze/library/Parser.h b/cpp/demo/Freeze/library/Parser.h index 57543b35768..9130bee8596 100644 --- a/cpp/demo/Freeze/library/Parser.h +++ b/cpp/demo/Freeze/library/Parser.h @@ -10,7 +10,6 @@ #ifndef PARSER_H #define PARSER_H -#include <IceUtil/Handle.h> #include <Ice/Ice.h> #include <Library.h> #include <list> @@ -51,13 +50,13 @@ int yyparse(); #define yyoverflow(a, b, c, d, e, f) yyerror(a) class Parser; -typedef ::IceUtil::Handle<Parser> ParserPtr; +typedef IceUtil::Handle<Parser> ParserPtr; -class Parser : public ::IceUtil::SimpleShared +class Parser : public IceUtil::SimpleShared { public: - static ParserPtr createParser(const Ice::CommunicatorPtr&, const Demo::LibraryPrx&); + static ParserPtr createParser(const Demo::LibraryPrx&); void usage(); @@ -88,13 +87,13 @@ public: private: - Parser(const Ice::CommunicatorPtr&, const Demo::LibraryPrx&); + Parser(const Demo::LibraryPrx&); Demo::BookPrxSeq _foundBooks; Demo::BookPrxSeq::iterator _current; std::string _commands; - Demo::LibraryPrx _library; + const Demo::LibraryPrx _library; bool _continue; int _errors; int _currentLine; diff --git a/cpp/demo/Freeze/library/RunParser.cpp b/cpp/demo/Freeze/library/RunParser.cpp index eed07833b58..b71a188d852 100644 --- a/cpp/demo/Freeze/library/RunParser.cpp +++ b/cpp/demo/Freeze/library/RunParser.cpp @@ -7,7 +7,6 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <Parser.h> using namespace std; @@ -100,15 +99,14 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) return EXIT_FAILURE; } - Ice::ObjectPrx base = communicator->stringToProxy(proxy); - LibraryPrx phoneBook = LibraryPrx::checkedCast(base); + LibraryPrx phoneBook = LibraryPrx::checkedCast(communicator->stringToProxy(proxy)); if(!phoneBook) { cerr << argv[0] << ": invalid proxy" << endl; return EXIT_FAILURE; } - ParserPtr p = Parser::createParser(communicator, phoneBook); + ParserPtr p = Parser::createParser(phoneBook); int status = EXIT_SUCCESS; if(argc < 2) // No files given diff --git a/cpp/demo/Freeze/library/Scanner.l b/cpp/demo/Freeze/library/Scanner.l index b9c9509ca70..31484dfaf93 100644 --- a/cpp/demo/Freeze/library/Scanner.l +++ b/cpp/demo/Freeze/library/Scanner.l @@ -9,7 +9,6 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <Parser.h> #include <Grammar.h> @@ -20,7 +19,6 @@ #endif using namespace std; -using namespace Ice; #define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) diff --git a/cpp/demo/Freeze/library/Server.cpp b/cpp/demo/Freeze/library/Server.cpp index d1494af2e69..13996a74b95 100644 --- a/cpp/demo/Freeze/library/Server.cpp +++ b/cpp/demo/Freeze/library/Server.cpp @@ -7,13 +7,11 @@ // // ********************************************************************** -#include <Ice/Application.h> #include <BookFactory.h> +#include <Ice/Application.h> #include <Freeze/Freeze.h> using namespace std; -using namespace Ice; -using namespace Freeze; class LibraryServer : public Ice::Application { @@ -41,18 +39,18 @@ main(int argc, char* argv[]) int LibraryServer::run(int argc, char* argv[]) { - PropertiesPtr properties = communicator()->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); // // Create an object adapter // - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Library"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Library"); // // Create an evictor for books. // Freeze::EvictorPtr evictor = Freeze::createEvictor(adapter, _envName, "books"); - Int evictorSize = properties->getPropertyAsInt("Library.EvictorSize"); + Ice::Int evictorSize = properties->getPropertyAsInt("Library.EvictorSize"); if(evictorSize > 0) { evictor->setSize(evictorSize); @@ -68,12 +66,12 @@ LibraryServer::run(int argc, char* argv[]) // Create the library, and add it to the object adapter. // LibraryIPtr library = new LibraryI(communicator(), _envName, "authors", evictor); - adapter->add(library, stringToIdentity("library")); + adapter->add(library, Ice::stringToIdentity("library")); // // Create and install a factory for books. // - ObjectFactoryPtr bookFactory = new BookFactory(library); + Ice::ObjectFactoryPtr bookFactory = new BookFactory(library); communicator()->addObjectFactory(bookFactory, "::Demo::Book"); // diff --git a/cpp/demo/Freeze/phonebook/Client.cpp b/cpp/demo/Freeze/phonebook/Client.cpp index 38faba90113..15b942aed6f 100644 --- a/cpp/demo/Freeze/phonebook/Client.cpp +++ b/cpp/demo/Freeze/phonebook/Client.cpp @@ -7,13 +7,11 @@ // // ********************************************************************** -#include <Ice/Application.h> #include <Parser.h> using namespace std; -using namespace Ice; -class PhoneBookClient : public Application +class PhoneBookClient : public Ice::Application { virtual int run(int argc, char* argv[]); }; @@ -28,6 +26,6 @@ main(int argc, char* argv[]) int PhoneBookClient::run(int argc, char* argv[]) { - int runParser(int, char*[], const CommunicatorPtr&); + int runParser(int, char*[], const Ice::CommunicatorPtr&); return runParser(argc, argv, communicator()); } diff --git a/cpp/demo/Freeze/phonebook/Collocated.cpp b/cpp/demo/Freeze/phonebook/Collocated.cpp index 60aed9975cd..8f526cc0044 100644 --- a/cpp/demo/Freeze/phonebook/Collocated.cpp +++ b/cpp/demo/Freeze/phonebook/Collocated.cpp @@ -7,15 +7,12 @@ // // ********************************************************************** -#include <Ice/Application.h> #include <ContactFactory.h> #include <NameIndex.h> #include <PhoneBookI.h> #include <Parser.h> using namespace std; -using namespace Ice; -using namespace Freeze; class PhoneBookCollocated : public Ice::Application { @@ -29,6 +26,7 @@ public: virtual int run(int argc, char* argv[]); private: + const string _envName; }; @@ -42,7 +40,7 @@ main(int argc, char* argv[]) int PhoneBookCollocated::run(int argc, char* argv[]) { - PropertiesPtr properties = communicator()->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); // // Create and install a factory for contacts. @@ -60,20 +58,21 @@ PhoneBookCollocated::run(int argc, char* argv[]) // // Create an object adapter, use the evictor as servant locator. // - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PhoneBook"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PhoneBook"); // // Create an evictor for contacts. - // When Freeze.Evictor.db.contacts.PopulateEmptyIndices is not 0 and the - // Name index is empty, Freeze will traverse the database to recreate - // the index during createEvictor(). Therefore the factories for the objects - // stored in evictor (contacts here) must be registered before the call - // to createEvictor(). + // + // When Freeze.Evictor.db.contacts.PopulateEmptyIndices is not 0 + // and the Name index is empty, Freeze will traverse the database + // to recreate the index during createEvictor(). Therefore the + // factories for the objects stored in evictor (contacts here) + // must be registered before the call to createEvictor(). // Freeze::EvictorPtr evictor = Freeze::createEvictor(adapter, _envName, "contacts", 0, indices); adapter->addServantLocator(evictor, "contact"); - Int evictorSize = properties->getPropertyAsInt("PhoneBook.EvictorSize"); + Ice::Int evictorSize = properties->getPropertyAsInt("PhoneBook.EvictorSize"); if(evictorSize > 0) { evictor->setSize(evictorSize); @@ -90,12 +89,12 @@ PhoneBookCollocated::run(int argc, char* argv[]) // Create the phonebook, and add it to the Object Adapter. // PhoneBookIPtr phoneBook = new PhoneBookI(evictor, contactFactory, index); - adapter->add(phoneBook, stringToIdentity("phonebook")); + adapter->add(phoneBook, Ice::stringToIdentity("phonebook")); // // Everything ok, let's go. // - int runParser(int, char*[], const CommunicatorPtr&); + int runParser(int, char*[], const Ice::CommunicatorPtr&); int status = runParser(argc, argv, communicator()); adapter->deactivate(); adapter->waitForDeactivate(); diff --git a/cpp/demo/Freeze/phonebook/ContactFactory.cpp b/cpp/demo/Freeze/phonebook/ContactFactory.cpp index d63cd94b331..9596a92cbbf 100644 --- a/cpp/demo/Freeze/phonebook/ContactFactory.cpp +++ b/cpp/demo/Freeze/phonebook/ContactFactory.cpp @@ -11,16 +11,15 @@ #include <PhoneBookI.h> using namespace std; -using namespace Ice; -using namespace Freeze; ContactFactory::ContactFactory() { } -ObjectPtr +Ice::ObjectPtr ContactFactory::create(const string& type) { + assert(_evictor); assert(type == "::Demo::Contact"); return new ContactI(this); } @@ -40,7 +39,7 @@ ContactFactory::setEvictor(const Freeze::EvictorPtr& evictor) _evictor = evictor; } -const Freeze::EvictorPtr& +Freeze::EvictorPtr ContactFactory::getEvictor() const { return _evictor; diff --git a/cpp/demo/Freeze/phonebook/ContactFactory.h b/cpp/demo/Freeze/phonebook/ContactFactory.h index 43e99240b2d..102da5757ad 100644 --- a/cpp/demo/Freeze/phonebook/ContactFactory.h +++ b/cpp/demo/Freeze/phonebook/ContactFactory.h @@ -12,7 +12,7 @@ #include <Freeze/Freeze.h> -class ContactFactory : virtual public Ice::ObjectFactory +class ContactFactory : public Ice::ObjectFactory { public: @@ -27,9 +27,8 @@ public: void setEvictor(const Freeze::EvictorPtr&); - const Freeze::EvictorPtr& + Freeze::EvictorPtr getEvictor() const; - private: diff --git a/cpp/demo/Freeze/phonebook/Grammar.y b/cpp/demo/Freeze/phonebook/Grammar.y index ae49e12fb11..fca086808d7 100644 --- a/cpp/demo/Freeze/phonebook/Grammar.y +++ b/cpp/demo/Freeze/phonebook/Grammar.y @@ -9,7 +9,6 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <Parser.h> #ifdef _MSC_VER diff --git a/cpp/demo/Freeze/phonebook/Parser.cpp b/cpp/demo/Freeze/phonebook/Parser.cpp index 316b63bba83..60f6be1ad8f 100644 --- a/cpp/demo/Freeze/phonebook/Parser.cpp +++ b/cpp/demo/Freeze/phonebook/Parser.cpp @@ -7,7 +7,6 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <Parser.h> #ifdef HAVE_READLINE @@ -16,7 +15,6 @@ #endif using namespace std; -using namespace Ice; using namespace Demo; extern FILE* yyin; @@ -43,9 +41,9 @@ Parser::usage() } ParserPtr -Parser::createParser(const CommunicatorPtr& communicator, const PhoneBookPrx& phoneBook) +Parser::createParser(const PhoneBookPrx& phoneBook) { - return new Parser(communicator, phoneBook); + return new Parser(phoneBook); } void @@ -70,7 +68,7 @@ Parser::addContacts(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -98,7 +96,7 @@ Parser::findContacts(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -141,7 +139,7 @@ Parser::printCurrent() { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -178,7 +176,7 @@ Parser::setCurrentName(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -215,7 +213,7 @@ Parser::setCurrentAddress(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -252,7 +250,7 @@ Parser::setCurrentPhone(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -283,7 +281,7 @@ Parser::removeCurrent() { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -308,7 +306,7 @@ Parser::setEvictorSize(const list<string>& args) { error(ex.message); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -323,7 +321,7 @@ Parser::shutdown() { _phoneBook->shutdown(); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { ostringstream s; s << ex; @@ -569,7 +567,7 @@ Parser::parse(const string& commands, bool debug) return status; } -Parser::Parser(const CommunicatorPtr& communicator, const PhoneBookPrx& phoneBook) : +Parser::Parser(const PhoneBookPrx& phoneBook) : _phoneBook(phoneBook) { } diff --git a/cpp/demo/Freeze/phonebook/Parser.h b/cpp/demo/Freeze/phonebook/Parser.h index cc141ec09e4..5915c2aefdc 100644 --- a/cpp/demo/Freeze/phonebook/Parser.h +++ b/cpp/demo/Freeze/phonebook/Parser.h @@ -10,7 +10,6 @@ #ifndef PARSER_H #define PARSER_H -#include <IceUtil/Handle.h> #include <Ice/Ice.h> #include <PhoneBook.h> #include <list> @@ -57,7 +56,7 @@ class Parser : public ::IceUtil::SimpleShared { public: - static ParserPtr createParser(const Ice::CommunicatorPtr&, const Demo::PhoneBookPrx&); + static ParserPtr createParser(const Demo::PhoneBookPrx&); void usage(); @@ -88,13 +87,13 @@ public: private: - Parser(const Ice::CommunicatorPtr&, const Demo::PhoneBookPrx&); + Parser(const Demo::PhoneBookPrx&); Demo::Contacts _foundContacts; Demo::Contacts::iterator _current; std::string _commands; - Demo::PhoneBookPrx _phoneBook; + const Demo::PhoneBookPrx _phoneBook; bool _continue; int _errors; int _currentLine; diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp index a41fb881f42..32be6d815b3 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp @@ -11,7 +11,6 @@ #include <IceUtil/UUID.h> using namespace std; -using namespace Ice; using namespace Demo; ContactI::ContactI(const ContactFactoryPtr& contactFactory) : @@ -22,49 +21,49 @@ ContactI::ContactI(const ContactFactoryPtr& contactFactory) : string ContactI::getName(const Ice::Current&) const { - IceUtil::RWRecMutex::RLock sync(*this); + RLock sync(*this); return name; } void ContactI::setName(const string& newName, const Ice::Current&) { - IceUtil::RWRecMutex::WLock sync(*this); + WLock sync(*this); name = newName; } string ContactI::getAddress(const Ice::Current&) const { - IceUtil::RWRecMutex::RLock sync(*this); + RLock sync(*this); return address; } void ContactI::setAddress(const string& newAddress, const Ice::Current&) { - IceUtil::RWRecMutex::WLock sync(*this); + WLock sync(*this); address = newAddress; } string ContactI::getPhone(const Ice::Current&) const { - IceUtil::RWRecMutex::RLock sync(*this); + RLock sync(*this); return phone; } void ContactI::setPhone(const string& newPhone, const Ice::Current&) { - IceUtil::RWRecMutex::WLock sync(*this); + WLock sync(*this); phone = newPhone; } void ContactI::destroy(const Ice::Current& c) { - IceUtil::RWRecMutex::RLock sync(*this); + RLock sync(*this); try { _factory->getEvictor()->remove(c.id); @@ -89,19 +88,19 @@ class IdentityToContact { public: - IdentityToContact(const ObjectAdapterPtr& adapter) : + IdentityToContact(const Ice::ObjectAdapterPtr& adapter) : _adapter(adapter) { } - ContactPrx operator()(const Identity& ident) + ContactPrx operator()(const Ice::Identity& ident) { return ContactPrx::uncheckedCast(_adapter->createProxy(ident)); } private: - ObjectAdapterPtr _adapter; + const Ice::ObjectAdapterPtr _adapter; }; ContactPrx @@ -110,7 +109,7 @@ PhoneBookI::createContact(const Ice::Current& c) // // Get a new unique identity. // - Identity ident; + Ice::Identity ident; ident.name = IceUtil::generateUUID(); ident.category = "contact"; @@ -138,7 +137,7 @@ PhoneBookI::findContacts(const string& name, const Ice::Current& c) const { try { - vector<Identity> identities = _index->find(name); + vector<Ice::Identity> identities = _index->find(name); Contacts contacts; contacts.reserve(identities.size()); @@ -155,7 +154,7 @@ PhoneBookI::findContacts(const string& name, const Ice::Current& c) const } void -PhoneBookI::setEvictorSize(Int size, const Ice::Current&) +PhoneBookI::setEvictorSize(Ice::Int size, const Ice::Current&) { _evictor->setSize(size); } diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.h b/cpp/demo/Freeze/phonebook/PhoneBookI.h index 6ce214a8a65..3c16369bb1d 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.h +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.h @@ -10,8 +10,8 @@ #ifndef PHONE_BOOK_I_H #define PHONE_BOOK_I_H -#include <IceUtil/IceUtil.h> #include <Ice/Ice.h> +#include <IceUtil/IceUtil.h> #include <Freeze/Freeze.h> #include <PhoneBook.h> #include <NameIndex.h> @@ -23,8 +23,7 @@ typedef IceUtil::Handle<PhoneBookI> PhoneBookIPtr; class ContactI; typedef IceUtil::Handle<ContactI> ContactIPtr; -class ContactI : public Demo::Contact, - public IceUtil::AbstractMutexReadI<IceUtil::RWRecMutex> +class ContactI : public Demo::Contact, public IceUtil::AbstractMutexReadI<IceUtil::RWRecMutex> { public: @@ -43,7 +42,7 @@ public: private: - ContactFactoryPtr _factory; + const ContactFactoryPtr _factory; }; class PhoneBookI : public Demo::PhoneBook @@ -59,8 +58,8 @@ public: private: - Freeze::EvictorPtr _evictor; - ContactFactoryPtr _contactFactory; + const Freeze::EvictorPtr _evictor; + const ContactFactoryPtr _contactFactory; NameIndexPtr _index; }; diff --git a/cpp/demo/Freeze/phonebook/RunParser.cpp b/cpp/demo/Freeze/phonebook/RunParser.cpp index 00c2c5a578a..e254e885828 100644 --- a/cpp/demo/Freeze/phonebook/RunParser.cpp +++ b/cpp/demo/Freeze/phonebook/RunParser.cpp @@ -7,11 +7,9 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <Parser.h> using namespace std; -using namespace Ice; using namespace Demo; void @@ -28,7 +26,7 @@ usage(const char* appName) } int -runParser(int argc, char* argv[], const CommunicatorPtr& communicator) +runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { string commands; bool debug = false; @@ -92,7 +90,7 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) return EXIT_FAILURE; } - PropertiesPtr properties = communicator->getProperties(); + Ice::PropertiesPtr properties = communicator->getProperties(); const char* proxyProperty = "PhoneBook.Proxy"; string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) @@ -101,15 +99,14 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) return EXIT_FAILURE; } - ObjectPrx base = communicator->stringToProxy(proxy); - PhoneBookPrx phoneBook = PhoneBookPrx::checkedCast(base); + PhoneBookPrx phoneBook = PhoneBookPrx::checkedCast(communicator->stringToProxy(proxy)); if(!phoneBook) { cerr << argv[0] << ": invalid proxy" << endl; return EXIT_FAILURE; } - ParserPtr p = Parser::createParser(communicator, phoneBook); + ParserPtr p = Parser::createParser(phoneBook); int status = EXIT_SUCCESS; if(argc < 2) // No files given diff --git a/cpp/demo/Freeze/phonebook/Scanner.l b/cpp/demo/Freeze/phonebook/Scanner.l index 8848652d1d0..6ee2e17a287 100644 --- a/cpp/demo/Freeze/phonebook/Scanner.l +++ b/cpp/demo/Freeze/phonebook/Scanner.l @@ -9,7 +9,6 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <Parser.h> #include <Grammar.h> @@ -20,7 +19,6 @@ #endif using namespace std; -using namespace Ice; #define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) diff --git a/cpp/demo/Freeze/phonebook/Server.cpp b/cpp/demo/Freeze/phonebook/Server.cpp index 3e86ac79808..065b55e488e 100644 --- a/cpp/demo/Freeze/phonebook/Server.cpp +++ b/cpp/demo/Freeze/phonebook/Server.cpp @@ -13,7 +13,6 @@ #include <PhoneBookI.h> using namespace std; -using namespace Ice; using namespace Freeze; class PhoneBookServer : public Ice::Application @@ -41,7 +40,7 @@ main(int argc, char* argv[]) int PhoneBookServer::run(int argc, char* argv[]) { - PropertiesPtr properties = communicator()->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); // // Create and install a factory for contacts. @@ -59,7 +58,7 @@ PhoneBookServer::run(int argc, char* argv[]) // // Create an object adapter, use the evictor as servant locator. // - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PhoneBook"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PhoneBook"); // // Create an evictor for contacts. @@ -72,7 +71,7 @@ PhoneBookServer::run(int argc, char* argv[]) Freeze::EvictorPtr evictor = Freeze::createEvictor(adapter, _envName, "contacts", 0, indices); adapter->addServantLocator(evictor, "contact"); - Int evictorSize = properties->getPropertyAsInt("PhoneBook.EvictorSize"); + Ice::Int evictorSize = properties->getPropertyAsInt("PhoneBook.EvictorSize"); if(evictorSize > 0) { evictor->setSize(evictorSize); @@ -89,7 +88,7 @@ PhoneBookServer::run(int argc, char* argv[]) // Create the phonebook, and add it to the object adapter. // PhoneBookIPtr phoneBook = new PhoneBookI(evictor, contactFactory, index); - adapter->add(phoneBook, stringToIdentity("phonebook")); + adapter->add(phoneBook, Ice::stringToIdentity("phonebook")); // // Everything ok, let's go. diff --git a/cpp/demo/Glacier2/callback/CallbackI.cpp b/cpp/demo/Glacier2/callback/CallbackI.cpp index 4fc13841cba..7cc2fe0289a 100644 --- a/cpp/demo/Glacier2/callback/CallbackI.cpp +++ b/cpp/demo/Glacier2/callback/CallbackI.cpp @@ -7,42 +7,41 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <CallbackI.h> +#include <Ice/Ice.h> using namespace std; -using namespace Ice; using namespace Demo; void -CallbackReceiverI::callback(const Current&) +CallbackReceiverI::callback(const Ice::Current&) { cout << "received callback" << endl; } void -CallbackI::initiateCallback(const CallbackReceiverPrx& proxy, const Current& current) +CallbackI::initiateCallback(const CallbackReceiverPrx& proxy, const Ice::Current& current) { cout << "initiating callback to: " << current.adapter->getCommunicator()->proxyToString(proxy) << endl; try { proxy->callback(current.ctx); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { cout << ex << endl; } } void -CallbackI::shutdown(const Current& c) +CallbackI::shutdown(const Ice::Current& c) { cout << "shutting down..." << endl; try { c.adapter->getCommunicator()->shutdown(); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { cout << ex << endl; } diff --git a/cpp/demo/Glacier2/callback/Client.cpp b/cpp/demo/Glacier2/callback/Client.cpp index 44d853cb77f..a64ad50b76a 100644 --- a/cpp/demo/Glacier2/callback/Client.cpp +++ b/cpp/demo/Glacier2/callback/Client.cpp @@ -7,15 +7,14 @@ // // ********************************************************************** +#include <CallbackI.h> #include <Ice/Application.h> #include <Glacier2/Router.h> -#include <CallbackI.h> using namespace std; -using namespace Ice; using namespace Demo; -class CallbackClient : public Application +class CallbackClient : public Ice::Application { public: @@ -48,7 +47,7 @@ menu() int CallbackClient::run(int argc, char* argv[]) { - RouterPrx defaultRouter = communicator()->getDefaultRouter(); + Ice::RouterPrx defaultRouter = communicator()->getDefaultRouter(); if(!defaultRouter) { cerr << argv[0] << ": no default router set" << endl; @@ -86,14 +85,14 @@ CallbackClient::run(int argc, char* argv[]) } string category = router->getServerProxy()->ice_getIdentity().category; - Identity callbackReceiverIdent; + Ice::Identity callbackReceiverIdent; callbackReceiverIdent.name = "callbackReceiver"; callbackReceiverIdent.category = category; - Identity callbackReceiverFakeIdent; + Ice::Identity callbackReceiverFakeIdent; callbackReceiverFakeIdent.name = "callbackReceiver"; callbackReceiverFakeIdent.category = "fake"; - PropertiesPtr properties = communicator()->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); const char* proxyProperty = "Callback.Proxy"; std::string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) @@ -102,12 +101,12 @@ CallbackClient::run(int argc, char* argv[]) return EXIT_FAILURE; } - ObjectPrx base = communicator()->stringToProxy(proxy); + Ice::ObjectPrx base = communicator()->stringToProxy(proxy); CallbackPrx twoway = CallbackPrx::checkedCast(base); CallbackPrx oneway = CallbackPrx::uncheckedCast(twoway->ice_oneway()); CallbackPrx batchOneway = CallbackPrx::uncheckedCast(twoway->ice_batchOneway()); - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client"); adapter->add(new CallbackReceiverI, callbackReceiverIdent); adapter->add(new CallbackReceiverI, callbackReceiverFakeIdent); // Should never be called for the fake identity. adapter->activate(); @@ -129,7 +128,7 @@ CallbackClient::run(int argc, char* argv[]) cin >> c; if(c == 't') { - Context context; + Ice::Context context; context["_fwd"] = "t"; if(!override.empty()) { @@ -139,7 +138,7 @@ CallbackClient::run(int argc, char* argv[]) } else if(c == 'o') { - Context context; + Ice::Context context; context["_fwd"] = "o"; if(!override.empty()) { @@ -149,7 +148,7 @@ CallbackClient::run(int argc, char* argv[]) } else if(c == 'O') { - Context context; + Ice::Context context; context["_fwd"] = "O"; if(!override.empty()) { @@ -189,7 +188,7 @@ CallbackClient::run(int argc, char* argv[]) onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_newIdentity(callbackReceiverIdent)); } - cout << "callback receiver identity: " << identityToString(twowayR->ice_getIdentity()) << endl; + cout << "callback receiver identity: " << Ice::identityToString(twowayR->ice_getIdentity()) << endl; } else if(c == 's') { @@ -209,7 +208,7 @@ CallbackClient::run(int argc, char* argv[]) menu(); } } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { cerr << ex << endl; } diff --git a/cpp/demo/Glacier2/callback/Server.cpp b/cpp/demo/Glacier2/callback/Server.cpp index 53dcefccb9d..0fc2fc8f4d3 100644 --- a/cpp/demo/Glacier2/callback/Server.cpp +++ b/cpp/demo/Glacier2/callback/Server.cpp @@ -11,10 +11,9 @@ #include <CallbackI.h> using namespace std; -using namespace Ice; using namespace Demo; -class CallbackServer : public Application +class CallbackServer : public Ice::Application { public: @@ -31,7 +30,7 @@ main(int argc, char* argv[]) int CallbackServer::run(int argc, char* argv[]) { - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Server"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Server"); adapter->add(new CallbackI, Ice::stringToIdentity("callback")); adapter->activate(); communicator()->waitForShutdown(); diff --git a/cpp/demo/Glacier2/callback/SessionI.cpp b/cpp/demo/Glacier2/callback/SessionI.cpp index c8516c1c124..1271bd289f1 100644 --- a/cpp/demo/Glacier2/callback/SessionI.cpp +++ b/cpp/demo/Glacier2/callback/SessionI.cpp @@ -7,15 +7,14 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <SessionI.h> +#include <Ice/Ice.h> using namespace std; -using namespace Ice; bool DummyPermissionsVerifierI::checkPermissions(const string& userId, const string& password, string&, - const Current&) const + const Ice::Current&) const { cout << "verified user `" << userId << "' with password `" << password << "'" << endl; return true; diff --git a/cpp/demo/Glacier2/callback/SessionServer.cpp b/cpp/demo/Glacier2/callback/SessionServer.cpp index 3f5da4a2980..6c91ac9ed89 100644 --- a/cpp/demo/Glacier2/callback/SessionServer.cpp +++ b/cpp/demo/Glacier2/callback/SessionServer.cpp @@ -7,13 +7,12 @@ // // ********************************************************************** -#include <Ice/Application.h> #include <SessionI.h> +#include <Ice/Application.h> using namespace std; -using namespace Ice; -class SessionServer : public Application +class SessionServer : public Ice::Application { public: @@ -30,7 +29,7 @@ main(int argc, char* argv[]) int SessionServer::run(int argc, char* argv[]) { - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("SessionServer"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("SessionServer"); adapter->add(new DummyPermissionsVerifierI, Ice::stringToIdentity("verifier")); adapter->add(new SessionManagerI, Ice::stringToIdentity("sessionmanager")); adapter->activate(); diff --git a/cpp/demo/Glacier2/chat/ChatSessionI.cpp b/cpp/demo/Glacier2/chat/ChatSessionI.cpp index 22e703885c4..bc6b9ca366b 100755 --- a/cpp/demo/Glacier2/chat/ChatSessionI.cpp +++ b/cpp/demo/Glacier2/chat/ChatSessionI.cpp @@ -7,13 +7,11 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <ChatSessionI.h> - +#include <Ice/Ice.h> #include <list> using namespace std; -using namespace Ice; using namespace Demo; class ChatRoom; @@ -55,18 +53,18 @@ ChatRoom::instance() void ChatRoom::enter(const ChatCallbackPrx& callback) { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); _members.push_back(ChatCallbackPrx::uncheckedCast(callback->ice_oneway())); } void ChatRoom::leave(const ChatCallbackPrx& callback) { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); list<ChatCallbackPrx>::iterator p; for(p = _members.begin(); p != _members.end(); ++p) { - if(proxyIdentityEqual(callback, *p)) + if(Ice::proxyIdentityEqual(callback, *p)) { break; } @@ -79,14 +77,14 @@ ChatRoom::leave(const ChatCallbackPrx& callback) void ChatRoom::message(const string& data) const { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); for(list<ChatCallbackPrx>::const_iterator p = _members.begin(); p != _members.end(); ++p) { try { (*p)->message(data); } - catch(const LocalException&) + catch(const Ice::LocalException&) { } } @@ -98,9 +96,9 @@ ChatSessionI::ChatSessionI(const string& userId) : } void -ChatSessionI::setCallback(const ChatCallbackPrx& callback, const Current& current) +ChatSessionI::setCallback(const ChatCallbackPrx& callback, const Ice::Current& current) { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); if(!_callback) { _callback = callback; @@ -111,15 +109,15 @@ ChatSessionI::setCallback(const ChatCallbackPrx& callback, const Current& curren } void -ChatSessionI::say(const string& data, const Current&) +ChatSessionI::say(const string& data, const Ice::Current&) { ChatRoom::instance()->message(_userId + " says: " + data); } void -ChatSessionI::destroy(const Current& current) +ChatSessionI::destroy(const Ice::Current& current) { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); if(_callback) { ChatRoomPtr chatRoom = ChatRoom::instance(); diff --git a/cpp/demo/Glacier2/chat/Client.cpp b/cpp/demo/Glacier2/chat/Client.cpp index 41678016a51..48701a0b533 100755 --- a/cpp/demo/Glacier2/chat/Client.cpp +++ b/cpp/demo/Glacier2/chat/Client.cpp @@ -12,7 +12,6 @@ #include <Chat.h> using namespace std; -using namespace Ice; using namespace Demo; class SessionPingThread : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> @@ -69,20 +68,20 @@ class ChatCallbackI : public ChatCallback public: virtual void - message(const string& data, const Current&) + message(const string& data, const Ice::Current&) { cout << data << endl; } }; -class ChatClient : public Application +class ChatClient : public Ice::Application { public: virtual int run(int argc, char* argv[]) { - RouterPrx defaultRouter = communicator()->getDefaultRouter(); + Ice::RouterPrx defaultRouter = communicator()->getDefaultRouter(); if(!defaultRouter) { cerr << argv[0] << ": no default router set" << endl; @@ -128,11 +127,11 @@ public: ping->start(); string category = router->getServerProxy()->ice_getIdentity().category; - Identity callbackReceiverIdent; + Ice::Identity callbackReceiverIdent; callbackReceiverIdent.name = "callbackReceiver"; callbackReceiverIdent.category = category; - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Chat.Client"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Chat.Client"); ChatCallbackPrx callback = ChatCallbackPrx::uncheckedCast( adapter->add(new ChatCallbackI, callbackReceiverIdent)); adapter->activate(); @@ -168,7 +167,7 @@ public: while(cin.good()); router->destroySession(); } - catch(const Exception& ex) + catch(const Ice::Exception& ex) { cerr << ex << endl; diff --git a/cpp/demo/Glacier2/chat/Server.cpp b/cpp/demo/Glacier2/chat/Server.cpp index 75f1fcf9440..3e03d92f89e 100755 --- a/cpp/demo/Glacier2/chat/Server.cpp +++ b/cpp/demo/Glacier2/chat/Server.cpp @@ -7,13 +7,11 @@ // // ********************************************************************** +#include <ChatSessionI.h> #include <Ice/Application.h> #include <Glacier2/PermissionsVerifier.h> -#include <ChatSessionI.h> - using namespace std; -using namespace Ice; using namespace Demo; class DummyPermissionsVerifierI : public Glacier2::PermissionsVerifier @@ -21,7 +19,7 @@ class DummyPermissionsVerifierI : public Glacier2::PermissionsVerifier public: virtual bool - checkPermissions(const string& userId, const string& passwd, string&, const Current&) const + checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current&) const { return true; } @@ -32,23 +30,23 @@ class ChatSessionManagerI : public Glacier2::SessionManager public: virtual Glacier2::SessionPrx - create(const string& userId, const Current& current) + create(const string& userId, const Ice::Current& current) { return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(new ChatSessionI(userId))); } }; -class ChatServer : public Application +class ChatServer : public Ice::Application { public: virtual int run(int, char*[]) { - ObjectAdapterPtr adapter = communicator()->createObjectAdapter("ChatServer"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("ChatServer"); - adapter->add(new DummyPermissionsVerifierI, stringToIdentity("verifier")); - adapter->add(new ChatSessionManagerI, stringToIdentity("ChatSessionManager")); + adapter->add(new DummyPermissionsVerifierI, Ice::stringToIdentity("verifier")); + adapter->add(new ChatSessionManagerI, Ice::stringToIdentity("ChatSessionManager")); adapter->activate(); communicator()->waitForShutdown(); diff --git a/cpp/demo/Ice/MFC/client/HelloClient.cpp b/cpp/demo/Ice/MFC/client/HelloClient.cpp index 0ed631775c3..6d68c7122d9 100644 --- a/cpp/demo/Ice/MFC/client/HelloClient.cpp +++ b/cpp/demo/Ice/MFC/client/HelloClient.cpp @@ -7,74 +7,77 @@ // // ********************************************************************** -
-#include "stdafx.h"
-#include "HelloClient.h"
-#include "HelloClientDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-BEGIN_MESSAGE_MAP(CHelloClientApp, CWinApp)
- ON_COMMAND(ID_HELP, CWinApp::OnHelp)
-END_MESSAGE_MAP()
-
-CHelloClientApp::CHelloClientApp()
-{
- // Place all significant initialization in InitInstance
-}
-
-// The one and only CHelloClientApp object
-
-CHelloClientApp theApp;
-
-BOOL
-CHelloClientApp::InitInstance()
-{
- // InitCommonControls() is required on Windows XP if an application
- // manifest specifies use of ComCtl32.dll version 6 or later to enable
- // visual styles. Otherwise, any window creation will fail.
- InitCommonControls();
-
- CWinApp::InitInstance();
-
- //
- // Create a communicator.
- //
- Ice::CommunicatorPtr communicator;
- try
- {
- int argc = 0;
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, 0, properties);
- }
- catch(const IceUtil::Exception& ex)
- {
- std::ostringstream ostr;
- ostr << ex;
- std::string s = ostr.str();
- AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION);
- return FALSE;
- }
-
- CHelloClientDlg dlg(communicator);
- m_pMainWnd = &dlg;
- dlg.DoModal();
-
- //
- // Clean up.
- //
- try
- {
- communicator->destroy();
- }
- catch(const IceUtil::Exception&)
- {
- }
-
- // Since the dialog has been closed, return FALSE so that we exit the
- // application, rather than start the application's message pump.
- return FALSE;
-}
+ +#include "stdafx.h" +#include "HelloClient.h" +#include "HelloClientDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +BEGIN_MESSAGE_MAP(CHelloClientApp, CWinApp) + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +using namespace std; + + +CHelloClientApp::CHelloClientApp() +{ + // Place all significant initialization in InitInstance +} + +// The one and only CHelloClientApp object + +CHelloClientApp theApp; + +BOOL +CHelloClientApp::InitInstance() +{ + // InitCommonControls() is required on Windows XP if an application + // manifest specifies use of ComCtl32.dll version 6 or later to enable + // visual styles. Otherwise, any window creation will fail. + InitCommonControls(); + + CWinApp::InitInstance(); + + // + // Create a communicator. + // + Ice::CommunicatorPtr communicator; + try + { + int argc = 0; + Ice::PropertiesPtr properties = Ice::createProperties(); + properties->load("config"); + communicator = Ice::initializeWithProperties(argc, 0, properties); + } + catch(const IceUtil::Exception& ex) + { + ostringstream ostr; + ostr << ex; + string s = ostr.str(); + AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION); + return FALSE; + } + + CHelloClientDlg dlg(communicator); + m_pMainWnd = &dlg; + dlg.DoModal(); + + // + // Clean up. + // + try + { + communicator->destroy(); + } + catch(const IceUtil::Exception&) + { + } + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} diff --git a/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp b/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp index 5cea643eb5b..b9e6932b428 100644 --- a/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp +++ b/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp @@ -7,244 +7,247 @@ // // ********************************************************************** -
-#include "stdafx.h"
-#include "HelloClient.h"
-#include "HelloClientDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-CHelloClientDlg::CHelloClientDlg(const Ice::CommunicatorPtr& communicator, CWnd* pParent /*=NULL*/) :
- CDialog(CHelloClientDlg::IDD, pParent), _communicator(communicator), _currentMode(0),
- _useSecure(false), _useTimeout(false)
-{
- _hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-}
-
-void
-CHelloClientDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
-}
-
-BEGIN_MESSAGE_MAP(CHelloClientDlg, CDialog)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDC_INVOKE, OnSayHello)
- ON_BN_CLICKED(IDC_FLUSH, OnFlush)
- ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown)
-END_MESSAGE_MAP()
-
-BOOL
-CHelloClientDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(_hIcon, TRUE); // Set big icon
- SetIcon(_hIcon, FALSE); // Set small icon
-
- //
- // Retrieve the controls.
- //
- _mode = (CComboBox*)GetDlgItem(IDC_MODE);
- _secure = (CButton*)GetDlgItem(IDC_SECURE);
- _timeout = (CButton*)GetDlgItem(IDC_TIMEOUT);
- _status = (CStatic*)GetDlgItem(IDC_STATUSBAR);
-
- //
- // Use twoway mode as the initial default.
- //
- _mode->SetCurSel(_currentMode);
-
- //
- // Create the proxy.
- //
- Ice::PropertiesPtr properties = _communicator->getProperties();
- const char* proxyProperty = "Hello.Proxy";
- std::string proxy = properties->getProperty(proxyProperty);
- Ice::ObjectPrx obj = _communicator->stringToProxy(proxy);
- _proxy = Demo::HelloPrx::uncheckedCast(obj);
- _currentProxy = _proxy;
- _status->SetWindowText(CString(" Ready"));
-
- return TRUE; // return TRUE unless you set the focus to a control
-}
-
-// If you add a minimize button to your dialog, you will need the code below
-// to draw the icon. For MFC applications using the document/view model,
-// this is automatically done for you by the framework.
-
-void
-CHelloClientDlg::OnPaint()
-{
- if(IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, _hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
-}
-
-// The system calls this function to obtain the cursor to display while the user drags
-// the minimized window.
-HCURSOR
-CHelloClientDlg::OnQueryDragIcon()
-{
- return static_cast<HCURSOR>(_hIcon);
-}
-
-void
-CHelloClientDlg::OnSayHello()
-{
- try
- {
- updateProxy();
- _currentProxy->sayHello();
- if(_currentProxy->ice_isBatchOneway() || _currentProxy->ice_isBatchDatagram())
- {
- _status->SetWindowText(CString(" Queued batch request"));
- }
- else
- {
- _status->SetWindowText(CString(" Sent request"));
- }
- }
- catch(const IceUtil::Exception& ex)
- {
- handleException(ex);
- }
-}
-
-void
-CHelloClientDlg::OnFlush()
-{
- try
- {
- _communicator->flushBatchRequests();
- _status->SetWindowText(CString(" Flushed batch requests"));
- }
- catch(const IceUtil::Exception& ex)
- {
- handleException(ex);
- }
-}
-
-void
-CHelloClientDlg::OnShutdown()
-{
- try
- {
- updateProxy();
- _currentProxy->shutdown();
- if(_currentProxy->ice_isBatchOneway() || _currentProxy->ice_isBatchDatagram())
- {
- _status->SetWindowText(CString(" Queued shutdown request"));
- }
- else
- {
- _status->SetWindowText(CString(" Sent shutdown request"));
- }
- }
- catch(const IceUtil::Exception& ex)
- {
- handleException(ex);
- }
-}
-
-void
-CHelloClientDlg::updateProxy()
-{
- int mode = _mode->GetCurSel();
- bool secure = _secure->GetCheck() == BST_CHECKED;
- bool timeout = _timeout->GetCheck() == BST_CHECKED;
-
- if(mode == _currentMode && secure == _useSecure && timeout == _useTimeout)
- {
- return;
- }
-
- Ice::ObjectPrx proxy;
- switch(mode)
- {
- case 0:
- proxy = _proxy->ice_twoway();
- break;
- case 1:
- proxy = _proxy->ice_oneway();
- break;
- case 2:
- proxy = _proxy->ice_batchOneway();
- break;
- case 3:
- proxy = _proxy->ice_datagram();
- break;
- case 4:
- proxy = _proxy->ice_batchDatagram();
- break;
- default:
- assert(false);
- }
- proxy = proxy->ice_secure(secure);
- if(timeout)
- {
- proxy = proxy->ice_timeout(2000);
- }
- else
- {
- proxy = proxy->ice_timeout(-1);
- }
-
- if(proxy->ice_isTwoway())
- {
- _currentProxy = Demo::HelloPrx::checkedCast(proxy);
- }
- else
- {
- _currentProxy = Demo::HelloPrx::uncheckedCast(proxy);
- }
- _currentMode = mode;
- _useSecure = secure;
- _useTimeout = timeout;
-}
-
-void
-CHelloClientDlg::handleException(const IceUtil::Exception& e)
-{
- try
- {
- e.ice_throw();
- }
- catch(const Ice::NoEndpointException&)
- {
- AfxMessageBox(CString("The proxy does not support the current configuration"),
- MB_OK|MB_ICONEXCLAMATION);
- }
- catch(const IceUtil::Exception& ex)
- {
- std::ostringstream ostr;
- ostr << ex;
- std::string s = ostr.str();
- AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION);
- }
- _status->SetWindowText(CString(" Ready"));
-}
+ +#include "stdafx.h" +#include "HelloClient.h" +#include "HelloClientDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +using namespace std; +using namespace Demo; + +CHelloClientDlg::CHelloClientDlg(const Ice::CommunicatorPtr& communicator, CWnd* pParent /*=NULL*/) : + CDialog(CHelloClientDlg::IDD, pParent), _communicator(communicator), _currentMode(0), + _useSecure(false), _useTimeout(false) +{ + _hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void +CHelloClientDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CHelloClientDlg, CDialog) + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + //}}AFX_MSG_MAP + ON_BN_CLICKED(IDC_INVOKE, OnSayHello) + ON_BN_CLICKED(IDC_FLUSH, OnFlush) + ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown) +END_MESSAGE_MAP() + +BOOL +CHelloClientDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(_hIcon, TRUE); // Set big icon + SetIcon(_hIcon, FALSE); // Set small icon + + // + // Retrieve the controls. + // + _mode = (CComboBox*)GetDlgItem(IDC_MODE); + _secure = (CButton*)GetDlgItem(IDC_SECURE); + _timeout = (CButton*)GetDlgItem(IDC_TIMEOUT); + _status = (CStatic*)GetDlgItem(IDC_STATUSBAR); + + // + // Use twoway mode as the initial default. + // + _mode->SetCurSel(_currentMode); + + // + // Create the proxy. + // + Ice::PropertiesPtr properties = _communicator->getProperties(); + const char* proxyProperty = "Hello.Proxy"; + string proxy = properties->getProperty(proxyProperty); + Ice::ObjectPrx obj = _communicator->stringToProxy(proxy); + _proxy = HelloPrx::uncheckedCast(obj); + _currentProxy = _proxy; + _status->SetWindowText(CString(" Ready")); + + return TRUE; // return TRUE unless you set the focus to a control +} + +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. + +void +CHelloClientDlg::OnPaint() +{ + if(IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, _hIcon); + } + else + { + CDialog::OnPaint(); + } +} + +// The system calls this function to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR +CHelloClientDlg::OnQueryDragIcon() +{ + return static_cast<HCURSOR>(_hIcon); +} + +void +CHelloClientDlg::OnSayHello() +{ + try + { + updateProxy(); + _currentProxy->sayHello(); + if(_currentProxy->ice_isBatchOneway() || _currentProxy->ice_isBatchDatagram()) + { + _status->SetWindowText(CString(" Queued batch request")); + } + else + { + _status->SetWindowText(CString(" Sent request")); + } + } + catch(const IceUtil::Exception& ex) + { + handleException(ex); + } +} + +void +CHelloClientDlg::OnFlush() +{ + try + { + _communicator->flushBatchRequests(); + _status->SetWindowText(CString(" Flushed batch requests")); + } + catch(const IceUtil::Exception& ex) + { + handleException(ex); + } +} + +void +CHelloClientDlg::OnShutdown() +{ + try + { + updateProxy(); + _currentProxy->shutdown(); + if(_currentProxy->ice_isBatchOneway() || _currentProxy->ice_isBatchDatagram()) + { + _status->SetWindowText(CString(" Queued shutdown request")); + } + else + { + _status->SetWindowText(CString(" Sent shutdown request")); + } + } + catch(const IceUtil::Exception& ex) + { + handleException(ex); + } +} + +void +CHelloClientDlg::updateProxy() +{ + int mode = _mode->GetCurSel(); + bool secure = _secure->GetCheck() == BST_CHECKED; + bool timeout = _timeout->GetCheck() == BST_CHECKED; + + if(mode == _currentMode && secure == _useSecure && timeout == _useTimeout) + { + return; + } + + Ice::ObjectPrx proxy; + switch(mode) + { + case 0: + proxy = _proxy->ice_twoway(); + break; + case 1: + proxy = _proxy->ice_oneway(); + break; + case 2: + proxy = _proxy->ice_batchOneway(); + break; + case 3: + proxy = _proxy->ice_datagram(); + break; + case 4: + proxy = _proxy->ice_batchDatagram(); + break; + default: + assert(false); + } + proxy = proxy->ice_secure(secure); + if(timeout) + { + proxy = proxy->ice_timeout(2000); + } + else + { + proxy = proxy->ice_timeout(-1); + } + + if(proxy->ice_isTwoway()) + { + _currentProxy = HelloPrx::checkedCast(proxy); + } + else + { + _currentProxy = HelloPrx::uncheckedCast(proxy); + } + _currentMode = mode; + _useSecure = secure; + _useTimeout = timeout; +} + +void +CHelloClientDlg::handleException(const IceUtil::Exception& e) +{ + try + { + e.ice_throw(); + } + catch(const Ice::NoEndpointException&) + { + AfxMessageBox(CString("The proxy does not support the current configuration"), + MB_OK|MB_ICONEXCLAMATION); + } + catch(const IceUtil::Exception& ex) + { + ostringstream ostr; + ostr << ex; + string s = ostr.str(); + AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION); + } + _status->SetWindowText(CString(" Ready")); +} diff --git a/cpp/demo/Ice/MFC/client/README b/cpp/demo/Ice/MFC/client/README new file mode 100644 index 00000000000..9b3b2300506 --- /dev/null +++ b/cpp/demo/Ice/MFC/client/README @@ -0,0 +1,12 @@ +The client-side portion of the MFC hello demo. Note that this demo +will work against either the MFC server, or any of the other hello +servers (for example, the one contained in demo/Ice/hello). + +To run the demo, first start the server: + +$ cd ../server +$ server + +Then start the client: + +$ client diff --git a/cpp/demo/Ice/MFC/server/HelloServer.cpp b/cpp/demo/Ice/MFC/server/HelloServer.cpp index 3efa6a59fc5..2f9c430f493 100644 --- a/cpp/demo/Ice/MFC/server/HelloServer.cpp +++ b/cpp/demo/Ice/MFC/server/HelloServer.cpp @@ -7,102 +7,104 @@ // // ********************************************************************** -
-#include "stdafx.h"
-#include "HelloServer.h"
-#include "HelloServerDlg.h"
-#include "HelloI.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-BEGIN_MESSAGE_MAP(CHelloServerApp, CWinApp)
- ON_COMMAND(ID_HELP, CWinApp::OnHelp)
-END_MESSAGE_MAP()
-
-CHelloServerApp::CHelloServerApp()
-{
- // Place all significant initialization in InitInstance
-}
-
-// The one and only CHelloServerApp object
-
-CHelloServerApp theApp;
-
-BOOL CHelloServerApp::InitInstance()
-{
- //
- // InitCommonControls() is required on Windows XP if an application
- // manifest specifies use of ComCtl32.dll version 6 or later to enable
- // visual styles. Otherwise, any window creation will fail.
- //
- InitCommonControls();
-
- CWinApp::InitInstance();
-
- //
- // Create a communicator and object adapter.
- //
- Ice::CommunicatorPtr communicator;
- Ice::ObjectAdapterPtr adapter;
- LogIPtr log;
- try
- {
- int argc = 0;
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, 0, properties);
- log = new LogI;
- communicator->setLogger(log);
- adapter = communicator->createObjectAdapter("Hello");
- }
- catch(const IceUtil::Exception& ex)
- {
- std::ostringstream ostr;
- ostr << ex;
- std::string s = ostr.str();
- AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION);
- return FALSE;
- }
-
- //
- // Create the dialog.
- //
- CHelloServerDlg dlg(communicator, log);
-
- //
- // Instantiate the servant.
- //
- Ice::ObjectPtr servant = new HelloI(log, &dlg);
- adapter->add(servant, Ice::stringToIdentity("hello"));
- adapter->activate();
- log->message("Ready to receive requests.");
-
- //
- // Show dialog and wait until it is closed, or until the servant receives
- // a shutdown request.
- //
- m_pMainWnd = &dlg;
- dlg.DoModal();
-
- //
- // Edit control no longer exists.
- //
- log->setHandle(0);
-
- //
- // Clean up.
- //
- try
- {
- communicator->destroy();
- }
- catch(const IceUtil::Exception&)
- {
- }
-
- // Since the dialog has been closed, return FALSE so that we exit the
- // application, rather than start the application's message pump.
- return FALSE;
-}
+ +#include "stdafx.h" +#include "HelloServer.h" +#include "HelloServerDlg.h" +#include "HelloI.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +BEGIN_MESSAGE_MAP(CHelloServerApp, CWinApp) + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +using namespace std; + +CHelloServerApp::CHelloServerApp() +{ + // Place all significant initialization in InitInstance +} + +// The one and only CHelloServerApp object + +CHelloServerApp theApp; + +BOOL CHelloServerApp::InitInstance() +{ + // + // InitCommonControls() is required on Windows XP if an application + // manifest specifies use of ComCtl32.dll version 6 or later to enable + // visual styles. Otherwise, any window creation will fail. + // + InitCommonControls(); + + CWinApp::InitInstance(); + + // + // Create a communicator and object adapter. + // + Ice::CommunicatorPtr communicator; + Ice::ObjectAdapterPtr adapter; + LogIPtr log; + try + { + int argc = 0; + Ice::PropertiesPtr properties = Ice::createProperties(); + properties->load("config"); + communicator = Ice::initializeWithProperties(argc, 0, properties); + log = new LogI; + communicator->setLogger(log); + adapter = communicator->createObjectAdapter("Hello"); + } + catch(const IceUtil::Exception& ex) + { + ostringstream ostr; + ostr << ex; + string s = ostr.str(); + AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION); + return FALSE; + } + + // + // Create the dialog. + // + CHelloServerDlg dlg(communicator, log); + + // + // Instantiate the servant. + // + Ice::ObjectPtr servant = new HelloI(log, &dlg); + adapter->add(servant, Ice::stringToIdentity("hello")); + adapter->activate(); + log->message("Ready to receive requests."); + + // + // Show dialog and wait until it is closed, or until the servant receives + // a shutdown request. + // + m_pMainWnd = &dlg; + dlg.DoModal(); + + // + // Edit control no longer exists. + // + log->setHandle(0); + + // + // Clean up. + // + try + { + communicator->destroy(); + } + catch(const IceUtil::Exception&) + { + } + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} diff --git a/cpp/demo/Ice/MFC/server/HelloServerDlg.cpp b/cpp/demo/Ice/MFC/server/HelloServerDlg.cpp index 99e3401dc7e..a6a29a7b0fa 100644 --- a/cpp/demo/Ice/MFC/server/HelloServerDlg.cpp +++ b/cpp/demo/Ice/MFC/server/HelloServerDlg.cpp @@ -7,118 +7,119 @@ // // ********************************************************************** -
-#include "stdafx.h"
-#include "HelloServer.h"
-#include "HelloServerDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-CHelloServerDlg::CHelloServerDlg(const Ice::CommunicatorPtr& communicator, const LogIPtr& log,
- CWnd* pParent /*=NULL*/) :
- CDialog(CHelloServerDlg::IDD, pParent), _communicator(communicator), _log(log)
-{
- _hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-}
-
-void
-CHelloServerDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
-}
-
-BEGIN_MESSAGE_MAP(CHelloServerDlg, CDialog)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown)
- ON_BN_CLICKED(IDC_CLEAR, OnClear)
+ +#include "stdafx.h" +#include "HelloServer.h" +#include "HelloServerDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +CHelloServerDlg::CHelloServerDlg(const Ice::CommunicatorPtr& communicator, const LogIPtr& log, + CWnd* pParent /*=NULL*/) : + CDialog(CHelloServerDlg::IDD, pParent), _communicator(communicator), _log(log) +{ + _hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void +CHelloServerDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CHelloServerDlg, CDialog) + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + //}}AFX_MSG_MAP + ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown) + ON_BN_CLICKED(IDC_CLEAR, OnClear) ON_MESSAGE(WM_USER, OnLog) -END_MESSAGE_MAP()
-
-BOOL
-CHelloServerDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(_hIcon, TRUE); // Set big icon
- SetIcon(_hIcon, FALSE); // Set small icon
-
- //
- // Retrieve the edit control.
- //
- _edit = (CEdit*)GetDlgItem(IDC_LOG);
- _log->setHandle(m_hWnd);
-
- //
- // Set the focus to the shutdown button, so that the text in the log
- // is not initially highlighted.
- //
- ((CButton*)GetDlgItem(IDC_SHUTDOWN))->SetFocus();
-
- return FALSE; // return FALSE because we explicitly set the focus
-}
-
-void
-CHelloServerDlg::OnCancel()
-{
- _log->setHandle(0);
- CDialog::OnCancel();
-}
-
-// If you add a minimize button to your dialog, you will need the code below
-// to draw the icon. For MFC applications using the document/view model,
-// this is automatically done for you by the framework.
-
-void
-CHelloServerDlg::OnPaint()
-{
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, _hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
-}
-
-// The system calls this function to obtain the cursor to display while the user drags
-// the minimized window.
-HCURSOR
-CHelloServerDlg::OnQueryDragIcon()
-{
- return static_cast<HCURSOR>(_hIcon);
-}
-
-void
-CHelloServerDlg::OnShutdown()
-{
- EndDialog(0);
-}
-
-void
-CHelloServerDlg::OnClear()
-{
- _edit->SetWindowText(CString(""));
-}
+END_MESSAGE_MAP() + +BOOL +CHelloServerDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(_hIcon, TRUE); // Set big icon + SetIcon(_hIcon, FALSE); // Set small icon + + // + // Retrieve the edit control. + // + _edit = (CEdit*)GetDlgItem(IDC_LOG); + _log->setHandle(m_hWnd); + + // + // Set the focus to the shutdown button, so that the text in the log + // is not initially highlighted. + // + ((CButton*)GetDlgItem(IDC_SHUTDOWN))->SetFocus(); + + return FALSE; // return FALSE because we explicitly set the focus +} + +void +CHelloServerDlg::OnCancel() +{ + _log->setHandle(0); + CDialog::OnCancel(); +} + +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. + +void +CHelloServerDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, _hIcon); + } + else + { + CDialog::OnPaint(); + } +} + +// The system calls this function to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR +CHelloServerDlg::OnQueryDragIcon() +{ + return static_cast<HCURSOR>(_hIcon); +} + +void +CHelloServerDlg::OnShutdown() +{ + EndDialog(0); +} + +void +CHelloServerDlg::OnClear() +{ + _edit->SetWindowText(CString("")); +} LRESULT CHelloServerDlg::OnLog(WPARAM wParam, LPARAM lParam) diff --git a/cpp/demo/Ice/MFC/server/README b/cpp/demo/Ice/MFC/server/README new file mode 100644 index 00000000000..aaf732932a6 --- /dev/null +++ b/cpp/demo/Ice/MFC/server/README @@ -0,0 +1,12 @@ +The server-side portion of the MFC hello demo. Note that this demo +will work against either the MFC client, or any of the other hello +clikents (for example, the one in demo/Ice/hello). + +To run the demo, first start the server: + +$ server + +Then start the client: + +$ cd ../client +$ client diff --git a/cpp/demo/Ice/minimal/Client.cpp b/cpp/demo/Ice/minimal/Client.cpp new file mode 100644 index 00000000000..6f2e4a966d9 --- /dev/null +++ b/cpp/demo/Ice/minimal/Client.cpp @@ -0,0 +1,116 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <Hello.h> + +using namespace std; +using namespace Demo; + +void +menu() +{ + cout << + "usage:\n" + "h: send greeting as twoway\n" + "x: exit\n" + "?: help\n"; +} + +int +run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +{ + Ice::PropertiesPtr properties = communicator->getProperties(); + const char* proxyProperty = "Hello.Proxy"; + string proxy = properties->getProperty(proxyProperty); + if(proxy.empty()) + { + cerr << argv[0] << ": property `" << proxyProperty << "' not set" << endl; + return EXIT_FAILURE; + } + + Ice::ObjectPrx base = communicator->stringToProxy(proxy); + HelloPrx hello = HelloPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false)); + if(!hello) + { + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; + } + + menu(); + + char c; + do + { + try + { + cout << "==> "; + cin >> c; + if(c == 'h') + { + hello->sayHello(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } + } + while(cin.good() && c != 'x'); + + return EXIT_SUCCESS; +} + +int +main(int argc, char* argv[]) +{ + int status; + Ice::CommunicatorPtr communicator; + + try + { + Ice::PropertiesPtr properties = Ice::createProperties(); + properties->load("config"); + communicator = Ice::initializeWithProperties(argc, argv, properties); + status = run(argc, argv, communicator); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + + if(communicator) + { + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + } + + return status; +} diff --git a/cpp/demo/Ice/minimal/Hello.ice b/cpp/demo/Ice/minimal/Hello.ice new file mode 100644 index 00000000000..1e35e0829fa --- /dev/null +++ b/cpp/demo/Ice/minimal/Hello.ice @@ -0,0 +1,23 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef HELLO_ICE +#define HELLO_ICE + +module Demo +{ + +interface Hello +{ + nonmutating void sayHello(); +}; + +}; + +#endif diff --git a/cpp/demo/Ice/minimal/HelloI.cpp b/cpp/demo/Ice/minimal/HelloI.cpp new file mode 100644 index 00000000000..ad1810a53f2 --- /dev/null +++ b/cpp/demo/Ice/minimal/HelloI.cpp @@ -0,0 +1,19 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <HelloI.h> +#include <Ice/Ice.h> + +using namespace std; + +void +HelloI::sayHello(const Ice::Current&) const +{ + cout << "Hello World!" << endl; +} diff --git a/cpp/demo/Ice/minimal/HelloI.h b/cpp/demo/Ice/minimal/HelloI.h new file mode 100644 index 00000000000..c0e7e2f6fdb --- /dev/null +++ b/cpp/demo/Ice/minimal/HelloI.h @@ -0,0 +1,22 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef HELLO_I_H +#define HELLO_I_H + +#include <Hello.h> + +class HelloI : public Demo::Hello +{ +public: + + virtual void sayHello(const Ice::Current&) const; +}; + +#endif diff --git a/cpp/demo/Ice/minimal/Makefile b/cpp/demo/Ice/minimal/Makefile new file mode 100644 index 00000000000..73cc2fd5a49 --- /dev/null +++ b/cpp/demo/Ice/minimal/Makefile @@ -0,0 +1,42 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ../../.. + +CLIENT = client +SERVER = server + +TARGETS = $(CLIENT) $(SERVER) + +OBJS = Hello.o + +COBJS = Client.o + +SOBJS = HelloI.o \ + Server.o + +SRCS = $(OBJS:.o=.cpp) \ + $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) + +SLICE_SRCS = Hello.ice + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. $(CPPFLAGS) + +$(CLIENT): $(OBJS) $(COBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(COBJS) $(LIBS) + +$(SERVER): $(OBJS) $(SOBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(SOBJS) $(LIBS) + +include .depend diff --git a/cpp/demo/Ice/minimal/README b/cpp/demo/Ice/minimal/README new file mode 100644 index 00000000000..dc9a911ca8f --- /dev/null +++ b/cpp/demo/Ice/minimal/README @@ -0,0 +1,9 @@ +This demo is a minimal Ice "hello world" application. + +To run the demo, first start the server: + +$ server + +In a separate window, start the client: + +$ client diff --git a/cpp/demo/Ice/minimal/Server.cpp b/cpp/demo/Ice/minimal/Server.cpp new file mode 100644 index 00000000000..a3fc47e146c --- /dev/null +++ b/cpp/demo/Ice/minimal/Server.cpp @@ -0,0 +1,58 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <HelloI.h> +#include <Ice/Ice.h> + +using namespace std; + +int +run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +{ + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello"); + adapter->add(new HelloI, Ice::stringToIdentity("hello")); + adapter->activate(); + communicator->waitForShutdown(); + return EXIT_SUCCESS; +} + +int +main(int argc, char* argv[]) +{ + int status; + Ice::CommunicatorPtr communicator; + + try + { + Ice::PropertiesPtr properties = Ice::createProperties(); + properties->load("config"); + communicator = Ice::initializeWithProperties(argc, argv, properties); + status = run(argc, argv, communicator); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + + if(communicator) + { + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + } + + return status; +} diff --git a/cpp/demo/Ice/minimal/config b/cpp/demo/Ice/minimal/config new file mode 100644 index 00000000000..39c092f4770 --- /dev/null +++ b/cpp/demo/Ice/minimal/config @@ -0,0 +1,84 @@ +# +# The client reads this property to create the reference to the +# "hello" object in the server. +# +Hello.Proxy=hello:tcp -p 10000:udp -p 10000:ssl -p 10001 + +# +# The server creates one single object adapter with the name +# "Hello". The following line sets the endpoints for this +# adapter. +# +Hello.Endpoints=tcp -p 10000:udp -p 10000:ssl -p 10001 + +# +# Warn about connection exceptions +# +Ice.Warn.Connections=1 + +# +# We want a faster ACM for this demo. +# +Ice.ACM.Client=10 +Ice.ACM.Server=10 + +# +# Network Tracing +# +# 0 = no network tracing +# 1 = trace connection establishment and closure +# 2 = like 1, but more detailed +# 3 = like 2, but also trace data transfer +# +Ice.Trace.Network=0 + +# +# Protocol Tracing +# +# 0 = no protocol tracing +# 1 = trace protocol messages +# +Ice.Trace.Protocol=0 + +# +# Security Tracing +# +# 0 = no security tracing +# 1 = trace warning messages +# 2 = config file parsing warnings +# +IceSSL.Trace.Security=0 + +# +# SSL Configuration File +# +# An XML based file that specifies the certificates, keys, SSL version +# and other pertinent information for creating an SSL connection. +# +Ice.Plugin.IceSSL=IceSSL:create +IceSSL.Client.CertPath=../../../certs +IceSSL.Client.Config=sslconfig.xml +IceSSL.Server.CertPath=../../../certs +IceSSL.Server.Config=sslconfig.xml + +# +# IcePack registry settings (assumes that a db directory exists in the +# current working directory). +# +IcePack.Registry.Client.Endpoints=default -p 10006 +IcePack.Registry.Server.Endpoints=default +IcePack.Registry.Internal.Endpoints=default +IcePack.Registry.Admin.Endpoints=default +IcePack.Registry.Data=db +IcePack.Registry.DynamicRegistration=1 + +# +# Uncomment the following lines if you want to run this demo with the +# IcePack registry. Note that we override properties previously set +# above, so make sure to comment out these properties to run the demo +# without IcePack. +# +#Hello.Proxy=hello@HelloAdapter +#Hello.Endpoints=tcp:udp:ssl +#Hello.AdapterId=HelloAdapter +#Ice.Default.Locator=IcePack/Locator:default -p 10006 diff --git a/cpp/demo/Ice/minimal/minimalC.dsp b/cpp/demo/Ice/minimal/minimalC.dsp new file mode 100644 index 00000000000..b97ebeebd2c --- /dev/null +++ b/cpp/demo/Ice/minimal/minimalC.dsp @@ -0,0 +1,153 @@ +# Microsoft Developer Studio Project File - Name="minimalC" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=minimalC - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "minimalC.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "minimalC.mak" CFG="minimalC - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "minimalC - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "minimalC - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "minimalC - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /WX /GR /GX /O2 /I "." /I "../../../include" /I "../../../include/stlport" /D "_CONSOLE" /D "NDEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /c +# SUBTRACT CPP /Fr /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Ice.lib IceUtil.lib /nologo /subsystem:console /incremental:yes /machine:I386 /out:"client.exe" /libpath:"../../../lib" /FIXED:no +# SUBTRACT LINK32 /debug /nodefaultlib + +!ELSEIF "$(CFG)" == "minimalC - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /I "../../../include/stlport" /D "_CONSOLE" /D "_DEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /GZ /c +# SUBTRACT CPP /Fr /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Iced.lib IceUtild.lib /nologo /subsystem:console /debug /machine:I386 /out:"client.exe" /pdbtype:sept /libpath:"../../../lib" /FIXED:no +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "minimalC - Win32 Release" +# Name "minimalC - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\Client.cpp +# End Source File +# Begin Source File + +SOURCE=.\Hello.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Hello.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\Hello.ice + +!IF "$(CFG)" == "minimalC - Win32 Release" + +USERDEP__HELLO="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\slice.lib" +# Begin Custom Build +InputPath=.\Hello.ice + +BuildCmds= \ + ..\..\..\bin\slice2cpp.exe Hello.ice + +"Hello.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) + +"Hello.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) +# End Custom Build + +!ELSEIF "$(CFG)" == "minimalC - Win32 Debug" + +USERDEP__HELLO="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\sliced.lib" +# Begin Custom Build +InputPath=.\Hello.ice + +BuildCmds= \ + ..\..\..\bin\slice2cpp.exe Hello.ice + +"Hello.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) + +"Hello.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) +# End Custom Build + +!ENDIF + +# End Source File +# End Group +# End Target +# End Project diff --git a/cpp/demo/Ice/minimal/minimalS.dsp b/cpp/demo/Ice/minimal/minimalS.dsp new file mode 100644 index 00000000000..e9a45a56972 --- /dev/null +++ b/cpp/demo/Ice/minimal/minimalS.dsp @@ -0,0 +1,161 @@ +# Microsoft Developer Studio Project File - Name="minimalS" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=minimalS - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "minimalS.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "minimalS.mak" CFG="minimalS - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "minimalS - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "minimalS - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "minimalS - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /WX /GR /GX /O2 /I "." /I "../../../include" /I "../../../include/stlport" /D "_CONSOLE" /D "NDEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /c +# SUBTRACT CPP /Fr /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Ice.lib IceUtil.lib /nologo /subsystem:console /incremental:yes /machine:I386 /out:"server.exe" /libpath:"../../../lib" /FIXED:no +# SUBTRACT LINK32 /debug /nodefaultlib + +!ELSEIF "$(CFG)" == "minimalS - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /I "../../../include/stlport" /D "_CONSOLE" /D "_DEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /GZ /c +# SUBTRACT CPP /Fr /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Iced.lib IceUtild.lib /nologo /subsystem:console /debug /machine:I386 /out:"server.exe" /pdbtype:sept /libpath:"../../../lib" /FIXED:no +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "minimalS - Win32 Release" +# Name "minimalS - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\Hello.cpp +# End Source File +# Begin Source File + +SOURCE=.\HelloI.cpp +# End Source File +# Begin Source File + +SOURCE=.\Server.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Hello.h +# End Source File +# Begin Source File + +SOURCE=.\HelloI.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\Hello.ice + +!IF "$(CFG)" == "minimalS - Win32 Release" + +USERDEP__HELLO="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\slice.lib" +# Begin Custom Build +InputPath=.\Hello.ice + +BuildCmds= \ + ..\..\..\bin\slice2cpp.exe Hello.ice + +"Hello.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) + +"Hello.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) +# End Custom Build + +!ELSEIF "$(CFG)" == "minimalS - Win32 Debug" + +USERDEP__HELLO="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\sliced.lib" +# Begin Custom Build +InputPath=.\Hello.ice + +BuildCmds= \ + ..\..\..\bin\slice2cpp.exe Hello.ice + +"Hello.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) + +"Hello.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) +# End Custom Build + +!ENDIF + +# End Source File +# End Group +# End Target +# End Project diff --git a/cpp/demo/IceBox/hello/Client.cpp b/cpp/demo/IceBox/hello/Client.cpp index c0158a7e242..8366704983f 100644 --- a/cpp/demo/IceBox/hello/Client.cpp +++ b/cpp/demo/IceBox/hello/Client.cpp @@ -7,14 +7,32 @@ // // ********************************************************************** -#include <Ice/Ice.h> +#include <Ice/Application.h> #include <Hello.h> using namespace std; using namespace Demo; +class HelloClient : public Ice::Application +{ +public: + + virtual int run(int, char*[]); + +private: + + void menu(); +}; + +int +main(int argc, char* argv[]) +{ + HelloClient app; + return app.main(argc, argv, "config"); +} + void -menu() +HelloClient::menu() { cout << "usage:\n" @@ -31,9 +49,9 @@ menu() } int -run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +HelloClient::run(int argc, char* argv[]) { - Ice::PropertiesPtr properties = communicator->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); const char* proxyProperty = "Hello.Proxy"; std::string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) @@ -42,7 +60,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) return EXIT_FAILURE; } - Ice::ObjectPrx base = communicator->stringToProxy(proxy); + Ice::ObjectPrx base = communicator()->stringToProxy(proxy); HelloPrx twoway = HelloPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { @@ -102,7 +120,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } else if(c == 'f') { - communicator->flushBatchRequests(); + communicator()->flushBatchRequests(); } else if(c == 'T') { @@ -170,38 +188,3 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) return EXIT_SUCCESS; } - -int -main(int argc, char* argv[]) -{ - int status; - Ice::CommunicatorPtr communicator; - - try - { - Ice::PropertiesPtr properties = Ice::createProperties(); - properties->load("config"); - communicator = Ice::initializeWithProperties(argc, argv, properties); - status = run(argc, argv, communicator); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - } - - return status; -} diff --git a/cpp/demo/IceBox/hello/HelloServiceI.cpp b/cpp/demo/IceBox/hello/HelloServiceI.cpp index a86dac4fe44..58b7f2d4110 100644 --- a/cpp/demo/IceBox/hello/HelloServiceI.cpp +++ b/cpp/demo/IceBox/hello/HelloServiceI.cpp @@ -19,8 +19,8 @@ extern "C" // // Factory function // -HELLO_API ::IceBox::Service* -create(::Ice::CommunicatorPtr communicator) +HELLO_API IceBox::Service* +create(Ice::CommunicatorPtr communicator) { return new HelloServiceI; } @@ -36,13 +36,10 @@ HelloServiceI::~HelloServiceI() } void -HelloServiceI::start(const string& name, - const ::Ice::CommunicatorPtr& communicator, - const ::Ice::StringSeq& args) +HelloServiceI::start(const string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args) { _adapter = communicator->createObjectAdapter(name); - ::Ice::ObjectPtr object = new HelloI; - _adapter->add(object, ::Ice::stringToIdentity("hello")); + _adapter->add(new HelloI, Ice::stringToIdentity("hello")); _adapter->activate(); } diff --git a/cpp/demo/IcePack/hello/Client.cpp b/cpp/demo/IcePack/hello/Client.cpp index 045ae8f8419..8ded43dc78d 100644 --- a/cpp/demo/IcePack/hello/Client.cpp +++ b/cpp/demo/IcePack/hello/Client.cpp @@ -7,15 +7,33 @@ // // ********************************************************************** -#include <Ice/Ice.h> +#include <Ice/Application.h> #include <IcePack/Query.h> #include <Hello.h> using namespace std; using namespace Demo; +class HelloClient : public Ice::Application +{ +public: + + virtual int run(int, char*[]); + +private: + + void menu(); +}; + +int +main(int argc, char* argv[]) +{ + HelloClient app; + return app.main(argc, argv, "config"); +} + void -menu() +HelloClient::menu() { cout << "usage:\n" @@ -30,11 +48,11 @@ menu() } int -run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +HelloClient::run(int argc, char* argv[]) { - Ice::PropertiesPtr properties = communicator->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); - IcePack::QueryPrx query = IcePack::QueryPrx::checkedCast(communicator->stringToProxy("IcePack/Query")); + IcePack::QueryPrx query = IcePack::QueryPrx::checkedCast(communicator()->stringToProxy("IcePack/Query")); // // Get an object implementing the HelloFactory interface. @@ -155,38 +173,3 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) return EXIT_SUCCESS; } - -int -main(int argc, char* argv[]) -{ - int status; - Ice::CommunicatorPtr communicator; - - try - { - Ice::PropertiesPtr properties = Ice::createProperties(); - properties->load("config"); - communicator = Ice::initializeWithProperties(argc, argv, properties); - status = run(argc, argv, communicator); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - } - - return status; -} diff --git a/cpp/demo/IcePack/hello/HelloI.cpp b/cpp/demo/IcePack/hello/HelloI.cpp index c2c014599c0..4d99bec43ed 100644 --- a/cpp/demo/IcePack/hello/HelloI.cpp +++ b/cpp/demo/IcePack/hello/HelloI.cpp @@ -7,9 +7,9 @@ // // ********************************************************************** +#include <HelloI.h> #include <Ice/Ice.h> #include <IcePack/Admin.h> -#include <HelloI.h> using namespace std; using namespace Demo; @@ -28,27 +28,39 @@ HelloFactoryI::create(const string& name, const Ice::Current& current) // Create the servant and add it to the object adapter using the // given name as the identity. // - Ice::ObjectPtr hello = new HelloI(name); - Ice::ObjectPrx object = adapter->add(hello, Ice::stringToIdentity(name)); + Ice::ObjectPrx object; + try + { + object = adapter->add(new HelloI(name), Ice::stringToIdentity(name)); + } + catch(const Ice::AlreadyRegisteredException&) + { + // + // The object is already registered. + // + throw NameExistsException(); + } // // Get the IcePack Admin interface and register the newly created // Hello object with the IcePack object registry. // + IcePack::AdminPrx admin = IcePack::AdminPrx::checkedCast(communicator->stringToProxy("IcePack/Admin")); try { - IcePack::AdminPrx admin = IcePack::AdminPrx::checkedCast(communicator->stringToProxy("IcePack/Admin")); admin->addObject(object); } catch(const IcePack::ObjectExistsException&) { // - // An object with the same identity is already registered with - // the registry. Remove the object from the object adapter and - // throw. + // This should only occur if the server has been restarted and + // the server objects haven't been removed from the object + // registry. // - adapter->remove(object->ice_getIdentity()); - throw NameExistsException(); + // In this case remove the current object, and re-add. + // + admin->removeObject(object->ice_getIdentity()); + admin->addObject(object); } string id = communicator->getProperties()->getProperty("Identity"); @@ -61,7 +73,7 @@ HelloFactoryI::create(const string& name, const Ice::Current& current) HelloPrx HelloFactoryI::find(const string& name, const Ice::Current& current) const { - Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); + const Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); // // The object is registered with the IcePack object registry so we @@ -112,8 +124,8 @@ HelloI::sayHello(const Ice::Current&) const void HelloI::destroy(const Ice::Current& current) { - Ice::ObjectAdapterPtr adapter = current.adapter; - Ice::CommunicatorPtr communicator = adapter->getCommunicator(); + const Ice::ObjectAdapterPtr adapter = current.adapter; + const Ice::CommunicatorPtr communicator = adapter->getCommunicator(); // // Get the IcePack Admin interface and remove the Hello object diff --git a/cpp/demo/IcePack/hello/HelloI.h b/cpp/demo/IcePack/hello/HelloI.h index 18e2ff18de8..d3f8e758d7f 100644 --- a/cpp/demo/IcePack/hello/HelloI.h +++ b/cpp/demo/IcePack/hello/HelloI.h @@ -23,13 +23,11 @@ public: HelloFactoryI(); virtual Demo::HelloPrx create(const std::string&, const Ice::Current&); - virtual Demo::HelloPrx find(const std::string&, const Ice::Current&) const; private: std::string _id; - }; class HELLO_API HelloI : public Demo::Hello @@ -37,12 +35,9 @@ class HELLO_API HelloI : public Demo::Hello public: HelloI(const std::string&); - virtual void sayHello(const Ice::Current&) const; + virtual void sayHello(const Ice::Current&) const; virtual void destroy(const Ice::Current&); - -private: - Ice::CommunicatorPtr _communicator; }; #endif diff --git a/cpp/demo/IcePack/hello/Server.cpp b/cpp/demo/IcePack/hello/Server.cpp index 1b328a7415a..be376fd4b0c 100644 --- a/cpp/demo/IcePack/hello/Server.cpp +++ b/cpp/demo/IcePack/hello/Server.cpp @@ -7,8 +7,8 @@ // // ********************************************************************** -#include <Ice/Ice.h> #include <HelloI.h> +#include <Ice/Application.h> using namespace std; @@ -27,8 +27,7 @@ Server::run(int argc, char* argv[]) string id = communicator()->getProperties()->getProperty("Identity"); - Ice::ObjectPtr object = new HelloFactoryI(); - adapter->add(object, Ice::stringToIdentity(id)); + adapter->add(new HelloFactoryI, Ice::stringToIdentity(id)); adapter->activate(); communicator()->waitForShutdown(); @@ -39,6 +38,5 @@ int main(int argc, char* argv[]) { Server app; - int status = app.main(argc, argv); - return status; + return app.main(argc, argv); } diff --git a/cpp/demo/IcePatch2/MFC/PatchClient.cpp b/cpp/demo/IcePatch2/MFC/PatchClient.cpp index 66abeb27f8c..4f982cff642 100755 --- a/cpp/demo/IcePatch2/MFC/PatchClient.cpp +++ b/cpp/demo/IcePatch2/MFC/PatchClient.cpp @@ -19,6 +19,8 @@ BEGIN_MESSAGE_MAP(CPatchClientApp, CWinApp) ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() +using namespace std; + CPatchClientApp::CPatchClientApp() { // Place all significant initialization in InitInstance @@ -48,9 +50,9 @@ CPatchClientApp::InitInstance() } catch(const IceUtil::Exception& ex) { - std::ostringstream ostr; + ostringstream ostr; ostr << ex; - std::string s = ostr.str(); + string s = ostr.str(); AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION); return FALSE; } diff --git a/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp b/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp index cbfe479a5de..3c848196642 100755 --- a/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp +++ b/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp @@ -18,6 +18,8 @@ #define new DEBUG_NEW #endif +using namespace std; + class DialogPatcherFeedback : public IcePatch2::PatcherFeedback { public: @@ -30,7 +32,7 @@ public: } virtual bool - noFileSummary(const std::string& reason) + noFileSummary(const string& reason) { return IDYES == AfxMessageBox("Cannot load file summary. Perform a thorough patch?", MB_YESNO|MB_ICONSTOP); } @@ -42,7 +44,7 @@ public: } virtual bool - checksumProgress(const std::string& path) + checksumProgress(const string& path) { return _dialog->checksumProgress(path); } @@ -72,7 +74,7 @@ public: } virtual bool - patchStart(const std::string& path, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize) + patchStart(const string& path, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize) { return _dialog->patchStart(path, size, totalProgress, totalSize); } @@ -123,7 +125,7 @@ CPatchDlg::checksumStart() } bool -CPatchDlg::checksumProgress(const std::string& path) +CPatchDlg::checksumProgress(const string& path) { // TODO: indicate busy progress @@ -175,7 +177,7 @@ CPatchDlg::fileListEnd() } bool -CPatchDlg::patchStart(const std::string& path, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize) +CPatchDlg::patchStart(const string& path, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize) { if(!_isPatch) { @@ -375,18 +377,18 @@ CPatchDlg::OnStartPatch() AfxMessageBox(CString("Please select a patch directory."), MB_OK|MB_ICONEXCLAMATION); return; } - properties->setProperty("IcePatch2.Directory", std::string(path)); + properties->setProperty("IcePatch2.Directory", string(path)); // // Set the thorough patch flag. // - std::string thorough = _thorough->GetCheck() == BST_CHECKED ? "1" : "0"; + string thorough = _thorough->GetCheck() == BST_CHECKED ? "1" : "0"; properties->setProperty("IcePatch2.Thorough", thorough); // // Set the remove orphan flag. // - std::string remove = _remove->GetCheck() == BST_CHECKED ? "1" : "0"; + string remove = _remove->GetCheck() == BST_CHECKED ? "1" : "0"; properties->setProperty("IcePatch2.Remove", remove); DialogPatcherFeedbackPtr feedback = new DialogPatcherFeedback(this); @@ -423,7 +425,7 @@ CPatchDlg::OnStartPatch() { handleException(ex); } - catch(const std::string& ex) + catch(const string& ex) { AfxMessageBox(CString(ex.c_str()), MB_OK|MB_ICONEXCLAMATION); } @@ -477,9 +479,9 @@ CPatchDlg::handleException(const IceUtil::Exception& e) } catch(const IceUtil::Exception& ex) { - std::ostringstream ostr; + ostringstream ostr; ostr << ex; - std::string s = ostr.str(); + string s = ostr.str(); AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION); } diff --git a/cpp/demo/IcePatch2/MFC/PatchClientDlg.h b/cpp/demo/IcePatch2/MFC/PatchClientDlg.h index 5cd569792da..f008d10ba4c 100755 --- a/cpp/demo/IcePatch2/MFC/PatchClientDlg.h +++ b/cpp/demo/IcePatch2/MFC/PatchClientDlg.h @@ -39,7 +39,7 @@ protected: virtual void DoDataExchange(CDataExchange*); // DDX/DDV support protected: - Ice::CommunicatorPtr _communicator; + const Ice::CommunicatorPtr _communicator; IceUtil::Time _startTime; CEdit* _path; CButton* _thorough; |