diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
commit | abada90e3f84dc703b8ddc9efcbed8a946fadead (patch) | |
tree | 2c6f9dccd510ea97cb927a7bd635422efaae547a /cpp/demo/Ice | |
parent | removing trace message (diff) | |
download | ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2 ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip |
Expanded tabs into spaces
Diffstat (limited to 'cpp/demo/Ice')
31 files changed, 1108 insertions, 1108 deletions
diff --git a/cpp/demo/Ice/MFC/client/HelloClient.cpp b/cpp/demo/Ice/MFC/client/HelloClient.cpp index 73d4a30e6f5..cc97e071f20 100644 --- a/cpp/demo/Ice/MFC/client/HelloClient.cpp +++ b/cpp/demo/Ice/MFC/client/HelloClient.cpp @@ -48,9 +48,9 @@ CHelloClientApp::InitInstance() try { int argc = 0; - Ice::InitializationData initData; - initData.properties = Ice::createProperties(); - initData.properties->load("config"); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(); + initData.properties->load("config"); communicator = Ice::initialize(argc, 0, initData); } catch(const IceUtil::Exception& ex) diff --git a/cpp/demo/Ice/MFC/client/stdafx.h b/cpp/demo/Ice/MFC/client/stdafx.h index 81d5a220522..6ad764438f9 100644 --- a/cpp/demo/Ice/MFC/client/stdafx.h +++ b/cpp/demo/Ice/MFC/client/stdafx.h @@ -22,30 +22,30 @@ #endif
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
-#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
+#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
-#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
-#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
-#endif
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
+#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#endif
#if 0
-#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
-#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
-#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
+#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
+#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
@@ -53,9 +53,9 @@ #include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
-#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
+#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <Ice/Ice.h>
diff --git a/cpp/demo/Ice/MFC/server/HelloServer.cpp b/cpp/demo/Ice/MFC/server/HelloServer.cpp index 064b6e4e0cf..6d60db6f561 100644 --- a/cpp/demo/Ice/MFC/server/HelloServer.cpp +++ b/cpp/demo/Ice/MFC/server/HelloServer.cpp @@ -51,11 +51,11 @@ BOOL CHelloServerApp::InitInstance() try { int argc = 0; - Ice::InitializationData initData; + Ice::InitializationData initData; initData.properties = Ice::createProperties(); - initData.properties->load("config"); + initData.properties->load("config"); log = new LogI; - initData.logger = log; + initData.logger = log; communicator = Ice::initialize(argc, 0, initData); adapter = communicator->createObjectAdapter("Hello"); } diff --git a/cpp/demo/Ice/MFC/server/LogI.cpp b/cpp/demo/Ice/MFC/server/LogI.cpp index a8c18c4e2f5..2e153f952f7 100644 --- a/cpp/demo/Ice/MFC/server/LogI.cpp +++ b/cpp/demo/Ice/MFC/server/LogI.cpp @@ -66,7 +66,7 @@ LogI::message(const string& msg) string line = msg + "\r\n"; if(_hwnd) { - post(line); + post(line); } else { @@ -80,7 +80,7 @@ LogI::setHandle(HWND hwnd) _hwnd = hwnd; if(_hwnd != 0 && !_buffer.empty()) { - post(_buffer); + post(_buffer); _buffer.clear(); } } diff --git a/cpp/demo/Ice/MFC/server/stdafx.h b/cpp/demo/Ice/MFC/server/stdafx.h index 81d5a220522..6ad764438f9 100644 --- a/cpp/demo/Ice/MFC/server/stdafx.h +++ b/cpp/demo/Ice/MFC/server/stdafx.h @@ -22,30 +22,30 @@ #endif
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
-#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
+#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
-#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
-#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
-#endif
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
+#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#endif
#if 0
-#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
-#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
-#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
+#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
+#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
@@ -53,9 +53,9 @@ #include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
-#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
+#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <Ice/Ice.h>
diff --git a/cpp/demo/Ice/async/Client.cpp b/cpp/demo/Ice/async/Client.cpp index cb3e7e862c0..e164fb18cc3 100644 --- a/cpp/demo/Ice/async/Client.cpp +++ b/cpp/demo/Ice/async/Client.cpp @@ -54,8 +54,8 @@ AsyncClient::run(int argc, char* argv[]) HelloPrx hello = HelloPrx::checkedCast(communicator()->propertyToProxy("Hello.Proxy")); if(!hello) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } menu(); @@ -63,40 +63,40 @@ AsyncClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 'i') - { - hello->sayHello(0); - } - else if(c == 'd') - { - hello->sayHello_async(new AMI_Hello_sayHelloI, 5000); - } - else if(c == 's') - { - hello->shutdown(); - } - 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; - } + try + { + cout << "==> "; + cin >> c; + if(c == 'i') + { + hello->sayHello(0); + } + else if(c == 'd') + { + hello->sayHello_async(new AMI_Hello_sayHelloI, 5000); + } + else if(c == 's') + { + hello->shutdown(); + } + 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'); @@ -125,10 +125,10 @@ void AsyncClient::menu() { cout << - "usage:\n" - "i: send immediate greeting\n" - "d: send delayed greeting\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "i: send immediate greeting\n" + "d: send delayed greeting\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/async/WorkQueue.cpp b/cpp/demo/Ice/async/WorkQueue.cpp index 0493b8087ab..fc506938210 100644 --- a/cpp/demo/Ice/async/WorkQueue.cpp +++ b/cpp/demo/Ice/async/WorkQueue.cpp @@ -25,34 +25,34 @@ WorkQueue::run() while(!_done) { if(_callbacks.size() == 0) - { - _monitor.wait(); - } + { + _monitor.wait(); + } - if(_callbacks.size() != 0) - { - // - // Get next work item. - // - CallbackEntry entry = _callbacks.front(); + if(_callbacks.size() != 0) + { + // + // Get next work item. + // + CallbackEntry entry = _callbacks.front(); - // - // Wait for the amount of time indicated in delay to - // emulate a process that takes a significant period of - // time to complete. - // - _monitor.timedWait(IceUtil::Time::milliSeconds(entry.delay)); + // + // Wait for the amount of time indicated in delay to + // emulate a process that takes a significant period of + // time to complete. + // + _monitor.timedWait(IceUtil::Time::milliSeconds(entry.delay)); - if(!_done) - { - // - // Print greeting and send response. - // - _callbacks.pop_front(); - cout << "Belated Hello World!" << endl; - entry.cb->ice_response(); - } - } + if(!_done) + { + // + // Print greeting and send response. + // + _callbacks.pop_front(); + cout << "Belated Hello World!" << endl; + entry.cb->ice_response(); + } + } } // @@ -79,17 +79,17 @@ WorkQueue::add(const Demo::AMD_Hello_sayHelloPtr& cb, int delay) entry.cb = cb; entry.delay = delay; - if(_callbacks.size() == 0) - { + if(_callbacks.size() == 0) + { _monitor.notify(); - } + } _callbacks.push_back(entry); } else { // - // Destroyed, throw exception. - // + // Destroyed, throw exception. + // cb->ice_exception(Demo::RequestCanceledException()); } } diff --git a/cpp/demo/Ice/async/WorkQueue.h b/cpp/demo/Ice/async/WorkQueue.h index 9147b2f615d..47c3ebf04da 100644 --- a/cpp/demo/Ice/async/WorkQueue.h +++ b/cpp/demo/Ice/async/WorkQueue.h @@ -33,7 +33,7 @@ private: struct CallbackEntry { Demo::AMD_Hello_sayHelloPtr cb; - int delay; + int delay; }; IceUtil::Monitor<IceUtil::Mutex> _monitor; diff --git a/cpp/demo/Ice/bidir/CallbackI.cpp b/cpp/demo/Ice/bidir/CallbackI.cpp index 05c6e288d82..d24888c0dd3 100644 --- a/cpp/demo/Ice/bidir/CallbackI.cpp +++ b/cpp/demo/Ice/bidir/CallbackI.cpp @@ -28,15 +28,15 @@ CallbackSenderI::destroy() IceUtil::ThreadPtr callbackSenderThread; { - IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); - - cout << "destroying callback sender" << endl; - _destroy = true; - - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); + + cout << "destroying callback sender" << endl; + _destroy = true; + + notify(); - callbackSenderThread = _callbackSenderThread; - _callbackSenderThread = 0; // Resolve cyclic dependency. + callbackSenderThread = _callbackSenderThread; + _callbackSenderThread = 0; // Resolve cyclic dependency. } callbackSenderThread->getThreadControl().join(); @@ -66,27 +66,27 @@ CallbackSenderI::run() while(!_destroy) { - timedWait(IceUtil::Time::seconds(2)); + timedWait(IceUtil::Time::seconds(2)); - if(!_destroy && !_clients.empty()) - { - ++_num; - - set<CallbackReceiverPrx>::iterator p = _clients.begin(); - while(p != _clients.end()) - { - try - { - (*p)->callback(_num); - ++p; - } - catch(const Exception& ex) - { - cerr << "removing client `" << _communicator->identityToString((*p)->ice_getIdentity()) << "':\n" - << ex << endl; - _clients.erase(p++); - } - } - } + if(!_destroy && !_clients.empty()) + { + ++_num; + + set<CallbackReceiverPrx>::iterator p = _clients.begin(); + while(p != _clients.end()) + { + try + { + (*p)->callback(_num); + ++p; + } + catch(const Exception& ex) + { + cerr << "removing client `" << _communicator->identityToString((*p)->ice_getIdentity()) << "':\n" + << ex << endl; + _clients.erase(p++); + } + } + } } } diff --git a/cpp/demo/Ice/bidir/CallbackI.h b/cpp/demo/Ice/bidir/CallbackI.h index 2af7a28bce7..e99789bfa31 100644 --- a/cpp/demo/Ice/bidir/CallbackI.h +++ b/cpp/demo/Ice/bidir/CallbackI.h @@ -48,19 +48,19 @@ private: { public: - CallbackSenderThread(const CallbackSenderIPtr& callbackSender) : - _callbackSender(callbackSender) - { - } + CallbackSenderThread(const CallbackSenderIPtr& callbackSender) : + _callbackSender(callbackSender) + { + } - virtual void run() - { - _callbackSender->run(); - } + virtual void run() + { + _callbackSender->run(); + } private: - const CallbackSenderIPtr _callbackSender; + const CallbackSenderIPtr _callbackSender; }; IceUtil::ThreadPtr _callbackSenderThread; diff --git a/cpp/demo/Ice/bidir/Client.cpp b/cpp/demo/Ice/bidir/Client.cpp index a7e8198ab45..9dbd44ab388 100644 --- a/cpp/demo/Ice/bidir/Client.cpp +++ b/cpp/demo/Ice/bidir/Client.cpp @@ -21,7 +21,7 @@ public: virtual void callback(Ice::Int num, const Ice::Current&) { - cout << "received callback #" << num << endl; + cout << "received callback #" << num << endl; } }; @@ -46,8 +46,8 @@ CallbackClient::run(int argc, char* argv[]) CallbackSenderPrx::checkedCast(communicator()->propertyToProxy("Callback.Client.CallbackServer")); if(!server) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter(""); diff --git a/cpp/demo/Ice/bidir/Server.cpp b/cpp/demo/Ice/bidir/Server.cpp index a311635864c..170d12ad77d 100644 --- a/cpp/demo/Ice/bidir/Server.cpp +++ b/cpp/demo/Ice/bidir/Server.cpp @@ -38,12 +38,12 @@ CallbackServer::run(int argc, char* argv[]) sender->start(); try { - communicator()->waitForShutdown(); + communicator()->waitForShutdown(); } catch(...) { - sender->destroy(); - throw; + sender->destroy(); + throw; } sender->destroy(); diff --git a/cpp/demo/Ice/callback/CallbackSenderI.cpp b/cpp/demo/Ice/callback/CallbackSenderI.cpp index 302dbecdba4..f50c47e7a32 100644 --- a/cpp/demo/Ice/callback/CallbackSenderI.cpp +++ b/cpp/demo/Ice/callback/CallbackSenderI.cpp @@ -20,11 +20,11 @@ CallbackSenderI::initiateCallback(const CallbackReceiverPrx& proxy, const Curren cout << "initiating callback" << endl; try { - proxy->callback(current.ctx); + proxy->callback(current.ctx); } catch(const Exception& ex) { - cout << ex << endl; + cout << ex << endl; } } @@ -34,10 +34,10 @@ CallbackSenderI::shutdown(const Current& c) cout << "shutting down..." << endl; try { - c.adapter->getCommunicator()->shutdown(); + c.adapter->getCommunicator()->shutdown(); } catch(const Exception& ex) { - cout << ex << endl; + cout << ex << endl; } } diff --git a/cpp/demo/Ice/callback/Client.cpp b/cpp/demo/Ice/callback/Client.cpp index 83959a1e5fe..a68bed47b99 100644 --- a/cpp/demo/Ice/callback/Client.cpp +++ b/cpp/demo/Ice/callback/Client.cpp @@ -20,15 +20,15 @@ public: virtual void callback(const Ice::Current&) { #ifdef __xlC__ - // - // The xlC compiler synchronizes cin and cout; to see the messages - // while accepting input through cin, we have to print the messages - // with printf - // - printf("received callback\n"); - fflush(0); + // + // The xlC compiler synchronizes cin and cout; to see the messages + // while accepting input through cin, we have to print the messages + // with printf + // + printf("received callback\n"); + fflush(0); #else - cout << "received callback" << endl; + cout << "received callback" << endl; #endif } }; @@ -62,12 +62,12 @@ CallbackClient::run(int argc, char* argv[]) callbackOnInterrupt(); CallbackSenderPrx twoway = CallbackSenderPrx::checkedCast( - communicator()->propertyToProxy("Callback.Client.CallbackServer")-> - ice_twoway()->ice_timeout(-1)->ice_secure(false)); + communicator()->propertyToProxy("Callback.Client.CallbackServer")-> + ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } CallbackSenderPrx oneway = CallbackSenderPrx::uncheckedCast(twoway->ice_oneway()); CallbackSenderPrx batchOneway = CallbackSenderPrx::uncheckedCast(twoway->ice_batchOneway()); @@ -79,7 +79,7 @@ CallbackClient::run(int argc, char* argv[]) adapter->activate(); CallbackReceiverPrx twowayR = CallbackReceiverPrx::uncheckedCast( - adapter->createProxy(communicator()->stringToIdentity("callbackReceiver"))); + adapter->createProxy(communicator()->stringToIdentity("callbackReceiver"))); CallbackReceiverPrx onewayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_oneway()); CallbackReceiverPrx datagramR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_datagram()); @@ -91,24 +91,24 @@ CallbackClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - twoway->initiateCallback(twowayR); - } - else if(c == 'o') - { - oneway->initiateCallback(onewayR); - } - else if(c == 'O') - { - batchOneway->initiateCallback(onewayR); - } - else if(c == 'd') - { + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + twoway->initiateCallback(twowayR); + } + else if(c == 'o') + { + oneway->initiateCallback(onewayR); + } + else if(c == 'O') + { + batchOneway->initiateCallback(onewayR); + } + else if(c == 'd') + { if(secure) { cout << "secure datagrams are not supported" << endl; @@ -117,9 +117,9 @@ CallbackClient::run(int argc, char* argv[]) { datagram->initiateCallback(datagramR); } - } - else if(c == 'D') - { + } + else if(c == 'D') + { if(secure) { cout << "secure datagrams are not supported" << endl; @@ -128,57 +128,57 @@ CallbackClient::run(int argc, char* argv[]) { batchDatagram->initiateCallback(datagramR); } - } - else if(c == 'f') - { - communicator()->flushBatchRequests(); - } - else if(c == 'S') - { - secure = !secure; - secureStr = secure ? "s" : ""; - - twoway = CallbackSenderPrx::uncheckedCast(twoway->ice_secure(secure)); - oneway = CallbackSenderPrx::uncheckedCast(oneway->ice_secure(secure)); - batchOneway = CallbackSenderPrx::uncheckedCast(batchOneway->ice_secure(secure)); - datagram = CallbackSenderPrx::uncheckedCast(datagram->ice_secure(secure)); - batchDatagram = CallbackSenderPrx::uncheckedCast(batchDatagram->ice_secure(secure)); - - twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_secure(secure)); - onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_secure(secure)); - datagramR = CallbackReceiverPrx::uncheckedCast(datagramR->ice_secure(secure)); - - if(secure) - { - cout << "secure mode is now on" << endl; - } - else - { - cout << "secure mode is now off" << endl; - } - } - else if(c == 's') - { - twoway->shutdown(); - } - 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; - } + } + else if(c == 'f') + { + communicator()->flushBatchRequests(); + } + else if(c == 'S') + { + secure = !secure; + secureStr = secure ? "s" : ""; + + twoway = CallbackSenderPrx::uncheckedCast(twoway->ice_secure(secure)); + oneway = CallbackSenderPrx::uncheckedCast(oneway->ice_secure(secure)); + batchOneway = CallbackSenderPrx::uncheckedCast(batchOneway->ice_secure(secure)); + datagram = CallbackSenderPrx::uncheckedCast(datagram->ice_secure(secure)); + batchDatagram = CallbackSenderPrx::uncheckedCast(batchDatagram->ice_secure(secure)); + + twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_secure(secure)); + onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_secure(secure)); + datagramR = CallbackReceiverPrx::uncheckedCast(datagramR->ice_secure(secure)); + + if(secure) + { + cout << "secure mode is now on" << endl; + } + else + { + cout << "secure mode is now off" << endl; + } + } + else if(c == 's') + { + twoway->shutdown(); + } + 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'); @@ -190,15 +190,15 @@ CallbackClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -207,15 +207,15 @@ void CallbackClient::menu() { cout << - "usage:\n" - "t: send callback as twoway\n" - "o: send callback as oneway\n" - "O: send callback as batch oneway\n" - "d: send callback as datagram\n" - "D: send callback as batch datagram\n" - "f: flush all batch requests\n" - "S: switch secure mode on/off\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send callback as twoway\n" + "o: send callback as oneway\n" + "O: send callback as batch oneway\n" + "d: send callback as datagram\n" + "D: send callback as batch datagram\n" + "f: flush all batch requests\n" + "S: switch secure mode on/off\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/converter/Client.cpp b/cpp/demo/Ice/converter/Client.cpp index 123ad49dc52..3db03370c4f 100644 --- a/cpp/demo/Ice/converter/Client.cpp +++ b/cpp/demo/Ice/converter/Client.cpp @@ -19,12 +19,12 @@ void menu() { cout << - "usage:\n" - "t: send greeting with conversion\n" - "u: send greeting without conversion\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting with conversion\n" + "u: send greeting without conversion\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } int @@ -34,15 +34,15 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator1, const Ice EchoPrx echo1 = EchoPrx::checkedCast(communicator1->propertyToProxy(proxyProperty)); if(!echo1) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } EchoPrx echo2 = EchoPrx::checkedCast(communicator2->propertyToProxy(proxyProperty)); if(!echo2) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } menu(); @@ -52,42 +52,42 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator1, const Ice char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - string ret = echo1->echoString(greeting); - cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl; - } - else if(c == 'u') - { - string ret = echo2->echoString(greeting); - cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl; - } - else if(c == 's') - { - echo1->shutdown(); - } - 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; - } + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + string ret = echo1->echoString(greeting); + cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl; + } + else if(c == 'u') + { + string ret = echo2->echoString(greeting); + cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl; + } + else if(c == 's') + { + echo1->shutdown(); + } + 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'); @@ -104,18 +104,18 @@ main(int argc, char* argv[]) try { // - // Create two communicators, one with string converter configured - // and one without. - // + // Create two communicators, one with string converter configured + // and one without. + // Ice::InitializationData initData; initData.stringConverter = new StringConverterI(); - initData.properties = Ice::createProperties(initData.stringConverter); - initData.properties->load("config.client"); + initData.properties = Ice::createProperties(initData.stringConverter); + initData.properties->load("config.client"); communicator1 = Ice::initialize(argc, argv, initData); Ice::InitializationData initData2; - initData2.properties = Ice::createProperties(); - initData2.properties->load("config.client"); + initData2.properties = Ice::createProperties(); + initData2.properties->load("config.client"); communicator2 = Ice::initialize(argc, argv, initData2); status = run(argc, argv, communicator1, communicator2); diff --git a/cpp/demo/Ice/converter/StringConverterI.cpp b/cpp/demo/Ice/converter/StringConverterI.cpp index 0f6a7f3bd64..0da9ee6cdbb 100644 --- a/cpp/demo/Ice/converter/StringConverterI.cpp +++ b/cpp/demo/Ice/converter/StringConverterI.cpp @@ -34,32 +34,32 @@ Demo::StringConverterI::toUTF8(const char* sourceStart, const char* sourceEnd, I { unsigned char byte = sourceStart[i]; if(byte <= 0x7F) - { - if(outputBytesLeft == 0) - { - targetStart = buffer.getMoreBytes(chunkSize, targetStart + chunkSize); - offset = 0; - } + { + if(outputBytesLeft == 0) + { + targetStart = buffer.getMoreBytes(chunkSize, targetStart + chunkSize); + offset = 0; + } - targetStart[offset] = byte; + targetStart[offset] = byte; - ++offset; - --outputBytesLeft; - } - else - { - if(outputBytesLeft <= 1) - { - targetStart = buffer.getMoreBytes(chunkSize, targetStart + chunkSize - outputBytesLeft); - offset = 0; - } + ++offset; + --outputBytesLeft; + } + else + { + if(outputBytesLeft <= 1) + { + targetStart = buffer.getMoreBytes(chunkSize, targetStart + chunkSize - outputBytesLeft); + offset = 0; + } - targetStart[offset] = 0xC0 | ((byte & 0xC0) >> 6); - targetStart[offset + 1] = 0x80 | (byte & 0x3F); + targetStart[offset] = 0xC0 | ((byte & 0xC0) >> 6); + targetStart[offset + 1] = 0x80 | (byte & 0x3F); - offset += 2; - outputBytesLeft -= 2; - } + offset += 2; + outputBytesLeft -= 2; + } } return targetStart + offset; @@ -67,7 +67,7 @@ Demo::StringConverterI::toUTF8(const char* sourceStart, const char* sourceEnd, I void Demo::StringConverterI::fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* sourceEnd, - string& target) const + string& target) const { size_t inSize = static_cast<size_t>(sourceEnd - sourceStart); target.resize(inSize); @@ -77,21 +77,21 @@ Demo::StringConverterI::fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* while(i < inSize) { if((sourceStart[i] & 0xC0) == 0xC0) - { - if(i + 1 >= inSize) - { - throw Ice::StringConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted"); - } - target[targetIndex] = (sourceStart[i] & 0x03) << 6; - target[targetIndex] = target[targetIndex] | (sourceStart[i + 1] & 0x3F); - i += 2; - } - else - { - target[targetIndex] = sourceStart[i]; - ++i; - } - ++targetIndex; + { + if(i + 1 >= inSize) + { + throw Ice::StringConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted"); + } + target[targetIndex] = (sourceStart[i] & 0x03) << 6; + target[targetIndex] = target[targetIndex] | (sourceStart[i + 1] & 0x3F); + i += 2; + } + else + { + target[targetIndex] = sourceStart[i]; + ++i; + } + ++targetIndex; } target.resize(targetIndex); diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp index 801a8ebc337..50269cca8af 100644 --- a/cpp/demo/Ice/hello/Client.cpp +++ b/cpp/demo/Ice/hello/Client.cpp @@ -42,11 +42,11 @@ HelloClient::run(int argc, char* argv[]) callbackOnInterrupt(); HelloPrx twoway = HelloPrx::checkedCast( - communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false)); + communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } HelloPrx oneway = HelloPrx::uncheckedCast(twoway->ice_oneway()); HelloPrx batchOneway = HelloPrx::uncheckedCast(twoway->ice_batchOneway()); @@ -62,133 +62,133 @@ HelloClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - twoway->sayHello(delay); - } - else if(c == 'o') - { - oneway->sayHello(delay); - } - else if(c == 'O') - { - batchOneway->sayHello(delay); - } - else if(c == 'd') - { - if(secure) - { - cout << "secure datagrams are not supported" << endl; - } - else - { - datagram->sayHello(delay); - } - } - else if(c == 'D') - { - if(secure) - { - cout << "secure datagrams are not supported" << endl; - } - else - { - batchDatagram->sayHello(delay); - } - } - else if(c == 'f') - { - communicator()->flushBatchRequests(); - } - else if(c == 'T') - { - if(timeout == -1) - { - timeout = 2000; - } - else - { - timeout = -1; - } - - twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout)); - oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout)); - batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); - - if(timeout == -1) - { - cout << "timeout is now switched off" << endl; - } - else - { - cout << "timeout is now set to 2000ms" << endl; - } - } - else if(c == 'P') - { - if(delay == 0) - { - delay = 2500; - } - else - { - delay = 0; - } - - if(delay == 0) - { - cout << "server delay is now disabled" << endl; - } - else - { - cout << "server delay is now set to 2500ms" << endl; - } - } - else if(c == 'S') - { - secure = !secure; - - twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure)); - oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure)); - batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure)); - datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); - batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); - - if(secure) - { - cout << "secure mode is now on" << endl; - } - else - { - cout << "secure mode is now off" << endl; - } - } - else if(c == 's') - { - twoway->shutdown(); - } - 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; - } + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + twoway->sayHello(delay); + } + else if(c == 'o') + { + oneway->sayHello(delay); + } + else if(c == 'O') + { + batchOneway->sayHello(delay); + } + else if(c == 'd') + { + if(secure) + { + cout << "secure datagrams are not supported" << endl; + } + else + { + datagram->sayHello(delay); + } + } + else if(c == 'D') + { + if(secure) + { + cout << "secure datagrams are not supported" << endl; + } + else + { + batchDatagram->sayHello(delay); + } + } + else if(c == 'f') + { + communicator()->flushBatchRequests(); + } + else if(c == 'T') + { + if(timeout == -1) + { + timeout = 2000; + } + else + { + timeout = -1; + } + + twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout)); + oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout)); + batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); + + if(timeout == -1) + { + cout << "timeout is now switched off" << endl; + } + else + { + cout << "timeout is now set to 2000ms" << endl; + } + } + else if(c == 'P') + { + if(delay == 0) + { + delay = 2500; + } + else + { + delay = 0; + } + + if(delay == 0) + { + cout << "server delay is now disabled" << endl; + } + else + { + cout << "server delay is now set to 2500ms" << endl; + } + } + else if(c == 'S') + { + secure = !secure; + + twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure)); + oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure)); + batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure)); + datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); + batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); + + if(secure) + { + cout << "secure mode is now on" << endl; + } + else + { + cout << "secure mode is now off" << endl; + } + } + else if(c == 's') + { + twoway->shutdown(); + } + 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'); @@ -200,15 +200,15 @@ HelloClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -217,17 +217,17 @@ void HelloClient::menu() { cout << - "usage:\n" - "t: send greeting as twoway\n" - "o: send greeting as oneway\n" - "O: send greeting as batch oneway\n" - "d: send greeting as datagram\n" - "D: send greeting as batch datagram\n" - "f: flush all batch requests\n" - "T: set a timeout\n" - "P: set server delay\n" - "S: switch secure mode on/off\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting as twoway\n" + "o: send greeting as oneway\n" + "O: send greeting as batch oneway\n" + "d: send greeting as datagram\n" + "D: send greeting as batch datagram\n" + "f: flush all batch requests\n" + "T: set a timeout\n" + "P: set server delay\n" + "S: switch secure mode on/off\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/invoke/Client.cpp b/cpp/demo/Ice/invoke/Client.cpp index 3c0bb5bf8c6..e36fb965f31 100644 --- a/cpp/demo/Ice/invoke/Client.cpp +++ b/cpp/demo/Ice/invoke/Client.cpp @@ -304,15 +304,15 @@ InvokeClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Ice/latency/Client.cpp b/cpp/demo/Ice/latency/Client.cpp index 27347c49dd0..5f59ff10b17 100644 --- a/cpp/demo/Ice/latency/Client.cpp +++ b/cpp/demo/Ice/latency/Client.cpp @@ -34,8 +34,8 @@ LatencyClient::run(int argc, char* argv[]) PingPrx ping = PingPrx::checkedCast(base); if(!ping) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } // Initial ping to setup the connection. @@ -47,7 +47,7 @@ LatencyClient::run(int argc, char* argv[]) cout << "pinging server " << repetitions << " times (this may take a while)" << endl; for(int i = 0; i < repetitions; ++i) { - ping->ice_ping(); + ping->ice_ping(); } tm = IceUtil::Time::now() - tm; diff --git a/cpp/demo/Ice/minimal/Client.cpp b/cpp/demo/Ice/minimal/Client.cpp index 7009383bef6..583379642ef 100644 --- a/cpp/demo/Ice/minimal/Client.cpp +++ b/cpp/demo/Ice/minimal/Client.cpp @@ -21,35 +21,35 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - HelloPrx hello = HelloPrx::checkedCast(communicator->stringToProxy("hello:tcp -p 10000")); - if(!hello) - { - cerr << argv[0] << ": invalid proxy" << endl; - status = EXIT_FAILURE; - } - else - { - hello->sayHello(); - } + communicator = Ice::initialize(argc, argv); + HelloPrx hello = HelloPrx::checkedCast(communicator->stringToProxy("hello:tcp -p 10000")); + if(!hello) + { + cerr << argv[0] << ": invalid proxy" << endl; + status = EXIT_FAILURE; + } + else + { + hello->sayHello(); + } } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/demo/Ice/minimal/Server.cpp b/cpp/demo/Ice/minimal/Server.cpp index dc243ba9e49..6b2e4874689 100644 --- a/cpp/demo/Ice/minimal/Server.cpp +++ b/cpp/demo/Ice/minimal/Server.cpp @@ -20,29 +20,29 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "tcp -p 10000"); - adapter->add(new HelloI, communicator->stringToIdentity("hello")); - adapter->activate(); - communicator->waitForShutdown(); + communicator = Ice::initialize(argc, argv); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "tcp -p 10000"); + adapter->add(new HelloI, communicator->stringToIdentity("hello")); + adapter->activate(); + communicator->waitForShutdown(); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/demo/Ice/nested/Client.cpp b/cpp/demo/Ice/nested/Client.cpp index 12235c1d0ea..30c6edc42f2 100644 --- a/cpp/demo/Ice/nested/Client.cpp +++ b/cpp/demo/Ice/nested/Client.cpp @@ -41,8 +41,8 @@ NestedClient::run(int argc, char* argv[]) NestedPrx nested = NestedPrx::checkedCast(communicator()->propertyToProxy("Nested.Client.NestedServer")); if(!nested) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Nested.Client"); @@ -51,28 +51,28 @@ NestedClient::run(int argc, char* argv[]) adapter->activate(); cout << "Note: The maximum nesting level is sz * 2, with sz being\n" - << "the maximum number of threads in the server thread pool. if\n" - << "you specify a value higher than that, the application will\n" - << "block or timeout.\n" - << endl; + << "the maximum number of threads in the server thread pool. if\n" + << "you specify a value higher than that, the application will\n" + << "block or timeout.\n" + << endl; string s; do { - try - { - cout << "enter nesting level or 'x' for exit: "; - cin >> s; - int level = atoi(s.c_str()); - if(level > 0) - { - nested->nestedCall(level, self); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + cout << "enter nesting level or 'x' for exit: "; + cin >> s; + int level = atoi(s.c_str()); + if(level > 0) + { + nested->nestedCall(level, self); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && s != "x"); @@ -89,15 +89,15 @@ NestedClient::interruptCallback(int) * try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } */ exit(EXIT_SUCCESS); diff --git a/cpp/demo/Ice/nested/NestedI.cpp b/cpp/demo/Ice/nested/NestedI.cpp index 133e34b896a..bb129b6dcdf 100644 --- a/cpp/demo/Ice/nested/NestedI.cpp +++ b/cpp/demo/Ice/nested/NestedI.cpp @@ -25,6 +25,6 @@ NestedI::nestedCall(Int level, const NestedPrx& proxy, const Ice::Current& curre cout << level << endl; if(--level > 0) { - proxy->nestedCall(level, _self, current.ctx); + proxy->nestedCall(level, _self, current.ctx); } } diff --git a/cpp/demo/Ice/session/Client.cpp b/cpp/demo/Ice/session/Client.cpp index 28a0393a1bd..89b05b09c1d 100755 --- a/cpp/demo/Ice/session/Client.cpp +++ b/cpp/demo/Ice/session/Client.cpp @@ -19,42 +19,42 @@ class SessionRefreshThread : public IceUtil::Thread, public IceUtil::Monitor<Ice public: SessionRefreshThread(const Ice::LoggerPtr& logger, const IceUtil::Time& timeout, const SessionPrx& session) : - _logger(logger), - _session(session), - _timeout(timeout), - _terminated(false) + _logger(logger), + _session(session), + _timeout(timeout), + _terminated(false) { } virtual void run() { - Lock sync(*this); - while(!_terminated) - { - timedWait(_timeout); - if(!_terminated) - { - try - { - _session->refresh(); - } - catch(const Ice::Exception& ex) - { - Ice::Warning warn(_logger); - warn << "SessionRefreshThread: " << ex; - _terminated = true; - } - } - } + Lock sync(*this); + while(!_terminated) + { + timedWait(_timeout); + if(!_terminated) + { + try + { + _session->refresh(); + } + catch(const Ice::Exception& ex) + { + Ice::Warning warn(_logger); + warn << "SessionRefreshThread: " << ex; + _terminated = true; + } + } + } } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + Lock sync(*this); + _terminated = true; + notify(); } private: @@ -109,24 +109,24 @@ SessionClient::run(int argc, char* argv[]) cin >> name; if(!cin.good()) { - return EXIT_FAILURE; + return EXIT_FAILURE; } Ice::ObjectPrx base = communicator()->propertyToProxy("SessionFactory.Proxy"); SessionFactoryPrx factory = SessionFactoryPrx::checkedCast(base); if(!factory) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } { - IceUtil::Mutex::Lock sync(_mutex); - _session = factory->create(name); - - _refresh = new SessionRefreshThread( - communicator()->getLogger(), IceUtil::Time::seconds(5), _session); - _refresh->start(); + IceUtil::Mutex::Lock sync(_mutex); + _session = factory->create(name); + + _refresh = new SessionRefreshThread( + communicator()->getLogger(), IceUtil::Time::seconds(5), _session); + _refresh->start(); } vector<HelloPrx> hellos; @@ -135,85 +135,85 @@ SessionClient::run(int argc, char* argv[]) try { - bool destroy = true; - bool shutdown = false; - while(true) - { - cout << "==> "; - char c; - cin >> c; - if(!cin.good()) - { - break; - } - if(isdigit(c)) - { - string s; - s += c; - vector<HelloPrx>::size_type index = atoi(s.c_str()); - if(index < hellos.size()) - { - hellos[index]->sayHello(); - } - else - { - cout << "Index is too high. " << hellos.size() << " hello objects exist so far.\n" - << "Use `c' to create a new hello object." << endl; - } - } - else if(c == 'c') - { - hellos.push_back(_session->createHello()); - cout << "Created hello object " << hellos.size() - 1 << endl; - } - else if(c == 's') - { - destroy = false; - shutdown = true; - break; - } - else if(c == 'x') - { - break; - } - else if(c == 't') - { - destroy = false; - break; - } - else if(c == '?') - { - menu(); - } - else - { - cout << "Unknown command `" << c << "'." << endl; - menu(); - } - } + bool destroy = true; + bool shutdown = false; + while(true) + { + cout << "==> "; + char c; + cin >> c; + if(!cin.good()) + { + break; + } + if(isdigit(c)) + { + string s; + s += c; + vector<HelloPrx>::size_type index = atoi(s.c_str()); + if(index < hellos.size()) + { + hellos[index]->sayHello(); + } + else + { + cout << "Index is too high. " << hellos.size() << " hello objects exist so far.\n" + << "Use `c' to create a new hello object." << endl; + } + } + else if(c == 'c') + { + hellos.push_back(_session->createHello()); + cout << "Created hello object " << hellos.size() - 1 << endl; + } + else if(c == 's') + { + destroy = false; + shutdown = true; + break; + } + else if(c == 'x') + { + break; + } + else if(c == 't') + { + destroy = false; + break; + } + else if(c == '?') + { + menu(); + } + else + { + cout << "Unknown command `" << c << "'." << endl; + menu(); + } + } - // - // The refresher thread must be terminated before destroy is - // called, otherwise it might get ObjectNotExistException. refresh - // is set to 0 so that if session->destroy() raises an exception - // the thread will not be re-terminated and re-joined. - // - cleanup(destroy); - if(shutdown) - { - factory->shutdown(); - } + // + // The refresher thread must be terminated before destroy is + // called, otherwise it might get ObjectNotExistException. refresh + // is set to 0 so that if session->destroy() raises an exception + // the thread will not be re-terminated and re-joined. + // + cleanup(destroy); + if(shutdown) + { + factory->shutdown(); + } } catch(...) { - try - { - cleanup(true); - } - catch(...) - { - } - throw; + try + { + cleanup(true); + } + catch(...) + { + } + throw; } return EXIT_SUCCESS; @@ -232,15 +232,15 @@ SessionClient::interruptCallback(int) try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -251,15 +251,15 @@ SessionClient::cleanup(bool destroy) IceUtil::Mutex::Lock sync(_mutex); if(_refresh) { - _refresh->terminate(); - _refresh->getThreadControl().join(); - _refresh = 0; + _refresh->terminate(); + _refresh->getThreadControl().join(); + _refresh = 0; } if(destroy && _session) { - _session->destroy(); - _session = 0; + _session->destroy(); + _session = 0; } } @@ -267,11 +267,11 @@ void SessionClient::menu() { cout << - "usage:\n" - "c: create a new per-client hello object\n" - "0-9: send a greeting to a hello object\n" - "s: shutdown the server and exit\n" - "x: exit\n" - "t: exit without destroying the session\n" - "?: help\n"; + "usage:\n" + "c: create a new per-client hello object\n" + "0-9: send a greeting to a hello object\n" + "s: shutdown the server and exit\n" + "x: exit\n" + "t: exit without destroying the session\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/session/ReapThread.cpp b/cpp/demo/Ice/session/ReapThread.cpp index 26d25ff506a..7257bd0994c 100755 --- a/cpp/demo/Ice/session/ReapThread.cpp +++ b/cpp/demo/Ice/session/ReapThread.cpp @@ -25,38 +25,38 @@ ReapThread::run() while(!_terminated) { - timedWait(_timeout); + timedWait(_timeout); - if(!_terminated) - { - list<SessionProxyPair>::iterator p = _sessions.begin(); - while(p != _sessions.end()) - { - try - { - // - // Session destruction may take time in a - // real-world example. Therefore the current time - // is computed for each iteration. - // - if((IceUtil::Time::now() - p->session->timestamp()) > _timeout) - { - string name = p->proxy->getName(); - p->proxy->destroy(); - cout << "The session " << name << " has timed out." << endl; - p = _sessions.erase(p); - } - else - { - ++p; - } - } - catch(const Ice::ObjectNotExistException&) - { - p = _sessions.erase(p); - } - } - } + if(!_terminated) + { + list<SessionProxyPair>::iterator p = _sessions.begin(); + while(p != _sessions.end()) + { + try + { + // + // Session destruction may take time in a + // real-world example. Therefore the current time + // is computed for each iteration. + // + if((IceUtil::Time::now() - p->session->timestamp()) > _timeout) + { + string name = p->proxy->getName(); + p->proxy->destroy(); + cout << "The session " << name << " has timed out." << endl; + p = _sessions.erase(p); + } + else + { + ++p; + } + } + catch(const Ice::ObjectNotExistException&) + { + p = _sessions.erase(p); + } + } + } } } diff --git a/cpp/demo/Ice/session/ReapThread.h b/cpp/demo/Ice/session/ReapThread.h index b7fc1434cf0..f96cf25036a 100755 --- a/cpp/demo/Ice/session/ReapThread.h +++ b/cpp/demo/Ice/session/ReapThread.h @@ -30,10 +30,10 @@ private: bool _terminated; struct SessionProxyPair { - SessionProxyPair(const Demo::SessionPrx& p, const SessionIPtr& s) : - proxy(p), session(s) { } - const Demo::SessionPrx proxy; - const SessionIPtr session; + SessionProxyPair(const Demo::SessionPrx& p, const SessionIPtr& s) : + proxy(p), session(s) { } + const Demo::SessionPrx proxy; + const SessionIPtr session; }; std::list<SessionProxyPair> _sessions; }; diff --git a/cpp/demo/Ice/session/SessionI.cpp b/cpp/demo/Ice/session/SessionI.cpp index d458b4117e4..a0e70e24168 100755 --- a/cpp/demo/Ice/session/SessionI.cpp +++ b/cpp/demo/Ice/session/SessionI.cpp @@ -17,21 +17,21 @@ class HelloI : public Hello public: HelloI(const string& name, int id) : - _name(name), - _id(id) + _name(name), + _id(id) { } virtual ~HelloI() { - cout << "Hello object #" << _id << " for session `" << _name << "' destroyed" << endl; + cout << "Hello object #" << _id << " for session `" << _name << "' destroyed" << endl; } void sayHello(const Ice::Current&) const { - cout << "Hello object #" << _id << " for session `" << _name << "' says:\n" - << "Hello " << _name << "!" << endl; + cout << "Hello object #" << _id << " for session `" << _name << "' says:\n" + << "Hello " << _name << "!" << endl; } private: @@ -55,7 +55,7 @@ SessionI::createHello(const Ice::Current& c) Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } HelloPrx hello = HelloPrx::uncheckedCast(c.adapter->addWithUUID(new HelloI(_name, _nextId++))); @@ -69,7 +69,7 @@ SessionI::refresh(const Ice::Current& c) Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } _timestamp = IceUtil::Time::now(); @@ -81,7 +81,7 @@ SessionI::getName(const Ice::Current&) const Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } return _name; @@ -93,7 +93,7 @@ SessionI::destroy(const Ice::Current& c) Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } _destroy = true; @@ -101,16 +101,16 @@ SessionI::destroy(const Ice::Current& c) cout << "The session " << _name << " is now destroyed." << endl; try { - c.adapter->remove(c.id); - for(list<HelloPrx>::const_iterator p = _objs.begin(); p != _objs.end(); ++p) - { - c.adapter->remove((*p)->ice_getIdentity()); - } + c.adapter->remove(c.id); + for(list<HelloPrx>::const_iterator p = _objs.begin(); p != _objs.end(); ++p) + { + c.adapter->remove((*p)->ice_getIdentity()); + } } catch(const Ice::ObjectAdapterDeactivatedException&) { - // This method is called on shutdown of the server, in which - // case this exception is expected. + // This method is called on shutdown of the server, in which + // case this exception is expected. } _objs.clear(); @@ -122,7 +122,7 @@ SessionI::timestamp() const Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } return _timestamp; } diff --git a/cpp/demo/Ice/throughput/Client.cpp b/cpp/demo/Ice/throughput/Client.cpp index d019e951a19..112eb317177 100644 --- a/cpp/demo/Ice/throughput/Client.cpp +++ b/cpp/demo/Ice/throughput/Client.cpp @@ -47,8 +47,8 @@ ThroughputClient::run(int argc, char* argv[]) ThroughputPrx throughput = ThroughputPrx::checkedCast(base); if(!throughput) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } ThroughputPrx throughputOneway = ThroughputPrx::uncheckedCast(throughput->ice_oneway()); @@ -64,7 +64,7 @@ ThroughputClient::run(int argc, char* argv[]) for(i = 0; i < StringDoubleSeqSize; ++i) { structSeq[i].s = "hello"; - structSeq[i].d = 3.14; + structSeq[i].d = 3.14; } FixedSeq fixedSeq(FixedSeqSize); @@ -88,296 +88,296 @@ ThroughputClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - - IceUtil::Time tm = IceUtil::Time::now(); - const int repetitions = 1000; - - if(c == '1' || c == '2' || c == '3' || c == '4') - { - currentType = c; - switch(c) - { - case '1': - { - cout << "using byte sequences" << endl; - seqSize = ByteSeqSize; - break; - } - - case '2': - { - cout << "using string sequences" << endl; - seqSize = StringSeqSize; - break; - } - - case '3': - { - cout << "using variable-length struct sequences" << endl; - seqSize = StringDoubleSeqSize; - break; - } - - case '4': - { - cout << "using fixed-length struct sequences" << endl; - seqSize = FixedSeqSize; - break; - } - } - } - else if(c == 't' || c == 'o' || c == 'r' || c == 'e') - { - switch(c) - { - case 't': - case 'o': - { - cout << "sending"; - break; - } - - case 'r': - { - cout << "receiving"; - break; - } - - case 'e': - { - cout << "sending and receiving"; - break; - } - } - - cout << ' ' << repetitions; - switch(currentType) - { - case '1': - { - cout << " byte"; - break; - } - - case '2': - { - cout << " string"; - break; - } - - case '3': - { - cout << " variable-length struct"; - break; - } - - case '4': - { - cout << " fixed-length struct"; - break; - } - } - cout << " sequences of size " << seqSize; - - - if(c == 'o') - { - cout << " as oneway"; - } - - cout << "..." << endl; - - for(int i = 0; i < repetitions; ++i) - { - switch(currentType) - { - case '1': - { - switch(c) - { - case 't': - { - throughput->sendByteSeq(byteArr); - break; - } - - case 'o': - { - throughputOneway->sendByteSeq(byteArr); - break; - } - - case 'r': - { - throughput->recvByteSeq(); - break; - } - - case 'e': - { - throughput->echoByteSeq(byteSeq); - break; - } - } - break; - } - - case '2': - { - switch(c) - { - case 't': - { - throughput->sendStringSeq(stringSeq); - break; - } - - case 'o': - { - throughputOneway->sendStringSeq(stringSeq); - break; - } - - case 'r': - { - throughput->recvStringSeq(); - break; - } - - case 'e': - { - throughput->echoStringSeq(stringSeq); - break; - } - } - break; - } - - case '3': - { - switch(c) - { - case 't': - { - throughput->sendStructSeq(structSeq); - break; - } - - case 'o': - { - throughputOneway->sendStructSeq(structSeq); - break; - } - - case 'r': - { - throughput->recvStructSeq(); - break; - } - - case 'e': - { - throughput->echoStructSeq(structSeq); - break; - } - } - break; - } - - case '4': - { - switch(c) - { - case 't': - { - throughput->sendFixedSeq(fixedSeq); - break; - } - - case 'o': - { - throughputOneway->sendFixedSeq(fixedSeq); - break; - } - - case 'r': - { - throughput->recvFixedSeq(); - break; - } - - case 'e': - { - throughput->echoFixedSeq(fixedSeq); - break; - } - } - break; - } - } - } - - tm = IceUtil::Time::now() - tm; - cout << "time for " << repetitions << " sequences: " << tm * 1000 << "ms" << endl; - cout << "time per sequence: " << tm * 1000 / repetitions << "ms" << endl; - int wireSize = 0; - switch(currentType) - { - case '1': - { - wireSize = 1; - break; - } - case '2': - { - wireSize = static_cast<int>(stringSeq[0].size()); - break; - } - case '3': - { - wireSize = static_cast<int>(structSeq[0].s.size()); - wireSize += 8; // Size of double on the wire. - break; - } - case '4': - { - wireSize = 16; // Size of two ints and a double on the wire. - break; - } - } - double mbit = repetitions * seqSize * wireSize * 8.0 / tm.toMicroSeconds(); - if(c == 'e') - { - mbit *= 2; - } - cout << "throughput: " << setprecision(5) << mbit << "Mbps" << endl; - } - else if(c == 's') - { - throughput->shutdown(); - } - 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; - } + try + { + cout << "==> "; + cin >> c; + + IceUtil::Time tm = IceUtil::Time::now(); + const int repetitions = 1000; + + if(c == '1' || c == '2' || c == '3' || c == '4') + { + currentType = c; + switch(c) + { + case '1': + { + cout << "using byte sequences" << endl; + seqSize = ByteSeqSize; + break; + } + + case '2': + { + cout << "using string sequences" << endl; + seqSize = StringSeqSize; + break; + } + + case '3': + { + cout << "using variable-length struct sequences" << endl; + seqSize = StringDoubleSeqSize; + break; + } + + case '4': + { + cout << "using fixed-length struct sequences" << endl; + seqSize = FixedSeqSize; + break; + } + } + } + else if(c == 't' || c == 'o' || c == 'r' || c == 'e') + { + switch(c) + { + case 't': + case 'o': + { + cout << "sending"; + break; + } + + case 'r': + { + cout << "receiving"; + break; + } + + case 'e': + { + cout << "sending and receiving"; + break; + } + } + + cout << ' ' << repetitions; + switch(currentType) + { + case '1': + { + cout << " byte"; + break; + } + + case '2': + { + cout << " string"; + break; + } + + case '3': + { + cout << " variable-length struct"; + break; + } + + case '4': + { + cout << " fixed-length struct"; + break; + } + } + cout << " sequences of size " << seqSize; + + + if(c == 'o') + { + cout << " as oneway"; + } + + cout << "..." << endl; + + for(int i = 0; i < repetitions; ++i) + { + switch(currentType) + { + case '1': + { + switch(c) + { + case 't': + { + throughput->sendByteSeq(byteArr); + break; + } + + case 'o': + { + throughputOneway->sendByteSeq(byteArr); + break; + } + + case 'r': + { + throughput->recvByteSeq(); + break; + } + + case 'e': + { + throughput->echoByteSeq(byteSeq); + break; + } + } + break; + } + + case '2': + { + switch(c) + { + case 't': + { + throughput->sendStringSeq(stringSeq); + break; + } + + case 'o': + { + throughputOneway->sendStringSeq(stringSeq); + break; + } + + case 'r': + { + throughput->recvStringSeq(); + break; + } + + case 'e': + { + throughput->echoStringSeq(stringSeq); + break; + } + } + break; + } + + case '3': + { + switch(c) + { + case 't': + { + throughput->sendStructSeq(structSeq); + break; + } + + case 'o': + { + throughputOneway->sendStructSeq(structSeq); + break; + } + + case 'r': + { + throughput->recvStructSeq(); + break; + } + + case 'e': + { + throughput->echoStructSeq(structSeq); + break; + } + } + break; + } + + case '4': + { + switch(c) + { + case 't': + { + throughput->sendFixedSeq(fixedSeq); + break; + } + + case 'o': + { + throughputOneway->sendFixedSeq(fixedSeq); + break; + } + + case 'r': + { + throughput->recvFixedSeq(); + break; + } + + case 'e': + { + throughput->echoFixedSeq(fixedSeq); + break; + } + } + break; + } + } + } + + tm = IceUtil::Time::now() - tm; + cout << "time for " << repetitions << " sequences: " << tm * 1000 << "ms" << endl; + cout << "time per sequence: " << tm * 1000 / repetitions << "ms" << endl; + int wireSize = 0; + switch(currentType) + { + case '1': + { + wireSize = 1; + break; + } + case '2': + { + wireSize = static_cast<int>(stringSeq[0].size()); + break; + } + case '3': + { + wireSize = static_cast<int>(structSeq[0].s.size()); + wireSize += 8; // Size of double on the wire. + break; + } + case '4': + { + wireSize = 16; // Size of two ints and a double on the wire. + break; + } + } + double mbit = repetitions * seqSize * wireSize * 8.0 / tm.toMicroSeconds(); + if(c == 'e') + { + mbit *= 2; + } + cout << "throughput: " << setprecision(5) << mbit << "Mbps" << endl; + } + else if(c == 's') + { + throughput->shutdown(); + } + 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'); @@ -389,15 +389,15 @@ ThroughputClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -406,22 +406,22 @@ void ThroughputClient::menu() { cout << - "usage:\n" - "\n" - "toggle type of data to send:\n" - "1: sequence of bytes (default)\n" - "2: sequence of strings (\"hello\")\n" - "3: sequence of structs with a string (\"hello\") and a double\n" - "4: sequence of structs with two ints and a double\n" - "\n" - "select test to run:\n" - "t: Send sequence as twoway\n" - "o: Send sequence as oneway\n" - "r: Receive sequence\n" - "e: Echo (send and receive) sequence\n" - "\n" - "other commands:\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "\n" + "toggle type of data to send:\n" + "1: sequence of bytes (default)\n" + "2: sequence of strings (\"hello\")\n" + "3: sequence of structs with a string (\"hello\") and a double\n" + "4: sequence of structs with two ints and a double\n" + "\n" + "select test to run:\n" + "t: Send sequence as twoway\n" + "o: Send sequence as oneway\n" + "r: Receive sequence\n" + "e: Echo (send and receive) sequence\n" + "\n" + "other commands:\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/throughput/ThroughputI.cpp b/cpp/demo/Ice/throughput/ThroughputI.cpp index 68114a2b7bf..beb61966b0b 100644 --- a/cpp/demo/Ice/throughput/ThroughputI.cpp +++ b/cpp/demo/Ice/throughput/ThroughputI.cpp @@ -20,14 +20,14 @@ ThroughputI::ThroughputI() : int i; for(i = 0; i < Demo::StringDoubleSeqSize; ++i) { - _structSeq[i].s = "hello"; - _structSeq[i].d = 3.14; + _structSeq[i].s = "hello"; + _structSeq[i].d = 3.14; } for(i = 0; i < Demo::FixedSeqSize; ++i) { - _fixedSeq[i].i = 0; - _fixedSeq[i].j = 0; - _fixedSeq[i].d = 0; + _fixedSeq[i].i = 0; + _fixedSeq[i].j = 0; + _fixedSeq[i].d = 0; } } diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index b072355b87f..e37a48aa349 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -42,47 +42,47 @@ ValueClient::run(int argc, char* argv[]) InitialPrx initial = InitialPrx::checkedCast(base); if(!initial) { - cerr << argv[0] << ": invalid object reference" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid object reference" << endl; + return EXIT_FAILURE; } char c[2]; cout << '\n' - << "Let's first transfer a simple object, for a class without\n" - << "operations, and print its contents. No factory is required\n" - << "for this.\n" - << "[press enter]\n"; + << "Let's first transfer a simple object, for a class without\n" + << "operations, and print its contents. No factory is required\n" + << "for this.\n" + << "[press enter]\n"; cin.getline(c, 2); SimplePtr simple = initial->getSimple(); cout << "==> " << simple->message << endl; cout << '\n' - << "Yes, this worked. Now let's try to transfer an object for a class\n" - << "with operations as type ::Demo::Printer, without installing a factory first.\n" - << "This should give us a `no factory' exception.\n" - << "[press enter]\n"; + << "Yes, this worked. Now let's try to transfer an object for a class\n" + << "with operations as type ::Demo::Printer, without installing a factory first.\n" + << "This should give us a `no factory' exception.\n" + << "[press enter]\n"; cin.getline(c, 2); PrinterPtr printer; PrinterPrx printerProxy; try { - initial->getPrinter(printer, printerProxy); - cerr << argv[0] << "Did not get the expected NoObjectFactoryException!" << endl; - exit(EXIT_FAILURE); + initial->getPrinter(printer, printerProxy); + cerr << argv[0] << "Did not get the expected NoObjectFactoryException!" << endl; + exit(EXIT_FAILURE); } catch(const Ice::NoObjectFactoryException& ex) { - cout << "==> " << ex << endl; + cout << "==> " << ex << endl; } cout << '\n' - << "Yep, that's what we expected. Now let's try again, but with\n" - << "installing an appropriate factory first. If successful, we print\n" - << "the object's content.\n" - << "[press enter]\n"; + << "Yep, that's what we expected. Now let's try again, but with\n" + << "installing an appropriate factory first. If successful, we print\n" + << "the object's content.\n" + << "[press enter]\n"; cin.getline(c, 2); Ice::ObjectFactoryPtr factory = new ObjectFactory; @@ -92,28 +92,28 @@ ValueClient::run(int argc, char* argv[]) cout << "==> " << printer->message << endl; cout << '\n' - << "Cool, it worked! Let's try calling the printBackwards() method\n" - << "on the object we just received locally.\n" - << "[press enter]\n"; + << "Cool, it worked! Let's try calling the printBackwards() method\n" + << "on the object we just received locally.\n" + << "[press enter]\n"; cin.getline(c, 2); cout << "==> "; printer->printBackwards(); cout << '\n' - << "Now we call the same method, but on the remote object. Watch the\n" - << "server's output.\n" - << "[press enter]\n"; + << "Now we call the same method, but on the remote object. Watch the\n" + << "server's output.\n" + << "[press enter]\n"; cin.getline(c, 2); printerProxy->printBackwards(); cout << '\n' - << "Next, we transfer a derived object from the server as a base\n" - << "object. Since we haven't yet installed a factory for the derived\n" - << "class, the derived class (::Demo::DerivedPrinter) is sliced\n" - << "to its base class (::Demo::Printer).\n" - << "[press enter]\n"; + << "Next, we transfer a derived object from the server as a base\n" + << "object. Since we haven't yet installed a factory for the derived\n" + << "class, the derived class (::Demo::DerivedPrinter) is sliced\n" + << "to its base class (::Demo::Printer).\n" + << "[press enter]\n"; cin.getline(c, 2); PrinterPtr derivedAsBase; @@ -122,10 +122,10 @@ ValueClient::run(int argc, char* argv[]) assert(derivedAsBase->ice_id() == "::Demo::Printer"); cout << '\n' - << "Now we install a factory for the derived class, and try again.\n" - << "Because we receive the derived object as a base object, we\n" - << "we need to do a dynamic_cast<> to get from the base to the derived object.\n" - << "[press enter]\n"; + << "Now we install a factory for the derived class, and try again.\n" + << "Because we receive the derived object as a base object, we\n" + << "we need to do a dynamic_cast<> to get from the base to the derived object.\n" + << "[press enter]\n"; cin.getline(c, 2); communicator()->addObjectFactory(factory, "::Demo::DerivedPrinter"); @@ -137,10 +137,10 @@ ValueClient::run(int argc, char* argv[]) cout << "==> The type ID of the received object is \"" << derived->ice_id() << "\"" << endl; cout << '\n' - << "Let's print the message contained in the derived object, and\n" - << "call the operation printUppercase() on the derived object\n" - << "locally.\n" - << "[press enter]\n"; + << "Let's print the message contained in the derived object, and\n" + << "call the operation printUppercase() on the derived object\n" + << "locally.\n" + << "[press enter]\n"; cin.getline(c, 2); cout << "==> " << derived->derivedMessage << endl; @@ -148,26 +148,26 @@ ValueClient::run(int argc, char* argv[]) derived->printUppercase(); cout << '\n' - << "Finally, we try the same again, but instead of returning the\n" - << "derived object, we throw an exception containing the derived\n" - << "object.\n" - << "[press enter]\n"; + << "Finally, we try the same again, but instead of returning the\n" + << "derived object, we throw an exception containing the derived\n" + << "object.\n" + << "[press enter]\n"; cin.getline(c, 2); try { - initial->throwDerivedPrinter(); - cerr << argv[0] << ": Did not get the expected DerivedPrinterException!" << endl; - exit(EXIT_FAILURE); + initial->throwDerivedPrinter(); + cerr << argv[0] << ": Did not get the expected DerivedPrinterException!" << endl; + exit(EXIT_FAILURE); } catch(const DerivedPrinterException& ex) { - derived = ex.derived; - if(!derived) - { - cerr << argv[0] << "Unexpected null pointer for `derived'" << endl; - exit(EXIT_FAILURE); - } + derived = ex.derived; + if(!derived) + { + cerr << argv[0] << "Unexpected null pointer for `derived'" << endl; + exit(EXIT_FAILURE); + } } cout << "==> " << derived->derivedMessage << endl; @@ -175,7 +175,7 @@ ValueClient::run(int argc, char* argv[]) derived->printUppercase(); cout << '\n' - << "That's it for this demo. Have fun with Ice!\n"; + << "That's it for this demo. Have fun with Ice!\n"; initial->shutdown(); @@ -187,15 +187,15 @@ ValueClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Ice/value/ObjectFactory.cpp b/cpp/demo/Ice/value/ObjectFactory.cpp index 2156f97448f..8c1ae1a5868 100644 --- a/cpp/demo/Ice/value/ObjectFactory.cpp +++ b/cpp/demo/Ice/value/ObjectFactory.cpp @@ -18,12 +18,12 @@ ObjectFactory::create(const string& type) { if(type == "::Demo::Printer") { - return new PrinterI; + return new PrinterI; } if(type == "::Demo::DerivedPrinter") { - return new DerivedPrinterI; + return new DerivedPrinterI; } assert(false); |