summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2005-09-09 07:05:32 +0000
committerMatthew Newhook <matthew@zeroc.com>2005-09-09 07:05:32 +0000
commitd9e37798719846dd6ea7f25fcc4eb053db2c2efe (patch)
tree04dc91fdacae69db9adb3ba8c8d0872a7243662d /cpp
parentFirst saving support (diff)
downloadice-d9e37798719846dd6ea7f25fcc4eb053db2c2efe.tar.bz2
ice-d9e37798719846dd6ea7f25fcc4eb053db2c2efe.tar.xz
ice-d9e37798719846dd6ea7f25fcc4eb053db2c2efe.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=335
Diffstat (limited to 'cpp')
-rw-r--r--cpp/demo/Freeze/backup/Client.cpp31
-rw-r--r--cpp/demo/Ice/bidir/Client.cpp11
-rw-r--r--cpp/demo/Ice/bidir/README12
-rw-r--r--cpp/demo/Ice/bidir/Server.cpp7
-rw-r--r--cpp/demo/Ice/callback/Client.cpp55
-rw-r--r--cpp/demo/Ice/callback/README11
-rw-r--r--cpp/demo/Ice/callback/Server.cpp7
-rw-r--r--cpp/demo/Ice/hello/Client.cpp87
-rw-r--r--cpp/demo/Ice/hello/HelloI.cpp2
-rw-r--r--cpp/demo/Ice/hello/HelloI.h2
-rw-r--r--cpp/demo/Ice/hello/README11
-rw-r--r--cpp/demo/Ice/hello/Server.cpp56
-rw-r--r--cpp/demo/Ice/invoke/Client.cpp105
-rw-r--r--cpp/demo/Ice/invoke/Server.cpp56
-rw-r--r--cpp/demo/Ice/latency/Client.cpp57
-rw-r--r--cpp/demo/Ice/latency/README10
-rw-r--r--cpp/demo/Ice/latency/Server.cpp57
-rw-r--r--cpp/demo/Ice/nested/Client.cpp13
-rw-r--r--cpp/demo/Ice/nested/NestedI.h2
-rw-r--r--cpp/demo/Ice/nested/README11
-rw-r--r--cpp/demo/Ice/nested/Server.cpp7
-rw-r--r--cpp/demo/Ice/throughput/Client.cpp95
-rw-r--r--cpp/demo/Ice/throughput/Makefile3
-rw-r--r--cpp/demo/Ice/throughput/README15
-rw-r--r--cpp/demo/Ice/throughput/Server.cpp57
-rw-r--r--cpp/demo/Ice/throughput/ThroughputI.cpp105
-rw-r--r--cpp/demo/Ice/throughput/ThroughputI.h109
-rw-r--r--cpp/demo/Ice/throughput/throughputS.dsp4
-rw-r--r--cpp/demo/Ice/value/Client.cpp4
-rw-r--r--cpp/demo/Ice/value/README14
-rw-r--r--cpp/demo/Ice/value/Server.cpp5
-rw-r--r--cpp/demo/Ice/value/ValueI.cpp13
-rw-r--r--cpp/demo/Ice/value/ValueI.h22
33 files changed, 500 insertions, 556 deletions
diff --git a/cpp/demo/Freeze/backup/Client.cpp b/cpp/demo/Freeze/backup/Client.cpp
index 231d772044d..1ad35f9eea1 100644
--- a/cpp/demo/Freeze/backup/Client.cpp
+++ b/cpp/demo/Freeze/backup/Client.cpp
@@ -11,17 +11,13 @@
#include <IceUtil/Time.h>
#include <Freeze/Freeze.h>
-using namespace Freeze;
-using namespace Ice;
-using namespace IceUtil;
using namespace std;
-
static void
testFailed(const char* expr, const char* file, unsigned int line)
{
- std::cout << "failed!" << std::endl;
- std::cout << file << ':' << line << ": assertion `" << expr << "' failed" << std::endl;
+ cout << "failed!" << endl;
+ cout << file << ':' << line << ": assertion `" << expr << "' failed" << endl;
abort();
}
@@ -30,12 +26,12 @@ testFailed(const char* expr, const char* file, unsigned int line)
int
main(int argc, char* argv[])
{
- PropertiesPtr properties = Ice::createProperties();
+ Ice::PropertiesPtr properties = Ice::createProperties();
properties->load("config");
- CommunicatorPtr communicator = initializeWithProperties(argc, argv, properties);
+ Ice::CommunicatorPtr communicator = Ice::initializeWithProperties(argc, argv, properties);
- Freeze::ConnectionPtr connection = createConnection(communicator, "backup");
+ Freeze::ConnectionPtr connection = Freeze::createConnection(communicator, "backup");
IntLongMap m(connection, "IntLongMap", true);
const int size = 10000;
@@ -43,10 +39,10 @@ main(int argc, char* argv[])
if(m.size() == 0)
{
cout << "********* Creating new map ***********" << endl;
- TransactionHolder txHolder(connection);
+ Freeze::TransactionHolder txHolder(connection);
- Time time = Time::now();
- Int64 ms = time.toMilliSeconds();
+ IceUtil::Time time = IceUtil::Time::now();
+ IceUtil::Int64 ms = time.toMilliSeconds();
for(int i = 0; i < size; ++i)
{
@@ -61,12 +57,12 @@ main(int argc, char* argv[])
{
int count = 0;
- TransactionHolder txHolder(connection);
- Time time = Time::now();
- Int64 ms = time.toMilliSeconds();
+ Freeze::TransactionHolder txHolder(connection);
+ IceUtil::Time time = IceUtil::Time::now();
+ IceUtil::Int64 ms = time.toMilliSeconds();
IntLongMap::iterator p = m.begin();
- Int64 oldMs = p->second;
+ IceUtil::Int64 oldMs = p->second;
do
{
if(p->second != oldMs)
@@ -80,7 +76,7 @@ main(int argc, char* argv[])
count++;
} while(++p != m.end());
- cout << "Read " << Time::milliSeconds(oldMs).toString() << " in all records;"
+ cout << "Read " << IceUtil::Time::milliSeconds(oldMs).toString() << " in all records;"
<< " updating with " << time.toString() << " ... " << flush;
txHolder.commit();
@@ -89,6 +85,7 @@ main(int argc, char* argv[])
}
connection->close();
+
communicator->destroy();
return EXIT_SUCCESS;
diff --git a/cpp/demo/Ice/bidir/Client.cpp b/cpp/demo/Ice/bidir/Client.cpp
index f0f05ea2836..56be81b282d 100644
--- a/cpp/demo/Ice/bidir/Client.cpp
+++ b/cpp/demo/Ice/bidir/Client.cpp
@@ -12,7 +12,6 @@
#include <Callback.h>
using namespace std;
-using namespace Ice;
using namespace Demo;
class CallbackReceiverI : public CallbackReceiver
@@ -20,13 +19,13 @@ class CallbackReceiverI : public CallbackReceiver
public:
virtual void
- callback(Int num, const Current&)
+ callback(Ice::Int num, const Ice::Current&)
{
cout << "received callback #" << num << endl;
}
};
-class CallbackClient : public Application
+class CallbackClient : public Ice::Application
{
public:
@@ -43,7 +42,7 @@ main(int argc, char* argv[])
int
CallbackClient::run(int argc, char* argv[])
{
- PropertiesPtr properties = communicator()->getProperties();
+ Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "Callback.Client.CallbackServer";
std::string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
@@ -59,8 +58,8 @@ CallbackClient::run(int argc, char* argv[])
return EXIT_FAILURE;
}
- ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client");
- Identity ident;
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client");
+ Ice::Identity ident;
ident.name = IceUtil::generateUUID();
ident.category = "";
adapter->add(new CallbackReceiverI, ident);
diff --git a/cpp/demo/Ice/bidir/README b/cpp/demo/Ice/bidir/README
new file mode 100644
index 00000000000..abce6080ba5
--- /dev/null
+++ b/cpp/demo/Ice/bidir/README
@@ -0,0 +1,12 @@
+This demo shows how to use bi-directional connections for
+callbacks. This is typically used if the server cannot open a
+connection to the client to send callbacks, for example, because
+firewalls block incoming connections to the client.
+
+To run the demo, first start the server:
+
+$ server
+
+In a separate window, start the client:
+
+$ client
diff --git a/cpp/demo/Ice/bidir/Server.cpp b/cpp/demo/Ice/bidir/Server.cpp
index 92b225ac4a6..41f7c129f10 100644
--- a/cpp/demo/Ice/bidir/Server.cpp
+++ b/cpp/demo/Ice/bidir/Server.cpp
@@ -7,14 +7,13 @@
//
// **********************************************************************
-#include <Ice/Application.h>
#include <CallbackI.h>
+#include <Ice/Application.h>
using namespace std;
-using namespace Ice;
using namespace Demo;
-class CallbackServer : public Application
+class CallbackServer : public Ice::Application
{
public:
@@ -31,7 +30,7 @@ main(int argc, char* argv[])
int
CallbackServer::run(int argc, char* argv[])
{
- ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Server");
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Server");
CallbackSenderIPtr sender = new CallbackSenderI;
adapter->add(sender, Ice::stringToIdentity("sender"));
adapter->activate();
diff --git a/cpp/demo/Ice/callback/Client.cpp b/cpp/demo/Ice/callback/Client.cpp
index 1ab96ca8bfe..28f6e401acd 100644
--- a/cpp/demo/Ice/callback/Client.cpp
+++ b/cpp/demo/Ice/callback/Client.cpp
@@ -11,24 +11,27 @@
#include <Callback.h>
using namespace std;
-using namespace Ice;
using namespace Demo;
class CallbackReceiverI : public CallbackReceiver
{
public:
- virtual void callback(const Current&)
+ virtual void callback(const Ice::Current&)
{
cout << "received callback" << endl;
}
};
-class CallbackClient : public Application
+class CallbackClient : public Ice::Application
{
public:
virtual int run(int, char*[]);
+
+private:
+
+ void menu();
};
int
@@ -38,27 +41,10 @@ main(int argc, char* argv[])
return app.main(argc, argv, "config");
}
-void
-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";
-}
-
int
CallbackClient::run(int argc, char* argv[])
{
- PropertiesPtr properties = communicator()->getProperties();
+ Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "Callback.Client.CallbackServer";
std::string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
@@ -67,7 +53,7 @@ CallbackClient::run(int argc, char* argv[])
return EXIT_FAILURE;
}
- ObjectPrx base = communicator()->stringToProxy(proxy);
+ Ice::ObjectPrx base = communicator()->stringToProxy(proxy);
CallbackSenderPrx twoway = CallbackSenderPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false));
if(!twoway)
{
@@ -79,12 +65,12 @@ CallbackClient::run(int argc, char* argv[])
CallbackSenderPrx datagram = CallbackSenderPrx::uncheckedCast(twoway->ice_datagram());
CallbackSenderPrx batchDatagram = CallbackSenderPrx::uncheckedCast(twoway->ice_batchDatagram());
- ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client");
- adapter->add(new CallbackReceiverI, stringToIdentity("callbackReceiver"));
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client");
+ adapter->add(new CallbackReceiverI, Ice::stringToIdentity("callbackReceiver"));
adapter->activate();
CallbackReceiverPrx twowayR = CallbackReceiverPrx::uncheckedCast(
- adapter->createProxy(stringToIdentity("callbackReceiver")));
+ adapter->createProxy(Ice::stringToIdentity("callbackReceiver")));
CallbackReceiverPrx onewayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_oneway());
CallbackReceiverPrx datagramR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_datagram());
@@ -180,7 +166,7 @@ CallbackClient::run(int argc, char* argv[])
menu();
}
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
cerr << ex << endl;
}
@@ -189,3 +175,20 @@ CallbackClient::run(int argc, char* argv[])
return EXIT_SUCCESS;
}
+
+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";
+}
diff --git a/cpp/demo/Ice/callback/README b/cpp/demo/Ice/callback/README
new file mode 100644
index 00000000000..47beab48e3e
--- /dev/null
+++ b/cpp/demo/Ice/callback/README
@@ -0,0 +1,11 @@
+A simple callback demo that illustrates how a client can pass a proxy
+to a server, invoke an operation in the server, and the server call
+back into an object provided by the client as part of that invocation.
+
+To run the demo, first start the server:
+
+$ server
+
+In a separate window, start the client:
+
+$ client
diff --git a/cpp/demo/Ice/callback/Server.cpp b/cpp/demo/Ice/callback/Server.cpp
index a476897e798..0c3b5a21581 100644
--- a/cpp/demo/Ice/callback/Server.cpp
+++ b/cpp/demo/Ice/callback/Server.cpp
@@ -7,14 +7,13 @@
//
// **********************************************************************
-#include <Ice/Application.h>
#include <CallbackSenderI.h>
+#include <Ice/Application.h>
using namespace std;
-using namespace Ice;
using namespace Demo;
-class CallbackServer : public Application
+class CallbackServer : public Ice::Application
{
public:
@@ -31,7 +30,7 @@ main(int argc, char* argv[])
int
CallbackServer::run(int argc, char* argv[])
{
- ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Server");
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Server");
adapter->add(new CallbackSenderI, Ice::stringToIdentity("callback"));
adapter->activate();
communicator()->waitForShutdown();
diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp
index a5d42dde750..7fbb8d0053d 100644
--- a/cpp/demo/Ice/hello/Client.cpp
+++ b/cpp/demo/Ice/hello/Client.cpp
@@ -7,34 +7,34 @@
//
// **********************************************************************
-#include <Ice/Ice.h>
+#include <Ice/Application.h>
#include <Hello.h>
using namespace std;
using namespace Demo;
-void
-menu()
+class HelloClient : public Ice::Application
{
- 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"
- "S: switch secure mode on/off\n"
- "s: shutdown server\n"
- "x: exit\n"
- "?: help\n";
+public:
+
+ virtual int run(int, char*[]);
+
+private:
+
+ void menu();
+};
+
+int
+main(int argc, char* argv[])
+{
+ HelloClient app;
+ return app.main(argc, argv, "config");
}
int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+HelloClient::run(int argc, char* argv[])
{
- Ice::PropertiesPtr properties = communicator->getProperties();
+ Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "Hello.Proxy";
string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
@@ -43,7 +43,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_FAILURE;
}
- Ice::ObjectPrx base = communicator->stringToProxy(proxy);
+ Ice::ObjectPrx base = communicator()->stringToProxy(proxy);
HelloPrx twoway = HelloPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false));
if(!twoway)
{
@@ -103,7 +103,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
else if(c == 'f')
{
- communicator->flushBatchRequests();
+ communicator()->flushBatchRequests();
}
else if(c == 'T')
{
@@ -176,37 +176,20 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_SUCCESS;
}
-int
-main(int argc, char* argv[])
+void
+HelloClient::menu()
{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, argv, properties);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
-
- return status;
+ 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"
+ "S: switch secure mode on/off\n"
+ "s: shutdown server\n"
+ "x: exit\n"
+ "?: help\n";
}
diff --git a/cpp/demo/Ice/hello/HelloI.cpp b/cpp/demo/Ice/hello/HelloI.cpp
index e9936671745..b324ac429ed 100644
--- a/cpp/demo/Ice/hello/HelloI.cpp
+++ b/cpp/demo/Ice/hello/HelloI.cpp
@@ -7,8 +7,8 @@
//
// **********************************************************************
-#include <Ice/Ice.h>
#include <HelloI.h>
+#include <Ice/Ice.h>
using namespace std;
diff --git a/cpp/demo/Ice/hello/HelloI.h b/cpp/demo/Ice/hello/HelloI.h
index f14b47ade3c..8741ccef50a 100644
--- a/cpp/demo/Ice/hello/HelloI.h
+++ b/cpp/demo/Ice/hello/HelloI.h
@@ -12,7 +12,7 @@
#include <Hello.h>
-class HelloI : public ::Demo::Hello
+class HelloI : public Demo::Hello
{
public:
diff --git a/cpp/demo/Ice/hello/README b/cpp/demo/Ice/hello/README
new file mode 100644
index 00000000000..5a7178ba9ca
--- /dev/null
+++ b/cpp/demo/Ice/hello/README
@@ -0,0 +1,11 @@
+This demo illustrates how to invoke ordinary (twoway) operations, as
+well as how to invoke oneway operations, use datagrams, secure
+invocations, and how to used batched invocations.
+
+To run the demo, first start the server:
+
+$ server
+
+In a separate window, start the client:
+
+$ client
diff --git a/cpp/demo/Ice/hello/Server.cpp b/cpp/demo/Ice/hello/Server.cpp
index a3b113af11d..c6b439fcfc2 100644
--- a/cpp/demo/Ice/hello/Server.cpp
+++ b/cpp/demo/Ice/hello/Server.cpp
@@ -7,53 +7,31 @@
//
// **********************************************************************
-#include <Ice/Ice.h>
#include <HelloI.h>
+#include <Ice/Application.h>
using namespace std;
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+class HelloServer : public Ice::Application
{
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello");
- Ice::ObjectPtr object = new HelloI;
- adapter->add(object, Ice::stringToIdentity("hello"));
- adapter->activate();
- communicator->waitForShutdown();
- return EXIT_SUCCESS;
-}
+public:
+
+ virtual int run(int, char*[]);
+};
int
main(int argc, char* argv[])
{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, argv, properties);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
+ HelloServer app;
+ return app.main(argc, argv, "config");
+}
- return status;
+int
+HelloServer::run(int argc, char* argv[])
+{
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");
+ adapter->add(new HelloI, Ice::stringToIdentity("hello"));
+ adapter->activate();
+ communicator()->waitForShutdown();
+ return EXIT_SUCCESS;
}
diff --git a/cpp/demo/Ice/invoke/Client.cpp b/cpp/demo/Ice/invoke/Client.cpp
index 62600f31a0c..120131b108e 100644
--- a/cpp/demo/Ice/invoke/Client.cpp
+++ b/cpp/demo/Ice/invoke/Client.cpp
@@ -7,29 +7,28 @@
//
// **********************************************************************
-#include <Ice/Ice.h>
+#include <Ice/Application.h>
#include <Printer.h>
using namespace std;
using namespace Demo;
-void
-menu()
+class InvokeClient : public Ice::Application
{
- cout <<
- "usage:\n"
- "1: print string\n"
- "2: print string sequence\n"
- "3: print dictionary\n"
- "4: print enum\n"
- "5: print struct\n"
- "6: print struct sequence\n"
- "7: print class\n"
- "8: get values\n"
- "9: throw exception\n"
- "s: shutdown server\n"
- "x: exit\n"
- "?: help\n";
+public:
+
+ virtual int run(int, char*[]);
+
+private:
+
+ void menu();
+};
+
+int
+main(int argc, char* argv[])
+{
+ InvokeClient app;
+ return app.main(argc, argv, "config");
}
static ostream&
@@ -51,9 +50,9 @@ operator<<(ostream& out, Demo::Color c)
}
int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+InvokeClient::run(int argc, char* argv[])
{
- Ice::PropertiesPtr properties = communicator->getProperties();
+ Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "Printer.Proxy";
string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
@@ -62,7 +61,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_FAILURE;
}
- Ice::ObjectPrx obj = communicator->stringToProxy(proxy);
+ Ice::ObjectPrx obj = communicator()->stringToProxy(proxy);
menu();
@@ -79,7 +78,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Marshal the in parameter.
//
Ice::ByteSeq inParams, outParams;
- Ice::OutputStreamPtr out = Ice::createOutputStream(communicator);
+ Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
out->writeString("The streaming API works!");
out->finished(inParams);
@@ -97,7 +96,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Marshal the in parameter.
//
Ice::ByteSeq inParams, outParams;
- Ice::OutputStreamPtr out = Ice::createOutputStream(communicator);
+ Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
Demo::StringSeq arr;
arr.push_back("The");
arr.push_back("streaming");
@@ -120,7 +119,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Marshal the in parameter.
//
Ice::ByteSeq inParams, outParams;
- Ice::OutputStreamPtr out = Ice::createOutputStream(communicator);
+ Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
Demo::StringDict dict;
dict["The"] = "streaming";
dict["API"] = "works!";
@@ -141,7 +140,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Marshal the in parameter.
//
Ice::ByteSeq inParams, outParams;
- Ice::OutputStreamPtr out = Ice::createOutputStream(communicator);
+ Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
Demo::ice_writeColor(out, Demo::green);
out->finished(inParams);
@@ -159,7 +158,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Marshal the in parameter.
//
Ice::ByteSeq inParams, outParams;
- Ice::OutputStreamPtr out = Ice::createOutputStream(communicator);
+ Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
Demo::Structure s;
s.name = "red";
s.value = Demo::red;
@@ -180,7 +179,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Marshal the in parameter.
//
Ice::ByteSeq inParams, outParams;
- Ice::OutputStreamPtr out = Ice::createOutputStream(communicator);
+ Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
Demo::StructureSeq arr;
arr.push_back(Demo::Structure());
arr.back().name = "red";
@@ -208,7 +207,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Marshal the in parameter.
//
Ice::ByteSeq inParams, outParams;
- Ice::OutputStreamPtr out = Ice::createOutputStream(communicator);
+ Ice::OutputStreamPtr out = Ice::createOutputStream(communicator());
Demo::CPtr c = new Demo::C;
c->s.name = "blue";
c->s.value = Demo::blue;
@@ -239,7 +238,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
// Unmarshal the results.
//
- Ice::InputStreamPtr in = Ice::createInputStream(communicator, outParams);
+ Ice::InputStreamPtr in = Ice::createInputStream(communicator(), outParams);
Demo::CPtr c;
Demo::ice_readC(in, c);
string str = in->readString();
@@ -259,7 +258,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
continue;
}
- Ice::InputStreamPtr in = Ice::createInputStream(communicator, outParams);
+ Ice::InputStreamPtr in = Ice::createInputStream(communicator(), outParams);
try
{
in->throwException();
@@ -302,37 +301,21 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_SUCCESS;
}
-int
-main(int argc, char* argv[])
+void
+InvokeClient::menu()
{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, argv, properties);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
-
- return status;
+ cout <<
+ "usage:\n"
+ "1: print string\n"
+ "2: print string sequence\n"
+ "3: print dictionary\n"
+ "4: print enum\n"
+ "5: print struct\n"
+ "6: print struct sequence\n"
+ "7: print class\n"
+ "8: get values\n"
+ "9: throw exception\n"
+ "s: shutdown server\n"
+ "x: exit\n"
+ "?: help\n";
}
diff --git a/cpp/demo/Ice/invoke/Server.cpp b/cpp/demo/Ice/invoke/Server.cpp
index 0847b57f15a..d2540ceaf1f 100644
--- a/cpp/demo/Ice/invoke/Server.cpp
+++ b/cpp/demo/Ice/invoke/Server.cpp
@@ -7,53 +7,31 @@
//
// **********************************************************************
-#include <Ice/Ice.h>
#include <PrinterI.h>
+#include <Ice/Application.h>
using namespace std;
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+class InvokeServer : public Ice::Application
{
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Printer");
- Ice::ObjectPtr object = new PrinterI;
- adapter->add(object, Ice::stringToIdentity("printer"));
- adapter->activate();
- communicator->waitForShutdown();
- return EXIT_SUCCESS;
-}
+public:
+
+ virtual int run(int, char*[]);
+};
int
main(int argc, char* argv[])
{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, argv, properties);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
+ InvokeServer app;
+ return app.main(argc, argv, "config");
+}
- return status;
+int
+InvokeServer::run(int argc, char* argv[])
+{
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Printer");
+ adapter->add(new PrinterI, Ice::stringToIdentity("printer"));
+ adapter->activate();
+ communicator()->waitForShutdown();
+ return EXIT_SUCCESS;
}
diff --git a/cpp/demo/Ice/latency/Client.cpp b/cpp/demo/Ice/latency/Client.cpp
index af9fc321628..549649a010e 100644
--- a/cpp/demo/Ice/latency/Client.cpp
+++ b/cpp/demo/Ice/latency/Client.cpp
@@ -7,16 +7,30 @@
//
// **********************************************************************
-#include <Ice/Ice.h>
+#include <Ice/Application.h>
#include <Latency.h>
using namespace std;
using namespace Demo;
+class LatencyClient : public Ice::Application
+{
+public:
+
+ virtual int run(int, char*[]);
+};
+
int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+main(int argc, char* argv[])
{
- Ice::PropertiesPtr properties = communicator->getProperties();
+ LatencyClient app;
+ return app.main(argc, argv, "config");
+}
+
+int
+LatencyClient::run(int argc, char* argv[])
+{
+ Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "Latency.Ping";
std::string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
@@ -25,7 +39,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_FAILURE;
}
- Ice::ObjectPrx base = communicator->stringToProxy(proxy);
+ Ice::ObjectPrx base = communicator()->stringToProxy(proxy);
PingPrx ping = PingPrx::checkedCast(base);
if(!ping)
{
@@ -52,38 +66,3 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_SUCCESS;
}
-
-int
-main(int argc, char* argv[])
-{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, argv, properties);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
-
- return status;
-}
diff --git a/cpp/demo/Ice/latency/README b/cpp/demo/Ice/latency/README
new file mode 100644
index 00000000000..9d0248f3ebc
--- /dev/null
+++ b/cpp/demo/Ice/latency/README
@@ -0,0 +1,10 @@
+A simple latency test that measures the basic call dispatch delay of
+Ice.
+
+To run the demo, first start the server:
+
+$ server
+
+In a separate window, start the client:
+
+$ client
diff --git a/cpp/demo/Ice/latency/Server.cpp b/cpp/demo/Ice/latency/Server.cpp
index 93bc1a7fc26..b030c3bdbb5 100644
--- a/cpp/demo/Ice/latency/Server.cpp
+++ b/cpp/demo/Ice/latency/Server.cpp
@@ -7,54 +7,33 @@
//
// **********************************************************************
-#include <Ice/Ice.h>
+#include <Ice/Application.h>
#include <Latency.h>
using namespace std;
using namespace Demo;
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+class LatencyServer : public Ice::Application
{
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Latency");
- Ice::ObjectPtr object = new Ping;
- adapter->add(object, Ice::stringToIdentity("ping"));
- adapter->activate();
- communicator->waitForShutdown();
- return EXIT_SUCCESS;
-}
+public:
+
+ virtual int run(int, char*[]);
+};
int
main(int argc, char* argv[])
{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, argv, properties);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
+ LatencyServer app;
+ return app.main(argc, argv, "config");
+}
- return status;
+int
+LatencyServer::run(int argc, char* argv[])
+{
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Latency");
+ Ice::ObjectPtr object = new Ping;
+ adapter->add(new Ping, Ice::stringToIdentity("ping"));
+ adapter->activate();
+ communicator()->waitForShutdown();
+ return EXIT_SUCCESS;
}
diff --git a/cpp/demo/Ice/nested/Client.cpp b/cpp/demo/Ice/nested/Client.cpp
index f9c7d8cf2f6..38f419b9e6e 100644
--- a/cpp/demo/Ice/nested/Client.cpp
+++ b/cpp/demo/Ice/nested/Client.cpp
@@ -7,14 +7,13 @@
//
// **********************************************************************
-#include <Ice/Application.h>
#include <NestedI.h>
+#include <Ice/Application.h>
using namespace std;
-using namespace Ice;
using namespace Demo;
-class NestedClient : public Application
+class NestedClient : public Ice::Application
{
public:
@@ -31,7 +30,7 @@ main(int argc, char* argv[])
int
NestedClient::run(int argc, char* argv[])
{
- PropertiesPtr properties = communicator()->getProperties();
+ Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "Nested.Client.NestedServer";
std::string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
@@ -40,7 +39,7 @@ NestedClient::run(int argc, char* argv[])
return EXIT_FAILURE;
}
- ObjectPrx base = communicator()->stringToProxy(proxy);
+ Ice::ObjectPrx base = communicator()->stringToProxy(proxy);
NestedPrx nested = NestedPrx::checkedCast(base);
if(!nested)
{
@@ -48,7 +47,7 @@ NestedClient::run(int argc, char* argv[])
return EXIT_FAILURE;
}
- ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Nested.Client");
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Nested.Client");
NestedPrx self = NestedPrx::uncheckedCast(adapter->createProxy(Ice::stringToIdentity("nestedClient")));
adapter->add(new NestedI(self), Ice::stringToIdentity("nestedClient"));
adapter->activate();
@@ -72,7 +71,7 @@ NestedClient::run(int argc, char* argv[])
nested->nestedCall(level, self);
}
}
- catch(const Exception& ex)
+ catch(const Ice::Exception& ex)
{
cerr << ex << endl;
}
diff --git a/cpp/demo/Ice/nested/NestedI.h b/cpp/demo/Ice/nested/NestedI.h
index 7117bf9b402..0e6777ea2cc 100644
--- a/cpp/demo/Ice/nested/NestedI.h
+++ b/cpp/demo/Ice/nested/NestedI.h
@@ -21,7 +21,7 @@ public:
private:
- Demo::NestedPrx _self;
+ const Demo::NestedPrx _self;
};
#endif
diff --git a/cpp/demo/Ice/nested/README b/cpp/demo/Ice/nested/README
new file mode 100644
index 00000000000..5f1b1b9a044
--- /dev/null
+++ b/cpp/demo/Ice/nested/README
@@ -0,0 +1,11 @@
+A demo to illustrate how nested callbacks work, and how the size of
+the thread pool affects the maximum nesting depth.
+
+To run the demo, first start the server:
+
+$ server
+
+In a separate window, start the client:
+
+$ client
+
diff --git a/cpp/demo/Ice/nested/Server.cpp b/cpp/demo/Ice/nested/Server.cpp
index 39cbfbd2faa..21c90e32baf 100644
--- a/cpp/demo/Ice/nested/Server.cpp
+++ b/cpp/demo/Ice/nested/Server.cpp
@@ -7,14 +7,13 @@
//
// **********************************************************************
-#include <Ice/Application.h>
#include <NestedI.h>
+#include <Ice/Application.h>
using namespace std;
-using namespace Ice;
using namespace Demo;
-class NestedServer : public Application
+class NestedServer : public Ice::Application
{
public:
@@ -31,7 +30,7 @@ main(int argc, char* argv[])
int
NestedServer::run(int argc, char* argv[])
{
- ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Nested.Server");
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Nested.Server");
NestedPrx self = NestedPrx::uncheckedCast(adapter->createProxy(Ice::stringToIdentity("nestedServer")));
adapter->add(new NestedI(self), Ice::stringToIdentity("nestedServer"));
adapter->activate();
diff --git a/cpp/demo/Ice/throughput/Client.cpp b/cpp/demo/Ice/throughput/Client.cpp
index 3916c62088b..71662073296 100644
--- a/cpp/demo/Ice/throughput/Client.cpp
+++ b/cpp/demo/Ice/throughput/Client.cpp
@@ -13,34 +13,28 @@
using namespace std;
using namespace Demo;
-void
-menu()
+class ThroughputClient : public Ice::Application
{
- 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";
+public:
+
+ virtual int run(int, char*[]);
+
+private:
+
+ void menu();
+};
+
+int
+main(int argc, char* argv[])
+{
+ ThroughputClient app;
+ return app.main(argc, argv, "config");
}
int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+ThroughputClient::run(int argc, char* argv[])
{
- Ice::PropertiesPtr properties = communicator->getProperties();
+ Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "Throughput.Throughput";
std::string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
@@ -49,7 +43,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_FAILURE;
}
- Ice::ObjectPrx base = communicator->stringToProxy(proxy);
+ Ice::ObjectPrx base = communicator()->stringToProxy(proxy);
ThroughputPrx throughput = ThroughputPrx::checkedCast(base);
if(!throughput)
{
@@ -387,37 +381,26 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_SUCCESS;
}
-int
-main(int argc, char* argv[])
+void
+ThroughputClient::menu()
{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, argv, properties);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
-
- return status;
+ 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";
}
diff --git a/cpp/demo/Ice/throughput/Makefile b/cpp/demo/Ice/throughput/Makefile
index ef4eb479c6b..65c6d7eaed2 100644
--- a/cpp/demo/Ice/throughput/Makefile
+++ b/cpp/demo/Ice/throughput/Makefile
@@ -18,7 +18,8 @@ OBJS = Throughput.o
COBJS = Client.o
-SOBJS = Server.o
+SOBJS = ThroughputI.o \
+ Server.o
SRCS = $(OBJS:.o=.cpp) \
$(COBJS:.o=.cpp) \
diff --git a/cpp/demo/Ice/throughput/README b/cpp/demo/Ice/throughput/README
new file mode 100644
index 00000000000..edba7975292
--- /dev/null
+++ b/cpp/demo/Ice/throughput/README
@@ -0,0 +1,15 @@
+A simple throughput demo that allows you to send sequences of various
+types between client and server and to measure the maximum bandwidth
+that can be achieved using serialized synchronous requests.
+
+To run the demo, first start the server:
+
+$ server
+
+In a separate window, start the client:
+
+$ client
+
+
+
+
diff --git a/cpp/demo/Ice/throughput/Server.cpp b/cpp/demo/Ice/throughput/Server.cpp
index af42c47e234..30df0952c98 100644
--- a/cpp/demo/Ice/throughput/Server.cpp
+++ b/cpp/demo/Ice/throughput/Server.cpp
@@ -7,52 +7,31 @@
//
// **********************************************************************
-#include <ThroughputI.h>
+#include <ThroughputI.h>
+#include <Ice/Application.h>
using namespace std;
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+class ThroughputServer : public Ice::Application
{
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Throughput");
- Ice::ObjectPtr object = new ThroughputI;
- adapter->add(object, Ice::stringToIdentity("throughput"));
- adapter->activate();
- communicator->waitForShutdown();
- return EXIT_SUCCESS;
-}
+public:
+
+ virtual int run(int, char*[]);
+};
int
main(int argc, char* argv[])
{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::PropertiesPtr properties = Ice::createProperties();
- properties->load("config");
- communicator = Ice::initializeWithProperties(argc, argv, properties);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
+ ThroughputServer app;
+ return app.main(argc, argv, "config");
+}
- return status;
+int
+ThroughputServer::run(int argc, char* argv[])
+{
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Throughput");
+ adapter->add(new ThroughputI, Ice::stringToIdentity("throughput"));
+ adapter->activate();
+ communicator()->waitForShutdown();
+ return EXIT_SUCCESS;
}
diff --git a/cpp/demo/Ice/throughput/ThroughputI.cpp b/cpp/demo/Ice/throughput/ThroughputI.cpp
new file mode 100644
index 00000000000..21ca82917cf
--- /dev/null
+++ b/cpp/demo/Ice/throughput/ThroughputI.cpp
@@ -0,0 +1,105 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <ThroughputI.h>
+#include <Ice/Ice.h>
+
+ThroughputI::ThroughputI() :
+ _byteSeq(Demo::ByteSeqSize, 0),
+ _stringSeq(Demo::StringSeqSize, "hello"),
+ _structSeq(Demo::StringDoubleSeqSize),
+ _fixedSeq(Demo::FixedSeqSize)
+{
+ int i;
+ for(i = 0; i < Demo::StringDoubleSeqSize; ++i)
+ {
+ _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;
+ }
+}
+
+void
+ThroughputI::sendByteSeq(const Demo::ByteSeq&, const Ice::Current&)
+{
+}
+
+Demo::ByteSeq
+ThroughputI::recvByteSeq(const Ice::Current&)
+{
+ return _byteSeq;
+}
+
+Demo::ByteSeq
+ThroughputI::echoByteSeq(const Demo::ByteSeq& seq, const Ice::Current&)
+{
+ return seq;
+}
+
+void
+ThroughputI::sendStringSeq(const Demo::StringSeq&, const Ice::Current&)
+{
+}
+
+Demo::StringSeq
+ThroughputI::recvStringSeq(const Ice::Current&)
+{
+ return _stringSeq;
+}
+
+Demo::StringSeq
+ThroughputI::echoStringSeq(const Demo::StringSeq& seq, const Ice::Current&)
+{
+ return seq;
+}
+
+void
+ThroughputI::sendStructSeq(const Demo::StringDoubleSeq&, const Ice::Current&)
+{
+}
+
+Demo::StringDoubleSeq
+ThroughputI::recvStructSeq(const Ice::Current&)
+{
+ return _structSeq;
+}
+
+Demo::StringDoubleSeq
+ThroughputI::echoStructSeq(const Demo::StringDoubleSeq& seq, const Ice::Current&)
+{
+ return seq;
+}
+
+void
+ThroughputI::sendFixedSeq(const Demo::FixedSeq&, const Ice::Current&)
+{
+}
+
+Demo::FixedSeq
+ThroughputI::recvFixedSeq(const Ice::Current&)
+{
+ return _fixedSeq;
+}
+
+Demo::FixedSeq
+ThroughputI::echoFixedSeq(const Demo::FixedSeq& seq, const Ice::Current&)
+{
+ return seq;
+}
+
+void
+ThroughputI::shutdown(const Ice::Current& c)
+{
+ c.adapter->getCommunicator()->shutdown();
+}
diff --git a/cpp/demo/Ice/throughput/ThroughputI.h b/cpp/demo/Ice/throughput/ThroughputI.h
index 4af80dd3a58..463b9f649b0 100644
--- a/cpp/demo/Ice/throughput/ThroughputI.h
+++ b/cpp/demo/Ice/throughput/ThroughputI.h
@@ -10,106 +10,27 @@
#ifndef THROUGHPUT_I_H
#define THROUGHPUT_I_H
-#include <Ice/Ice.h>
#include <Throughput.h>
class ThroughputI : public Demo::Throughput
{
public:
- ThroughputI() :
- _byteSeq(Demo::ByteSeqSize, 0),
- _stringSeq(Demo::StringSeqSize, "hello"),
- _structSeq(Demo::StringDoubleSeqSize),
- _fixedSeq(Demo::FixedSeqSize)
- {
- int i;
- for(i = 0; i < Demo::StringDoubleSeqSize; ++i)
- {
- _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;
- }
- }
-
- virtual void
- sendByteSeq(const Demo::ByteSeq&, const Ice::Current&)
- {
- }
-
- virtual Demo::ByteSeq
- recvByteSeq(const Ice::Current&)
- {
- return _byteSeq;
- }
-
- virtual Demo::ByteSeq
- echoByteSeq(const Demo::ByteSeq& seq, const Ice::Current&)
- {
- return seq;
- }
-
- virtual void
- sendStringSeq(const Demo::StringSeq&, const Ice::Current&)
- {
- }
-
- virtual Demo::StringSeq
- recvStringSeq(const Ice::Current&)
- {
- return _stringSeq;
- }
-
- virtual Demo::StringSeq
- echoStringSeq(const Demo::StringSeq& seq, const Ice::Current&)
- {
- return seq;
- }
-
- virtual void
- sendStructSeq(const Demo::StringDoubleSeq&, const Ice::Current&)
- {
- }
-
- virtual Demo::StringDoubleSeq
- recvStructSeq(const Ice::Current&)
- {
- return _structSeq;
- }
-
- virtual Demo::StringDoubleSeq
- echoStructSeq(const Demo::StringDoubleSeq& seq, const Ice::Current&)
- {
- return seq;
- }
-
- virtual void
- sendFixedSeq(const Demo::FixedSeq&, const Ice::Current&)
- {
- }
-
- virtual Demo::FixedSeq
- recvFixedSeq(const Ice::Current&)
- {
- return _fixedSeq;
- }
-
- virtual Demo::FixedSeq
- echoFixedSeq(const Demo::FixedSeq& seq, const Ice::Current&)
- {
- return seq;
- }
-
- virtual void
- shutdown(const Ice::Current& c)
- {
- c.adapter->getCommunicator()->shutdown();
- }
+ ThroughputI();
+
+ virtual void sendByteSeq(const Demo::ByteSeq&, const Ice::Current&);
+ virtual Demo::ByteSeq recvByteSeq(const Ice::Current&);
+ virtual Demo::ByteSeq echoByteSeq(const Demo::ByteSeq& seq, const Ice::Current&);
+ virtual void sendStringSeq(const Demo::StringSeq&, const Ice::Current&);
+ virtual Demo::StringSeq recvStringSeq(const Ice::Current&);
+ virtual Demo::StringSeq echoStringSeq(const Demo::StringSeq& seq, const Ice::Current&);
+ virtual void sendStructSeq(const Demo::StringDoubleSeq&, const Ice::Current&);
+ virtual Demo::StringDoubleSeq recvStructSeq(const Ice::Current&);
+ virtual Demo::StringDoubleSeq echoStructSeq(const Demo::StringDoubleSeq& seq, const Ice::Current&);
+ virtual void sendFixedSeq(const Demo::FixedSeq&, const Ice::Current&);
+ virtual Demo::FixedSeq recvFixedSeq(const Ice::Current&);
+ virtual Demo::FixedSeq echoFixedSeq(const Demo::FixedSeq& seq, const Ice::Current&);
+ virtual void shutdown(const Ice::Current& c);
private:
diff --git a/cpp/demo/Ice/throughput/throughputS.dsp b/cpp/demo/Ice/throughput/throughputS.dsp
index 1808db90429..b0d5e4b2354 100644
--- a/cpp/demo/Ice/throughput/throughputS.dsp
+++ b/cpp/demo/Ice/throughput/throughputS.dsp
@@ -97,6 +97,10 @@ SOURCE=.\Server.cpp
SOURCE=.\Throughput.cpp
# End Source File
+# Begin Source File
+
+SOURCE=.\ThroughputI.cpp
+# End Source File
# End Group
# Begin Group "Header Files"
diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp
index 2be467eb6c5..dd62275315a 100644
--- a/cpp/demo/Ice/value/Client.cpp
+++ b/cpp/demo/Ice/value/Client.cpp
@@ -19,10 +19,6 @@ class ValueClient : public Ice::Application
public:
virtual int run(int, char*[]);
-
-private:
-
- void menu();
};
int
diff --git a/cpp/demo/Ice/value/README b/cpp/demo/Ice/value/README
new file mode 100644
index 00000000000..2fdfb9e3260
--- /dev/null
+++ b/cpp/demo/Ice/value/README
@@ -0,0 +1,14 @@
+This demo shows how to use classes, class factories, and the
+difference between local and remote invocations of class operations.
+
+To run the demo, first start the server:
+
+$ server
+
+In a separate window, start the client:
+
+$ client
+
+
+
+
diff --git a/cpp/demo/Ice/value/Server.cpp b/cpp/demo/Ice/value/Server.cpp
index ea5fb5ea92e..867e4bc4617 100644
--- a/cpp/demo/Ice/value/Server.cpp
+++ b/cpp/demo/Ice/value/Server.cpp
@@ -7,8 +7,8 @@
//
// **********************************************************************
-#include <Ice/Ice.h>
#include <ValueI.h>
+#include <Ice/Ice.h>
using namespace std;
@@ -30,8 +30,7 @@ int
ValueServer::run(int argc, char* argv[])
{
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Value");
- Ice::ObjectPtr object = new InitialI(adapter);
- adapter->add(object, Ice::stringToIdentity("initial"));
+ adapter->add(new InitialI(adapter), Ice::stringToIdentity("initial"));
adapter->activate();
communicator()->waitForShutdown();
return EXIT_SUCCESS;
diff --git a/cpp/demo/Ice/value/ValueI.cpp b/cpp/demo/Ice/value/ValueI.cpp
index eef680edab9..763aaaa4fe6 100644
--- a/cpp/demo/Ice/value/ValueI.cpp
+++ b/cpp/demo/Ice/value/ValueI.cpp
@@ -13,19 +13,16 @@
using namespace std;
using namespace Demo;
-InitialI::InitialI(::Ice::ObjectAdapterPtr adapter)
+InitialI::InitialI(const Ice::ObjectAdapterPtr& adapter) :
+ _simple(new Simple),
+ _printer(new PrinterI),
+ _printerProxy(PrinterPrx::uncheckedCast(adapter->addWithUUID(_printer))),
+ _derivedPrinter(new DerivedPrinterI)
{
- _simple = new Simple;
_simple->message = "a message 4 u";
-
- _printer = new PrinterI;
_printer->message = "Ice rulez!";
- _printerProxy = PrinterPrx::uncheckedCast(adapter->addWithUUID(_printer));
-
- _derivedPrinter = new DerivedPrinterI;
_derivedPrinter->message = _printer->message;
_derivedPrinter->derivedMessage = "a derived message 4 u";
- adapter->addWithUUID(_derivedPrinter);
}
SimplePtr
diff --git a/cpp/demo/Ice/value/ValueI.h b/cpp/demo/Ice/value/ValueI.h
index 9808499a145..54944cb50a7 100644
--- a/cpp/demo/Ice/value/ValueI.h
+++ b/cpp/demo/Ice/value/ValueI.h
@@ -12,33 +12,33 @@
#include <Value.h>
-class InitialI : public ::Demo::Initial
+class InitialI : public Demo::Initial
{
public:
- InitialI(::Ice::ObjectAdapterPtr);
+ InitialI(const Ice::ObjectAdapterPtr&);
- virtual ::Demo::SimplePtr getSimple(const Ice::Current&);
- virtual void getPrinter(::Demo::PrinterPtr&, ::Demo::PrinterPrx&, const Ice::Current&);
- virtual ::Demo::PrinterPtr getDerivedPrinter(const Ice::Current&);
+ virtual Demo::SimplePtr getSimple(const Ice::Current&);
+ virtual void getPrinter(::Demo::PrinterPtr&, Demo::PrinterPrx&, const Ice::Current&);
+ virtual Demo::PrinterPtr getDerivedPrinter(const Ice::Current&);
virtual void throwDerivedPrinter(const Ice::Current&);
private:
- ::Demo::SimplePtr _simple;
- ::Demo::PrinterPtr _printer;
- ::Demo::PrinterPrx _printerProxy;
- ::Demo::DerivedPrinterPtr _derivedPrinter;
+ const Demo::SimplePtr _simple;
+ const Demo::PrinterPtr _printer;
+ const Demo::PrinterPrx _printerProxy;
+ const Demo::DerivedPrinterPtr _derivedPrinter;
};
-class PrinterI : virtual public ::Demo::Printer
+class PrinterI : virtual public Demo::Printer
{
public:
virtual void printBackwards(const Ice::Current&);
};
-class DerivedPrinterI : virtual public ::Demo::DerivedPrinter, virtual public PrinterI
+class DerivedPrinterI : virtual public Demo::DerivedPrinter, virtual public PrinterI
{
public: