diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2009-01-02 15:16:46 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2009-01-02 15:16:46 -0330 |
commit | 51ee7620f82e4232baf587ee052001751c23e481 (patch) | |
tree | 08baaf92bddeca3f33acfe1bb38620606de7a99b /cpp/demo | |
parent | The server now accepts anonymous clients. (diff) | |
download | ice-51ee7620f82e4232baf587ee052001751c23e481.tar.bz2 ice-51ee7620f82e4232baf587ee052001751c23e481.tar.xz ice-51ee7620f82e4232baf587ee052001751c23e481.zip |
Merged with R3_3_branch
Diffstat (limited to 'cpp/demo')
-rw-r--r-- | cpp/demo/Ice/MFC/client/Hello.ice | 4 | ||||
-rw-r--r-- | cpp/demo/Ice/MFC/client/HelloClient.cpp | 11 | ||||
-rw-r--r-- | cpp/demo/Ice/MFC/client/HelloClient.rc | 62 | ||||
-rw-r--r-- | cpp/demo/Ice/MFC/client/HelloClientDlg.cpp | 255 | ||||
-rw-r--r-- | cpp/demo/Ice/MFC/client/HelloClientDlg.h | 11 | ||||
-rw-r--r-- | cpp/demo/Ice/MFC/client/Resource.h | 7 | ||||
-rw-r--r-- | cpp/demo/Ice/MFC/client/config | 6 | ||||
-rw-r--r-- | cpp/demo/Ice/Makefile | 3 | ||||
-rw-r--r-- | cpp/demo/Ice/Makefile.mak | 3 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/.depend | 5 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/.gitignore | 7 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/Client.cpp | 141 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/Makefile | 42 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/Makefile.mak | 50 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/MyStringSeq.h | 32 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/Nrvo.ice | 30 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/NrvoI.cpp | 54 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/NrvoI.h | 31 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/README | 41 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/Server.cpp | 44 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/config.client | 20 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/config.server | 20 | ||||
-rw-r--r-- | cpp/demo/Ice/nrvo/expect.py | 30 |
23 files changed, 827 insertions, 82 deletions
diff --git a/cpp/demo/Ice/MFC/client/Hello.ice b/cpp/demo/Ice/MFC/client/Hello.ice index 11b714f01c8..a21b43ace2c 100644 --- a/cpp/demo/Ice/MFC/client/Hello.ice +++ b/cpp/demo/Ice/MFC/client/Hello.ice @@ -15,8 +15,8 @@ module Demo interface Hello { - ["cpp:const"] idempotent void sayHello(int delay); - void shutdown(); + ["ami", "cpp:const"] idempotent void sayHello(int delay); + ["ami"] void shutdown(); }; }; diff --git a/cpp/demo/Ice/MFC/client/HelloClient.cpp b/cpp/demo/Ice/MFC/client/HelloClient.cpp index 58deb943950..767bd89f646 100644 --- a/cpp/demo/Ice/MFC/client/HelloClient.cpp +++ b/cpp/demo/Ice/MFC/client/HelloClient.cpp @@ -66,17 +66,6 @@ CHelloClientApp::InitInstance() 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/HelloClient.rc b/cpp/demo/Ice/MFC/client/HelloClient.rc index 5e1ddc6f299..ba21c69ff1c 100644 --- a/cpp/demo/Ice/MFC/client/HelloClient.rc +++ b/cpp/demo/Ice/MFC/client/HelloClient.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script.
+// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
@@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE
//
-1 TEXTINCLUDE MOVEABLE PURE
+1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
-2 TEXTINCLUDE MOVEABLE PURE
+2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
-3 TEXTINCLUDE MOVEABLE PURE
+3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
@@ -64,7 +64,7 @@ END // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
-IDR_MAINFRAME ICON DISCARDABLE "res\\HelloClient.ico"
+IDR_MAINFRAME ICON "res\\HelloClient.ico"
/////////////////////////////////////////////////////////////////////////////
//
@@ -72,29 +72,25 @@ IDR_MAINFRAME ICON DISCARDABLE "res\\HelloClient.ico" //
IDD_HELLOCLIENT_DIALOG DIALOGEX 0, 0, 234, 97
-STYLE DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |
- WS_SYSMENU
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Ice Hello Client"
-FONT 8, "MS Shell Dlg"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LTEXT "Mode",IDC_MODELABEL,7,18,19,8
- COMBOBOX IDC_MODE,28,16,109,70,CBS_DROPDOWNLIST | WS_TABSTOP
- CONTROL "Secure",IDC_SECURE,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,155,14,38,10
- CONTROL "Timeout",IDC_TIMEOUT,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,155,26,41,10
- DEFPUSHBUTTON "Say Hello",IDC_INVOKE,7,56,68,14
- PUSHBUTTON "Flush Batch",IDC_FLUSH,83,56,68,14
- PUSHBUTTON "Shutdown Server",IDC_SHUTDOWN,159,56,68,14
- LTEXT "",IDC_STATUSBAR,0,84,234,12,SS_CENTERIMAGE |
- SS_ENDELLIPSIS,WS_EX_STATICEDGE
- CONTROL "Delay",IDC_DELAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- 155,38,34,10
+ LTEXT "Mode",IDC_MODELABEL,7,35,19,8
+ COMBOBOX IDC_MODE,41,33,109,70,CBS_DROPDOWNLIST | WS_TABSTOP
+ CONTROL "Secure",IDC_SECURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,15,38,10
+ CONTROL "Timeout",IDC_TIMEOUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,27,41,10
+ DEFPUSHBUTTON "Say Hello",IDC_INVOKE,7,57,68,14
+ PUSHBUTTON "Flush Batch",IDC_FLUSH,83,57,68,14
+ PUSHBUTTON "Shutdown Server",IDC_SHUTDOWN,159,57,68,14
+ LTEXT "",IDC_STATUSBAR,7,81,220,12,SS_CENTERIMAGE | SS_ENDELLIPSIS,WS_EX_STATICEDGE
+ CONTROL "Delay",IDC_DELAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,39,34,10
+ EDITTEXT IDC_HOST,41,16,109,14,ES_AUTOHSCROLL
+ LTEXT "Hostname",IDC_HOSTLABEL,7,17,31,8
END
-#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
@@ -117,14 +113,14 @@ BEGIN BEGIN
BLOCK "040904e4"
BEGIN
- VALUE "CompanyName", "ZeroC, Inc.\0"
- VALUE "FileDescription", "Ice Hello Client\0"
- VALUE "FileVersion", "1.0.0.1\0"
- VALUE "InternalName", "HelloClient.exe\0"
- VALUE "LegalCopyright", "Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.\0"
- VALUE "OriginalFilename", "HelloClient.exe\0"
- VALUE "ProductName", "Ice\0"
- VALUE "ProductVersion", "1.0.0.1\0"
+ VALUE "CompanyName", "ZeroC, Inc."
+ VALUE "FileDescription", "Ice Hello Client"
+ VALUE "FileVersion", "1.0.0.1"
+ VALUE "InternalName", "HelloClient.exe"
+ VALUE "LegalCopyright", "Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved."
+ VALUE "OriginalFilename", "HelloClient.exe"
+ VALUE "ProductName", "Ice"
+ VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
@@ -133,8 +129,6 @@ BEGIN END
END
-#endif // !_MAC
-
/////////////////////////////////////////////////////////////////////////////
//
@@ -142,14 +136,14 @@ END //
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO MOVEABLE PURE
+GUIDELINES DESIGNINFO
BEGIN
IDD_HELLOCLIENT_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 227
TOPMARGIN, 7
- BOTTOMMARGIN, 90
+ BOTTOMMARGIN, 93
END
END
#endif // APSTUDIO_INVOKED
diff --git a/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp b/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp index 8677ccc2393..2531ffbd229 100644 --- a/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp +++ b/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp @@ -15,9 +15,101 @@ #define new DEBUG_NEW #endif +#define WM_AMI_EXCEPTION (WM_USER + 1) +#define WM_AMI_SAY_HELLO_RESPONSE (WM_USER + 2) +#define WM_AMI_SAY_HELLO_SENT (WM_USER + 3) +#define WM_AMI_FLUSH_BATCH_REQUESTS_SENT (WM_USER + 4) +#define WM_AMI_SHUTDOWN_SENT (WM_USER + 5) + using namespace std; using namespace Demo; +class SayHelloCB : public AMI_Hello_sayHello, public Ice::AMISentCallback +{ +public: + + SayHelloCB(CHelloClientDlg* dialog) : _dialog(dialog) + { + } + + virtual void + ice_sent() + { + _dialog->PostMessage(WM_AMI_SAY_HELLO_SENT, 0, 0); + } + + virtual void + ice_response() + { + _dialog->PostMessage(WM_AMI_SAY_HELLO_RESPONSE, 0, 0); + } + + virtual void + ice_exception(const Ice::Exception& ex) + { + _dialog->PostMessage(WM_AMI_EXCEPTION, 0, reinterpret_cast<LONG>(ex.ice_clone())); + } + +private: + + CHelloClientDlg* _dialog; +}; + +class FlushBatchRequestsCB : public Ice::AMI_Object_ice_flushBatchRequests, public Ice::AMISentCallback +{ +public: + + FlushBatchRequestsCB(CHelloClientDlg* dialog) : _dialog(dialog) + { + } + + virtual void + ice_sent() + { + _dialog->PostMessage(WM_AMI_FLUSH_BATCH_REQUESTS_SENT, 0, 0); + } + + virtual void + ice_exception(const Ice::Exception& ex) + { + _dialog->PostMessage(WM_AMI_EXCEPTION, 0, reinterpret_cast<LONG>(ex.ice_clone())); + } + +private: + + CHelloClientDlg* _dialog; +}; + +class ShutdownCB : public AMI_Hello_shutdown, public Ice::AMISentCallback +{ +public: + + ShutdownCB(CHelloClientDlg* dialog) : _dialog(dialog) + { + } + + virtual void + ice_sent() + { + _dialog->PostMessage(WM_AMI_SHUTDOWN_SENT, 0, 0); + } + + virtual void + ice_response() + { + } + + virtual void + ice_exception(const Ice::Exception& ex) + { + _dialog->PostMessage(WM_AMI_EXCEPTION, 0, reinterpret_cast<LONG>(ex.ice_clone())); + } + +private: + + CHelloClientDlg* _dialog; +}; + CHelloClientDlg::CHelloClientDlg(const Ice::CommunicatorPtr& communicator, CWnd* pParent /*=NULL*/) : CDialog(CHelloClientDlg::IDD, pParent), _communicator(communicator), _currentMode(0), _useSecure(false), _useTimeout(false) @@ -38,6 +130,11 @@ BEGIN_MESSAGE_MAP(CHelloClientDlg, CDialog) ON_BN_CLICKED(IDC_INVOKE, OnSayHello) ON_BN_CLICKED(IDC_FLUSH, OnFlush) ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown) + ON_MESSAGE(WM_AMI_EXCEPTION, OnAMIException) + ON_MESSAGE(WM_AMI_SAY_HELLO_RESPONSE, OnAMISayHelloResponse) + ON_MESSAGE(WM_AMI_SAY_HELLO_SENT, OnAMISayHelloSent) + ON_MESSAGE(WM_AMI_FLUSH_BATCH_REQUESTS_SENT, OnAMIFlushBatchRequestsSent) + ON_MESSAGE(WM_AMI_SHUTDOWN_SENT, OnAMIShutdownSent) END_MESSAGE_MAP() BOOL @@ -53,6 +150,7 @@ CHelloClientDlg::OnInitDialog() // // Retrieve the controls. // + _host = (CEdit*)GetDlgItem(IDC_HOST); _mode = (CComboBox*)GetDlgItem(IDC_MODE); _secure = (CButton*)GetDlgItem(IDC_SECURE); _timeout = (CButton*)GetDlgItem(IDC_TIMEOUT); @@ -67,14 +165,29 @@ CHelloClientDlg::OnInitDialog() // // Create the proxy. // - Ice::ObjectPrx obj = _communicator->propertyToProxy("Hello.Proxy"); - _proxy = HelloPrx::uncheckedCast(obj); - _currentProxy = _proxy; + updateProxy(); + _host->SetWindowText(CString(_hostname.c_str())); _status->SetWindowText(CString(" Ready")); return TRUE; // return TRUE unless you set the focus to a control } +void +CHelloClientDlg::OnClose() +{ + // + // Destroy the communicator. If AMI calls are still in progress they will be + // interrupted with an Ice::CommunicatorDestroyedException. + // + try + { + _communicator->destroy(); + } + catch(const IceUtil::Exception&) + { + } +} + // 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. @@ -119,14 +232,24 @@ CHelloClientDlg::OnSayHello() try { updateProxy(); - _currentProxy->sayHello(_delay->GetCheck() == BST_CHECKED ? 2500 : 0); - if(_currentProxy->ice_isBatchOneway() || _currentProxy->ice_isBatchDatagram()) + if(!_currentProxy->ice_isBatchOneway() && !_currentProxy->ice_isBatchDatagram()) { - _status->SetWindowText(CString(" Queued batch request")); + if(_currentProxy->sayHello_async(new SayHelloCB(this), _delay->GetCheck() == BST_CHECKED ? 2500 : 0)) + { + if(_currentProxy->ice_isTwoway()) + { + _status->SetWindowText(CString(" Waiting for response")); + } + } + else + { + _status->SetWindowText(CString(" Sending request")); + } } else { - _status->SetWindowText(CString(" Sent request")); + _currentProxy->sayHello(_delay->GetCheck() == BST_CHECKED ? 2500 : 0); + _status->SetWindowText(CString(" Queued batch request")); } } catch(const IceUtil::Exception& ex) @@ -140,8 +263,15 @@ CHelloClientDlg::OnFlush() { try { - _communicator->flushBatchRequests(); - _status->SetWindowText(CString(" Flushed batch requests")); + updateProxy(); + if(_currentProxy->ice_flushBatchRequests_async(new FlushBatchRequestsCB(this))) + { + _status->SetWindowText(CString(" Flushed batch requests")); + } + else + { + _status->SetWindowText(CString(" Flushing batch requests")); + } } catch(const IceUtil::Exception& ex) { @@ -155,14 +285,21 @@ CHelloClientDlg::OnShutdown() try { updateProxy(); - _currentProxy->shutdown(); - if(_currentProxy->ice_isBatchOneway() || _currentProxy->ice_isBatchDatagram()) + if(!_currentProxy->ice_isBatchOneway() && !_currentProxy->ice_isBatchDatagram()) { - _status->SetWindowText(CString(" Queued shutdown request")); + if(_currentProxy->shutdown_async(new ShutdownCB(this))) + { + _status->SetWindowText(CString(" Sent shutdown request")); + } + else + { + _status->SetWindowText(CString(" Sending shutdown request")); + } } else { - _status->SetWindowText(CString(" Sent shutdown request")); + _currentProxy->shutdown(); + _status->SetWindowText(CString(" Queued shutdown request")); } } catch(const IceUtil::Exception& ex) @@ -171,6 +308,53 @@ CHelloClientDlg::OnShutdown() } } +LRESULT +CHelloClientDlg::OnAMIException(WPARAM, LPARAM lParam) +{ + Ice::Exception* ex = reinterpret_cast<Ice::Exception*>(lParam); + if(!dynamic_cast<Ice::CommunicatorDestroyedException*>(ex)) + { + handleException(*ex); + } + delete ex; + return 0; +} + +LRESULT +CHelloClientDlg::OnAMISayHelloSent(WPARAM, LPARAM) +{ + if(_currentProxy->ice_isTwoway()) + { + _status->SetWindowText(CString(" Waiting for response")); + } + else + { + _status->SetWindowText(CString(" Ready")); + } + return 0; +} + +LRESULT +CHelloClientDlg::OnAMISayHelloResponse(WPARAM, LPARAM) +{ + _status->SetWindowText(CString(" Ready")); + return 0; +} + +LRESULT +CHelloClientDlg::OnAMIFlushBatchRequestsSent(WPARAM, LPARAM) +{ + _status->SetWindowText(CString(" Flushed batch requests")); + return 0; +} + +LRESULT +CHelloClientDlg::OnAMIShutdownSent(WPARAM, LPARAM) +{ + _status->SetWindowText(CString(" Sent shutdown request")); + return 0; +} + void CHelloClientDlg::updateProxy() { @@ -178,12 +362,41 @@ CHelloClientDlg::updateProxy() bool secure = _secure->GetCheck() == BST_CHECKED; bool timeout = _timeout->GetCheck() == BST_CHECKED; - if(mode == _currentMode && secure == _useSecure && timeout == _useTimeout) + CString h; + _host->GetWindowText(h); + string hostname = (LPCTSTR)h; + + if(_currentProxy && + hostname == _hostname && + mode == _currentMode && + secure == _useSecure && + timeout == _useTimeout) { return; } - Ice::ObjectPrx proxy; + if(!_proxy) + { + _proxy = HelloPrx::uncheckedCast(_communicator->stringToProxy("hello:tcp -p 10000:udp -p 10000:ssl -p 10001")); + _hostname = "localhost"; + } + else if(hostname != _hostname) + { + try + { + _proxy = HelloPrx::uncheckedCast(_communicator->stringToProxy(string("hello") + + ":tcp -p 10000 -h " + hostname + + ":udp -p 10000 -h " + hostname + + ":ssl -p 10001 -h " + hostname)); + _hostname = hostname; + } + catch(const Ice::EndpointParseException&) + { + AfxMessageBox(CString("The provided hostname is invalid."), MB_OK|MB_ICONEXCLAMATION); + } + } + + Ice::ObjectPrx proxy = _proxy; switch(mode) { case 0: @@ -214,14 +427,7 @@ CHelloClientDlg::updateProxy() proxy = proxy->ice_timeout(-1); } - if(proxy->ice_isTwoway()) - { - _currentProxy = HelloPrx::checkedCast(proxy); - } - else - { - _currentProxy = HelloPrx::uncheckedCast(proxy); - } + _currentProxy = HelloPrx::uncheckedCast(proxy); _currentMode = mode; _useSecure = secure; _useTimeout = timeout; @@ -236,8 +442,7 @@ CHelloClientDlg::handleException(const IceUtil::Exception& e) } catch(const Ice::NoEndpointException&) { - AfxMessageBox(CString("The proxy does not support the current configuration"), - MB_OK|MB_ICONEXCLAMATION); + AfxMessageBox(CString("The proxy does not support the current configuration"), MB_OK|MB_ICONEXCLAMATION); } catch(const IceUtil::Exception& ex) { diff --git a/cpp/demo/Ice/MFC/client/HelloClientDlg.h b/cpp/demo/Ice/MFC/client/HelloClientDlg.h index 4935e1b72da..4ef7b2835fb 100644 --- a/cpp/demo/Ice/MFC/client/HelloClientDlg.h +++ b/cpp/demo/Ice/MFC/client/HelloClientDlg.h @@ -18,15 +18,19 @@ class CHelloClientDlg : public CDialog
{
public:
+ CHelloClientDlg(const Ice::CommunicatorPtr&, CWnd* = NULL);
enum { IDD = IDD_HELLOCLIENT_DIALOG };
protected:
+ virtual void DoDataExchange(CDataExchange*); // DDX/DDV support
protected:
+ Ice::CommunicatorPtr _communicator;
+ CEdit* _host;
CComboBox* _mode;
CButton* _secure;
CButton* _timeout;
@@ -35,17 +39,24 @@ protected: Demo::HelloPrx _proxy;
Demo::HelloPrx _currentProxy;
int _currentMode;
+ std::string _hostname;
bool _useSecure;
bool _useTimeout;
HICON _hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
+ afx_msg void OnClose();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSayHello();
afx_msg void OnFlush();
afx_msg void OnShutdown();
+ afx_msg LRESULT OnAMIException(WPARAM, LPARAM);
+ afx_msg LRESULT OnAMISayHelloResponse(WPARAM, LPARAM);
+ afx_msg LRESULT OnAMISayHelloSent(WPARAM, LPARAM);
+ afx_msg LRESULT OnAMIFlushBatchRequestsSent(WPARAM, LPARAM);
+ afx_msg LRESULT OnAMIShutdownSent(WPARAM, LPARAM);
DECLARE_MESSAGE_MAP()
void updateProxy();
diff --git a/cpp/demo/Ice/MFC/client/Resource.h b/cpp/demo/Ice/MFC/client/Resource.h index a4ac959eb20..0e779e87501 100644 --- a/cpp/demo/Ice/MFC/client/Resource.h +++ b/cpp/demo/Ice/MFC/client/Resource.h @@ -1,5 +1,5 @@ //{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
+// Microsoft Visual C++ generated include file.
// Used by HelloClient.rc
//
#define IDD_HELLOCLIENT_DIALOG 101
@@ -13,6 +13,9 @@ #define IDC_SHUTDOWN 1006
#define IDC_STATUSBAR 1007
#define IDC_DELAY 1008
+#define IDC_HOST 1009
+#define IDC_HOSTNAME 1010
+#define IDC_HOSTLABEL 1010
// Next default values for new objects
//
@@ -20,7 +23,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32771
-#define _APS_NEXT_CONTROL_VALUE 1008
+#define _APS_NEXT_CONTROL_VALUE 1010
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/cpp/demo/Ice/MFC/client/config b/cpp/demo/Ice/MFC/client/config index 0aceb3fc121..80829f230be 100644 --- a/cpp/demo/Ice/MFC/client/config +++ b/cpp/demo/Ice/MFC/client/config @@ -1,10 +1,4 @@ # -# 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 - -# # Warn about connection exceptions # Ice.Warn.Connections=1 diff --git a/cpp/demo/Ice/Makefile b/cpp/demo/Ice/Makefile index 7d605d2e45d..e393ac569ad 100644 --- a/cpp/demo/Ice/Makefile +++ b/cpp/demo/Ice/Makefile @@ -23,7 +23,8 @@ SUBDIRS = minimal \ session \ converter \ async \ - multicast + multicast \ + nrvo $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cpp/demo/Ice/Makefile.mak b/cpp/demo/Ice/Makefile.mak index 55709c93147..5fb697825e7 100644 --- a/cpp/demo/Ice/Makefile.mak +++ b/cpp/demo/Ice/Makefile.mak @@ -23,7 +23,8 @@ SUBDIRS = minimal \ session \
converter \
async \
- multicast
+ multicast \
+ nrvo
!if "$(CPP_COMPILER)" != "BCC2007" && "$(CPP_COMPILER)" != "VC80_EXPRESS" && "$(CPP_COMPILER)" != "VC90_EXPRESS"
SUBDIRS = $(SUBDIRS) MFC
diff --git a/cpp/demo/Ice/nrvo/.depend b/cpp/demo/Ice/nrvo/.depend new file mode 100644 index 00000000000..927f573b68e --- /dev/null +++ b/cpp/demo/Ice/nrvo/.depend @@ -0,0 +1,5 @@ +Nrvo$(OBJEXT): Nrvo.cpp Nrvo.h $(includedir)/Ice/LocalObjectF.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/Ice/Handle.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/Ice/Config.h $(includedir)/Ice/ProxyHandle.h $(includedir)/Ice/ProxyF.h $(includedir)/Ice/ObjectF.h $(includedir)/Ice/GCCountMap.h $(includedir)/Ice/GCShared.h $(includedir)/Ice/Exception.h $(includedir)/Ice/LocalObject.h $(includedir)/Ice/Proxy.h $(includedir)/IceUtil/Mutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Time.h $(includedir)/Ice/ProxyFactoryF.h $(includedir)/Ice/ConnectionIF.h $(includedir)/Ice/RequestHandlerF.h $(includedir)/Ice/EndpointIF.h $(includedir)/Ice/Endpoint.h $(includedir)/Ice/UndefSysMacros.h $(includedir)/Ice/ObjectAdapterF.h $(includedir)/Ice/ReferenceF.h $(includedir)/Ice/OutgoingAsyncF.h $(includedir)/Ice/Current.h $(includedir)/Ice/ConnectionF.h $(includedir)/Ice/Identity.h $(includedir)/Ice/StreamF.h $(includedir)/Ice/CommunicatorF.h $(includedir)/Ice/Object.h $(includedir)/Ice/IncomingAsyncF.h $(includedir)/Ice/Outgoing.h $(includedir)/IceUtil/Monitor.h $(includedir)/IceUtil/Cond.h $(includedir)/Ice/InstanceF.h $(includedir)/Ice/BasicStream.h $(includedir)/Ice/ObjectFactoryF.h $(includedir)/Ice/Buffer.h $(includedir)/Ice/Protocol.h $(includedir)/Ice/StringConverter.h $(includedir)/Ice/Plugin.h $(includedir)/Ice/LoggerF.h $(includedir)/IceUtil/Unicode.h $(includedir)/Ice/Incoming.h $(includedir)/Ice/ServantLocatorF.h $(includedir)/Ice/ServantManagerF.h $(includedir)/Ice/Direct.h MyStringSeq.h $(includedir)/Ice/LocalException.h $(includedir)/Ice/BuiltinSequences.h $(includedir)/Ice/ObjectFactory.h $(includedir)/IceUtil/Iterator.h $(includedir)/IceUtil/ScopedArray.h +Client$(OBJEXT): Client.cpp $(includedir)/Ice/Ice.h $(includedir)/Ice/Initialize.h $(includedir)/Ice/CommunicatorF.h $(includedir)/Ice/LocalObjectF.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/Ice/Handle.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/Ice/Config.h $(includedir)/Ice/ProxyHandle.h $(includedir)/Ice/ProxyF.h $(includedir)/Ice/ObjectF.h $(includedir)/Ice/GCCountMap.h $(includedir)/Ice/GCShared.h $(includedir)/Ice/Exception.h $(includedir)/Ice/LocalObject.h $(includedir)/Ice/UndefSysMacros.h $(includedir)/Ice/PropertiesF.h $(includedir)/Ice/Proxy.h $(includedir)/IceUtil/Mutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Time.h $(includedir)/Ice/ProxyFactoryF.h $(includedir)/Ice/ConnectionIF.h $(includedir)/Ice/RequestHandlerF.h $(includedir)/Ice/EndpointIF.h $(includedir)/Ice/Endpoint.h $(includedir)/Ice/ObjectAdapterF.h $(includedir)/Ice/ReferenceF.h $(includedir)/Ice/OutgoingAsyncF.h $(includedir)/Ice/Current.h $(includedir)/Ice/ConnectionF.h $(includedir)/Ice/Identity.h $(includedir)/Ice/StreamF.h $(includedir)/Ice/Object.h $(includedir)/Ice/IncomingAsyncF.h $(includedir)/Ice/InstanceF.h $(includedir)/Ice/LoggerF.h $(includedir)/Ice/StatsF.h $(includedir)/Ice/StringConverter.h $(includedir)/Ice/Plugin.h $(includedir)/IceUtil/Unicode.h $(includedir)/Ice/BuiltinSequences.h $(includedir)/Ice/LocalException.h $(includedir)/Ice/Properties.h $(includedir)/Ice/Outgoing.h $(includedir)/IceUtil/Monitor.h $(includedir)/IceUtil/Cond.h $(includedir)/Ice/BasicStream.h $(includedir)/Ice/ObjectFactoryF.h $(includedir)/Ice/Buffer.h $(includedir)/Ice/Protocol.h $(includedir)/Ice/OutgoingAsync.h $(includedir)/IceUtil/Timer.h $(includedir)/IceUtil/Thread.h $(includedir)/Ice/Incoming.h $(includedir)/Ice/ServantLocatorF.h $(includedir)/Ice/ServantManagerF.h $(includedir)/Ice/Direct.h $(includedir)/Ice/Logger.h $(includedir)/Ice/LoggerUtil.h $(includedir)/Ice/Stats.h $(includedir)/Ice/Communicator.h $(includedir)/Ice/RouterF.h $(includedir)/Ice/LocatorF.h $(includedir)/Ice/PluginF.h $(includedir)/Ice/ImplicitContextF.h $(includedir)/Ice/ObjectFactory.h $(includedir)/Ice/ObjectAdapter.h $(includedir)/Ice/FacetMap.h $(includedir)/Ice/ServantLocator.h $(includedir)/Ice/IncomingAsync.h $(includedir)/Ice/Process.h $(includedir)/Ice/Application.h $(includedir)/Ice/Connection.h $(includedir)/Ice/Functional.h $(includedir)/IceUtil/Functional.h $(includedir)/Ice/Stream.h $(includedir)/Ice/ImplicitContext.h $(includedir)/Ice/Locator.h $(includedir)/Ice/UserExceptionFactory.h $(includedir)/Ice/FactoryTable.h $(includedir)/Ice/FactoryTableDef.h $(includedir)/IceUtil/StaticMutex.h $(includedir)/Ice/UserExceptionFactoryF.h $(includedir)/Ice/ProcessF.h $(includedir)/Ice/Router.h $(includedir)/Ice/DispatchInterceptor.h $(includedir)/Ice/IconvStringConverter.h Nrvo.h MyStringSeq.h +NrvoI$(OBJEXT): NrvoI.cpp $(includedir)/Ice/Ice.h $(includedir)/Ice/Initialize.h $(includedir)/Ice/CommunicatorF.h $(includedir)/Ice/LocalObjectF.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/Ice/Handle.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/Ice/Config.h $(includedir)/Ice/ProxyHandle.h $(includedir)/Ice/ProxyF.h $(includedir)/Ice/ObjectF.h $(includedir)/Ice/GCCountMap.h $(includedir)/Ice/GCShared.h $(includedir)/Ice/Exception.h $(includedir)/Ice/LocalObject.h $(includedir)/Ice/UndefSysMacros.h $(includedir)/Ice/PropertiesF.h $(includedir)/Ice/Proxy.h $(includedir)/IceUtil/Mutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Time.h $(includedir)/Ice/ProxyFactoryF.h $(includedir)/Ice/ConnectionIF.h $(includedir)/Ice/RequestHandlerF.h $(includedir)/Ice/EndpointIF.h $(includedir)/Ice/Endpoint.h $(includedir)/Ice/ObjectAdapterF.h $(includedir)/Ice/ReferenceF.h $(includedir)/Ice/OutgoingAsyncF.h $(includedir)/Ice/Current.h $(includedir)/Ice/ConnectionF.h $(includedir)/Ice/Identity.h $(includedir)/Ice/StreamF.h $(includedir)/Ice/Object.h $(includedir)/Ice/IncomingAsyncF.h $(includedir)/Ice/InstanceF.h $(includedir)/Ice/LoggerF.h $(includedir)/Ice/StatsF.h $(includedir)/Ice/StringConverter.h $(includedir)/Ice/Plugin.h $(includedir)/IceUtil/Unicode.h $(includedir)/Ice/BuiltinSequences.h $(includedir)/Ice/LocalException.h $(includedir)/Ice/Properties.h $(includedir)/Ice/Outgoing.h $(includedir)/IceUtil/Monitor.h $(includedir)/IceUtil/Cond.h $(includedir)/Ice/BasicStream.h $(includedir)/Ice/ObjectFactoryF.h $(includedir)/Ice/Buffer.h $(includedir)/Ice/Protocol.h $(includedir)/Ice/OutgoingAsync.h $(includedir)/IceUtil/Timer.h $(includedir)/IceUtil/Thread.h $(includedir)/Ice/Incoming.h $(includedir)/Ice/ServantLocatorF.h $(includedir)/Ice/ServantManagerF.h $(includedir)/Ice/Direct.h $(includedir)/Ice/Logger.h $(includedir)/Ice/LoggerUtil.h $(includedir)/Ice/Stats.h $(includedir)/Ice/Communicator.h $(includedir)/Ice/RouterF.h $(includedir)/Ice/LocatorF.h $(includedir)/Ice/PluginF.h $(includedir)/Ice/ImplicitContextF.h $(includedir)/Ice/ObjectFactory.h $(includedir)/Ice/ObjectAdapter.h $(includedir)/Ice/FacetMap.h $(includedir)/Ice/ServantLocator.h $(includedir)/Ice/IncomingAsync.h $(includedir)/Ice/Process.h $(includedir)/Ice/Application.h $(includedir)/Ice/Connection.h $(includedir)/Ice/Functional.h $(includedir)/IceUtil/Functional.h $(includedir)/Ice/Stream.h $(includedir)/Ice/ImplicitContext.h $(includedir)/Ice/Locator.h $(includedir)/Ice/UserExceptionFactory.h $(includedir)/Ice/FactoryTable.h $(includedir)/Ice/FactoryTableDef.h $(includedir)/IceUtil/StaticMutex.h $(includedir)/Ice/UserExceptionFactoryF.h $(includedir)/Ice/ProcessF.h $(includedir)/Ice/Router.h $(includedir)/Ice/DispatchInterceptor.h $(includedir)/Ice/IconvStringConverter.h NrvoI.h Nrvo.h MyStringSeq.h +Nrvo.cpp: Nrvo.ice +Nrvo.ice: $(SLICE2CPP) $(SLICEPARSERLIB) diff --git a/cpp/demo/Ice/nrvo/.gitignore b/cpp/demo/Ice/nrvo/.gitignore new file mode 100644 index 00000000000..ee1193c8569 --- /dev/null +++ b/cpp/demo/Ice/nrvo/.gitignore @@ -0,0 +1,7 @@ +// Generated by makegitignore.py + +// IMPORTANT: Do not edit this file -- any edits made here will be lost! +client +server +Throughput.cpp +Throughput.h diff --git a/cpp/demo/Ice/nrvo/Client.cpp b/cpp/demo/Ice/nrvo/Client.cpp new file mode 100644 index 00000000000..7fec1f3ea71 --- /dev/null +++ b/cpp/demo/Ice/nrvo/Client.cpp @@ -0,0 +1,141 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 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 <Nrvo.h> +#include <MyStringSeq.h> +#include <iomanip> + +using namespace std; +using namespace Demo; + +class NrvoClient : public Ice::Application +{ +public: + + NrvoClient(); + virtual int run(int, char*[]); + +private: + + void menu(); +}; + +int +main(int argc, char* argv[]) +{ + NrvoClient app; + return app.main(argc, argv, "config.client"); +} + +NrvoClient::NrvoClient() +{ +} + +int +NrvoClient::run(int argc, char* argv[]) +{ + if(argc > 1) + { + cerr << appName() << ": too many arguments" << endl; + return EXIT_FAILURE; + } + + NrvoPrx nrvo = NrvoPrx::checkedCast(communicator()->propertyToProxy("Nrvo.Proxy")); + if(!nrvo) + { + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; + } + + menu(); + + char currentOperation = '1'; + char c; + do + { + try + { + cout << "==> "; + cin >> c; + + if(c == '1' || c == '2' || c == '3' || c == 's' || c == '?' || c == 'x') + { + currentOperation = c; + switch(c) + { + case '1': + { + cout << "calling op1" << endl; + MyStringSeq seq = nrvo->op1(); + break; + } + + case '2': + { + cout << "calling op2" << endl; + MyStringSeq seq = nrvo->op2(); + break; + } + + case '3': + { + cout << "calling op3" << endl; + MyStringSeq seq = nrvo->op3(10); + break; + } + + case 's': + { + nrvo->shutdown(); + } + + case '?': + { + menu(); + break; + } + + case 'x': + { + break; + } + } + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } + } + while(cin.good() && c != 'x'); + + return EXIT_SUCCESS; +} + + +void +NrvoClient::menu() +{ + cout << + "usage:\n" + "\n" + "Operation to call:\n" + "1: return a string sequence.\n" + "2: return a string sequence that is a data member of the servant.\n" + "3: return a string sequence from an operation with multiple return path.\n" + "s: shutdown server.\n" + "x: exit.\n" + "?: show this menu.\n"; +} diff --git a/cpp/demo/Ice/nrvo/Makefile b/cpp/demo/Ice/nrvo/Makefile new file mode 100644 index 00000000000..e4440c95693 --- /dev/null +++ b/cpp/demo/Ice/nrvo/Makefile @@ -0,0 +1,42 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2008 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 = Nrvo.o + +COBJS = Client.o + +SOBJS = NrvoI.o \ + Server.o + +SRCS = $(OBJS:.o=.cpp) \ + $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) + +SLICE_SRCS = Nrvo.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/nrvo/Makefile.mak b/cpp/demo/Ice/nrvo/Makefile.mak new file mode 100644 index 00000000000..d99fe2775f7 --- /dev/null +++ b/cpp/demo/Ice/nrvo/Makefile.mak @@ -0,0 +1,50 @@ +# **********************************************************************
+#
+# Copyright (c) 2003-2008 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.exe
+SERVER = server.exe
+
+TARGETS = $(CLIENT) $(SERVER)
+
+OBJS = Nrvo.obj
+
+COBJS = Client.obj
+
+SOBJS = NrvoI.obj \
+ Server.obj
+
+SRCS = $(OBJS:.obj=.cpp) \
+ $(COBJS:.obj=.cpp) \
+ $(SOBJS:.obj=.cpp)
+
+!include $(top_srcdir)/config/Make.rules.mak
+
+CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
+
+!if "$(GENERATE_PDB)" == "yes"
+CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb)
+SPDBFLAGS = /pdb:$(SERVER:.exe=.pdb)
+!endif
+
+$(CLIENT): $(OBJS) $(COBJS)
+ $(LINK) $(LD_EXEFLAGS) $(CPDBFLAGS) $(SETARGV) $(OBJS) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS)
+ @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
+ $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest
+
+$(SERVER): $(OBJS) $(SOBJS)
+ $(LINK) $(LD_EXEFLAGS) $(SPDBFLAGS) $(SETARGV) $(OBJS) $(SOBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS)
+ @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
+ $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest
+
+clean::
+ del /q Nrvo.cpp Nrvo.h
+
+!include .depend
diff --git a/cpp/demo/Ice/nrvo/MyStringSeq.h b/cpp/demo/Ice/nrvo/MyStringSeq.h new file mode 100644 index 00000000000..e5adfc4b45e --- /dev/null +++ b/cpp/demo/Ice/nrvo/MyStringSeq.h @@ -0,0 +1,32 @@ +#ifndef MY_STRING_SEQ +#define MY_STRING_SEQ + +#include <vector> +#include <string> +#include <iostream> + +class MyStringSeq : public std::vector<std::string> +{ +public: + + MyStringSeq() + {} + + MyStringSeq(size_t n) : + std::vector<std::string>(n) + { + } + + MyStringSeq(size_t n, const std::string& str) : + std::vector<std::string>(n, str) + { + } + + MyStringSeq(const MyStringSeq& seq) : + std::vector<std::string>(seq) + { + std::cout << "MyStringSeq copy ctor" << std::endl; + } +}; + +#endif diff --git a/cpp/demo/Ice/nrvo/Nrvo.ice b/cpp/demo/Ice/nrvo/Nrvo.ice new file mode 100644 index 00000000000..f403f0242ec --- /dev/null +++ b/cpp/demo/Ice/nrvo/Nrvo.ice @@ -0,0 +1,30 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 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 NRVO_ICE +#define NRVO_ICE + +module Demo +{ + +[["cpp:include:MyStringSeq.h"]] +["cpp:type:MyStringSeq"] sequence<string> StringSeq; +const int StringSeqSize = 50000; + +interface Nrvo +{ + StringSeq op1(); + StringSeq op2(); + StringSeq op3(int size); + void shutdown(); +}; + +}; + +#endif diff --git a/cpp/demo/Ice/nrvo/NrvoI.cpp b/cpp/demo/Ice/nrvo/NrvoI.cpp new file mode 100644 index 00000000000..dc07ff8d10f --- /dev/null +++ b/cpp/demo/Ice/nrvo/NrvoI.cpp @@ -0,0 +1,54 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 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 <iostream> +#include <NrvoI.h> + +using namespace std; + +NrvoI::NrvoI() : + _stringSeq(Demo::StringSeqSize, "hello") +{ +} + +Demo::StringSeq +NrvoI::op1(const Ice::Current&) +{ + cout << "running op1" << endl; + MyStringSeq seq = MyStringSeq(Demo::StringSeqSize, "hello"); + return seq; +} + +Demo::StringSeq +NrvoI::op2(const Ice::Current&) +{ + cout << "running op2" << endl; + return _stringSeq; +} + +Demo::StringSeq +NrvoI::op3(int size, const Ice::Current&) +{ + cout << "running op3" << endl; + MyStringSeq seq; + if(size < 10) + { + return MyStringSeq(size, "hello"); + } + seq = MyStringSeq(10, "hello"); + return seq; +} + + +void +NrvoI::shutdown(const Ice::Current& c) +{ + c.adapter->getCommunicator()->shutdown(); +} diff --git a/cpp/demo/Ice/nrvo/NrvoI.h b/cpp/demo/Ice/nrvo/NrvoI.h new file mode 100644 index 00000000000..5439c2ca15e --- /dev/null +++ b/cpp/demo/Ice/nrvo/NrvoI.h @@ -0,0 +1,31 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 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 NRVO_I_H +#define NRVO_I_H + +#include <Nrvo.h> +#include <MyStringSeq.h> + +class NrvoI : public Demo::Nrvo +{ +public: + + NrvoI(); + virtual Demo::StringSeq op1(const Ice::Current&); + virtual Demo::StringSeq op2(const Ice::Current&); + virtual Demo::StringSeq op3(int size, const Ice::Current&); + virtual void shutdown(const Ice::Current&); + +private: + + MyStringSeq _stringSeq; +}; + +#endif diff --git a/cpp/demo/Ice/nrvo/README b/cpp/demo/Ice/nrvo/README new file mode 100644 index 00000000000..105db4a5a32 --- /dev/null +++ b/cpp/demo/Ice/nrvo/README @@ -0,0 +1,41 @@ + +A simple demo that show how Ice take advantage of NRVO (Named Return Value Optimization) +include in moderm c++ compilers. + +GCC and Visual Studio compilers suport this optimization + + You could read more about Visual Studio NRVO at + http://msdn.microsoft.com/en-us/library/ms364057(VS.80).aspx + + For GCC NRVO was first introduced in gcc-3.1 see the release changes for details + http://www.gnu.org/software/gcc/gcc-3.1/changes.html + +To run the demo, first start the server: + +$ server + +In a separate window, start the client: + +$ client + +When you start the client it show you a menu with different operations +you can invoke each operation pressing the correspoding key. + +All this operations return a string sequence mapped to a custom class MyStringSeq, +when a copy is made the message "MyStringSeq copy ctor" is wrote to the console, this +permit you see what copies of the returned data are made by Ice run time. + +To make sure the optimzations are aply you should compile the demo with optimizations +enabled. + +If you call an operation the client and server should print a message "calling <opname>" +and bellow that message you will see as many "MyStringSeq copy ctor" messages as copies +are made. + +In the server side we show 1 case when NRVO works, that is a function that +has a single return path implemented in NrvoI::op1 . And 2 case where NRVO dont work, a +function that return a data member of the servant implemented in NrvoI::op2 and a function +with multiple returns path implemented in NrvoI::op3. + +So if you press option 1 you will see that NRVO is apply in both client and server sides, +and if you call 2 or 3 the optimization only apply to client side. diff --git a/cpp/demo/Ice/nrvo/Server.cpp b/cpp/demo/Ice/nrvo/Server.cpp new file mode 100644 index 00000000000..52b9d27f3d8 --- /dev/null +++ b/cpp/demo/Ice/nrvo/Server.cpp @@ -0,0 +1,44 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 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 <NrvoI.h> + +using namespace std; + +class NrvotServer : public Ice::Application +{ +public: + + virtual int run(int, char*[]); +}; + +int +main(int argc, char* argv[]) +{ + NrvotServer app; + return app.main(argc, argv, "config.server"); +} + +int +NrvotServer::run(int argc, char* argv[]) +{ + if(argc > 1) + { + cerr << appName() << ": too many arguments" << endl; + return EXIT_FAILURE; + } + + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Nrvo"); + Demo::NrvoPtr servant = new NrvoI(); + adapter->add(servant, communicator()->stringToIdentity("nrvo")); + adapter->activate(); + communicator()->waitForShutdown(); + return EXIT_SUCCESS; +} diff --git a/cpp/demo/Ice/nrvo/config.client b/cpp/demo/Ice/nrvo/config.client new file mode 100644 index 00000000000..c582c4dd677 --- /dev/null +++ b/cpp/demo/Ice/nrvo/config.client @@ -0,0 +1,20 @@ +# +# The client reads this property to create the reference to the +# "Throughput" object in the server. +# +Nrvo.Proxy=nrvo:default -p 10000 -h 127.0.0.1 + +# +# Disable client-side ACM. +# +Ice.ACM.Client=0 + +# +# SSL Configuration +# +Ice.Plugin.IceSSL=IceSSL:createIceSSL +IceSSL.DefaultDir=../../../../certs +IceSSL.CertAuthFile=cacert.pem +IceSSL.CertFile=c_rsa1024_pub.pem +IceSSL.KeyFile=c_rsa1024_priv.pem + diff --git a/cpp/demo/Ice/nrvo/config.server b/cpp/demo/Ice/nrvo/config.server new file mode 100644 index 00000000000..2a90e37a37c --- /dev/null +++ b/cpp/demo/Ice/nrvo/config.server @@ -0,0 +1,20 @@ +# +# The server creates one single object adapter with the name +# "Throughput". The following line sets the endpoints for this +# adapter. +# +Nrvo.Endpoints=default -p 10000 -h 127.0.0.1 + +# +# Warn about connection exceptions +# +Ice.Warn.Connections=1 + +# +# SSL Configuration +# +Ice.Plugin.IceSSL=IceSSL:createIceSSL +IceSSL.DefaultDir=../../../../certs +IceSSL.CertAuthFile=cacert.pem +IceSSL.CertFile=s_rsa1024_pub.pem +IceSSL.KeyFile=s_rsa1024_priv.pem diff --git a/cpp/demo/Ice/nrvo/expect.py b/cpp/demo/Ice/nrvo/expect.py new file mode 100644 index 00000000000..bce4683e291 --- /dev/null +++ b/cpp/demo/Ice/nrvo/expect.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2008 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. +# +# ********************************************************************** + +import sys, os + +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] +if len(path) == 0: + raise "can't find toplevel directory!" +sys.path.append(path[0]) + +from demoscript import * +from demoscript.Ice import nrvo + +server = Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = Util.spawn('./client') +client.expect('.*==>') + +nrvo.run(client, server) |