summaryrefslogtreecommitdiff
path: root/TAO/tests/POA/Generic_Servant/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/POA/Generic_Servant/client.cpp')
-rw-r--r--TAO/tests/POA/Generic_Servant/client.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/TAO/tests/POA/Generic_Servant/client.cpp b/TAO/tests/POA/Generic_Servant/client.cpp
new file mode 100644
index 00000000000..2d8f5ae42d4
--- /dev/null
+++ b/TAO/tests/POA/Generic_Servant/client.cpp
@@ -0,0 +1,76 @@
+#include "ace/streams.h"
+#include "ace/Get_Opt.h"
+#include "FooC.h"
+
+static char *ior = 0;
+
+static int
+parse_args (int argc, char **argv)
+{
+ ACE_Get_Opt get_opts (argc, argv, "k:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ ior = get_opts.optarg;
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s"
+ "-k IOR"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ if (ior == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Please specify the IOR for the servant"), -1);
+
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ CORBA::Environment env;
+
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("CORBA::ORB_init");
+ return -1;
+ }
+
+ parse_args (argc, argv);
+
+ CORBA::Object_var object = orb->string_to_object (ior, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("CORBA::ORB::string_to_object");
+ return -1;
+ }
+
+ Foo_var foo = Foo::_narrow (object.in (), env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("Foo::_narrow");
+ return -1;
+ }
+
+ CORBA::Long result = foo->doit (env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("Foo::doit");
+ return -1;
+ }
+
+ cout << result << endl;
+
+ return 0;
+}
+