summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsergio <sergio@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-11-10 01:26:09 +0000
committersergio <sergio@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-11-10 01:26:09 +0000
commit2c53fa4b92672d26392696c21e7591b360bf0dda (patch)
treeac67ab3ab186dcbb61a36ce47e4407d33d331c32
parent728afa289b2cb993d49c66794fb02513b3635981 (diff)
downloadATCD-2c53fa4b92672d26392696c21e7591b360bf0dda.tar.gz
*** empty log message ***
-rw-r--r--TAO/ChangeLog-98c6
-rw-r--r--TAO/tests/Cubit/TAO/DII_Cubit/clnt.cpp692
-rw-r--r--TAO/tests/Cubit/TAO/DII_Cubit/clnt.h126
3 files changed, 514 insertions, 310 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index fe4a66d21bf..a5153aa51e0 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,5 +1,11 @@
Sun Nov 9 16:05:56 1997 Sergio Flores <sergio@macarena.cs.wustl.edu>
+ * tests/Cubit/TAO/DII_Cubit/clnt.cpp: *
+ tests/Cubit/TAO/DII_Cubit/clnt.h: Added clnt.h and restructured
+ the code so it is similar to the IDL_Cubit example. It doesn't,
+ however, have the same options because the DII example uses an ior
+ as input.
+
* tao/debug.cpp: Added dummy function to get rid of
"'debug_stream' defined but not used" warning.
diff --git a/TAO/tests/Cubit/TAO/DII_Cubit/clnt.cpp b/TAO/tests/Cubit/TAO/DII_Cubit/clnt.cpp
index 347a388ce4e..5974661ceed 100644
--- a/TAO/tests/Cubit/TAO/DII_Cubit/clnt.cpp
+++ b/TAO/tests/Cubit/TAO/DII_Cubit/clnt.cpp
@@ -1,29 +1,66 @@
-// @ (#)clnt.cpp 1.2 05/14/97 Copyright 1994-1995 by Sun Microsystems
-// Inc. All Rights Reserved
+// $Id$
+
+// ============================================================================
//
-// TEST: Simple "cube" client, calling hand-crafted stubs.
+// = LIBRARY
+// TAO/tests/DII_Cubit
//
-// Modified version of Cubit Example written by Sun Microsystems Inc.
-// Modified by: Brian Mendel
-
+// = FILENAME
+// clnt.cpp
+//
+// = DESCRIPTION
+// This class implements a simple "cube" CORBA client for the Cubit
+// example using stubs generated by the TAO ORB IDL compiler.
+//
+// = AUTHORS
+// Andy Gokhale, Sumedh Mungee, and Sergio Flores-Gaitan
+//
+// ============================================================================
#include "ace/Profile_Timer.h"
#include "ace/Get_Opt.h"
#include "tao/corba.h"
#include "cubitC.h"
+#include "clnt.h"
+
+// Constructor.
+
+Cubit_Client::Cubit_Client (void)
+ : loop_count_ (1),
+ exit_later_ (0),
+ objref_ (CORBA::Object::_nil ()),
+ cubit_ (Cubit::_nil ()),
+ orb_ptr_ (0),
+ call_count_ (0),
+ error_count_ (0),
+ TAO_arg_ior_ (0)
+{
+}
+
+// destructor
-inline int func (unsigned i) { return i - 117; }
+Cubit_Client::~Cubit_Client (void)
+{
+ // Free resources
+ CORBA::release (this->cubit_);
+ CORBA::release (this->objref_);
+ CORBA::release (this->orb_ptr_);
+}
-// Global variables
-static const char *TAO_arg_ior = 0;
-static u_int loop_count = 1;
-static int exit_later = 0;
+// Simple function that returns the substraction of 117 from the
+// parameter.
+
+int
+Cubit_Client::func (u_int i)
+{
+ return i - 117;
+}
// Parses the command line arguments and returns an error status.
-static int
-parse_args (int argc, char *argv[])
+int
+Cubit_Client::parse_args (void)
{
- ACE_Get_Opt opts (argc, argv, "dn:O:x");
+ ACE_Get_Opt opts (argc_, argv_, "dn:O:x");
int c;
while ((c = opts ()) != -1)
@@ -33,13 +70,13 @@ parse_args (int argc, char *argv[])
TAO_debug_level++;
break;
case 'n': // loop count
- loop_count = (u_int) ACE_OS::atoi (opts.optarg);
+ loop_count_ = (u_int) ACE_OS::atoi (opts.optarg);
break;
case 'O': // stringified objref
- TAO_arg_ior = ACE_OS::strdup (opts.optarg);
+ TAO_arg_ior_ = ACE_OS::strdup (opts.optarg);
break;
case 'x':
- exit_later++;
+ exit_later_++;
break;
case '?':
default:
@@ -49,36 +86,32 @@ parse_args (int argc, char *argv[])
" [-n loopcount]"
" [-O objref]"
" [-x]"
- "\n", argv [0]
- ), 1);
+ "\n", argv_ [0]
+ ), -1);
}
return 0; // Indicates successful parsing of command line
}
-static void
-cube_union_stub (u_int i,
- u_int &call_count,
- u_int &error_count,
- CORBA::Object_ptr objref,
- CORBA::Environment &env)
+void
+Cubit_Client::cube_union_stub (void)
{
- Cubit_ptr cubit = Cubit::_narrow (objref);
+ this->cubit_ = Cubit::_narrow (this->objref_);
Cubit_oneof u, *r;
- call_count++;
+ this->call_count_++;
u._disc = e_2nd;
u.l = 3;
// Cube a "union" ...
- r = cubit->Cubit_cube_union (u, env);
+ r = this->cubit_->Cubit_cube_union (u, this->env_);
- if (env.exception () != 0)
+ if (this->env_.exception () != 0)
{
- env.print_exception ("from cube_union");
- error_count++;
+ this->env_.print_exception ("from cube_union");
+ this->error_count_++;
}
else
{
@@ -88,30 +121,32 @@ cube_union_stub (u_int i,
if (u.l != r->l)
{
ACE_DEBUG ((LM_DEBUG, "** cube_union ERROR\n"));
- error_count++;
+ this->error_count_++;
}
delete r;
}
- call_count++;
+ this->call_count_++;
u._disc = e_5th;
- u.cm.l = func (i);
- u.cm.s = func (i);
- u.cm.o = func (i);
+#if 0
+ u.cm.l = this->func (i);
+ u.cm.s = this->func (i);
+ u.cm.o = this->func (i);
+#endif
u.cm.l = 7;
u.cm.s = 5;
u.cm.o = 3;
// Cube another "union" which uses the default arm ...
- r = cubit->Cubit_cube_union (u, env);
+ r = this->cubit_->Cubit_cube_union (u, this->env_);
- if (env.exception () != 0)
+ if (this->env_.exception () != 0)
{
- env.print_exception ("from cube_union");
- error_count++;
+ this->env_.print_exception ("from cube_union");
+ this->error_count_++;
}
else
{
@@ -125,31 +160,28 @@ cube_union_stub (u_int i,
|| u.cm.o != r->cm.o)
{
ACE_DEBUG ((LM_DEBUG, "** cube_union ERROR\n"));
- error_count++;
+ this->error_count_++;
}
delete r;
}
}
-static void
-cube_union_dii (u_int &call_count,
- u_int &error_count,
- CORBA::Object_ptr objref,
- CORBA::Environment &env)
+void
+Cubit_Client::cube_union_dii (void)
{
// Create the request ...
CORBA::Request_ptr req;
- call_count++;
+ this->call_count_++;
- req = objref->_request ((const CORBA::String) "cube_union", env);
+ req = this->objref_->_request ((const CORBA::String) "cube_union", this->env_);
- if (env.exception () != 0)
+ if (this->env_.exception () != 0)
{
- error_count++;
+ this->error_count_++;
- env.print_exception ("cube_union_dii request create");
+ this->env_.print_exception ("cube_union_dii request create");
return;
}
@@ -163,22 +195,22 @@ cube_union_dii (u_int &call_count,
CORBA::Any tmp_arg (TC_Cubit_oneof, &u, CORBA::B_FALSE);
- req->arguments ()->add_value (0, tmp_arg, CORBA::ARG_IN, env);
+ req->arguments ()->add_value (0, tmp_arg, CORBA::ARG_IN, this->env_);
- if (env.exception () != 0)
+ if (this->env_.exception () != 0)
{
- error_count++;
- env.print_exception ("cube_union_dii request arg add");
+ this->error_count_++;
+ this->env_.print_exception ("cube_union_dii request arg add");
CORBA::release (req);
return;
}
- req->result ()->value ()->replace (TC_Cubit_oneof, 0, CORBA::B_TRUE, env);
+ req->result ()->value ()->replace (TC_Cubit_oneof, 0, CORBA::B_TRUE, this->env_);
- if (env.exception () != 0)
+ if (this->env_.exception () != 0)
{
- error_count++;
- env.print_exception ("cube_union_dii result type");
+ this->error_count_++;
+ this->env_.print_exception ("cube_union_dii result type");
CORBA::release (req);
return;
}
@@ -189,7 +221,7 @@ cube_union_dii (u_int &call_count,
if (req->env ()->exception () != 0)
{
- error_count++;
+ this->error_count_++;
req->env ()->print_exception ("cube_union_dii invoke");
CORBA::release (req);
return;
@@ -199,7 +231,7 @@ cube_union_dii (u_int &call_count,
if (r->cm.o != 27 || r->cm.l != 125 || r->cm.s != -343)
{
- error_count++;
+ this->error_count_++;
ACE_ERROR ((LM_ERROR, "cube_union_dii -- bad results\n"));
}
else
@@ -208,217 +240,299 @@ cube_union_dii (u_int &call_count,
CORBA::release (req);
}
+// Cube an octet
-class ACE_winsock_proper_shutdown
-// @@ We need this helper class to properly shutdown
-// WinSock before we figure out how to do this properly.
+void
+Cubit_Client::cube_octet (int i)
{
-public:
- ~ACE_winsock_proper_shutdown (void)
- {
- ACE_OS::socket_fini ();
- }
-};
+ CORBA::Octet arg_octet = this->func (i);
-int
-main (int argc, char *argv[])
+ // Cube an octet.
+ CORBA::Octet ret_octet = this->cubit_->Cubit_cube_octet (arg_octet, this->env_);
+
+ this->call_count_++;
+
+ if (this->env_.exception () != 0)
+ {
+ this->env_.print_exception ("from cube_octet");
+ this->error_count_++;
+ }
+ else
+ {
+ dmsg2 ("cube octet: %d --> %d\n", arg_octet, ret_octet);
+ arg_octet = arg_octet * arg_octet * arg_octet;
+ if (arg_octet != ret_octet) {
+ ACE_DEBUG ((LM_DEBUG,
+ "** cube_octet (%d) ERROR (--> %d)\n",
+ (CORBA::Octet) this->func (i),
+ ret_octet));
+ this->error_count_++;
+ }
+ }
+}
+
+
+// calculate the cube from a long
+
+void
+Cubit_Client::cube_long (int i)
{
- // @@ Winsock shutdown object.
- ACE_winsock_proper_shutdown shutdown_object;
+ CORBA::Long arg_long = this->func (i);
+
+ // Cube a long.
+ CORBA::Long ret_long = this->cubit_->Cubit_cube_long (arg_long, this->env_);
+
+ this->call_count_++;
+
+ if (this->env_.exception () != 0)
+ {
+ this->env_.print_exception ("from cube_long");
+ this->error_count_++;
+ }
+ else
+ {
+ dmsg2 ("cube long: %d --> %d\n", arg_long, ret_long);
+ arg_long = arg_long * arg_long * arg_long;
+ if (arg_long != ret_long) {
+ ACE_ERROR ((LM_ERROR,
+ "** cube_long (%ld) ERROR (--> %ld)\n",
+ (CORBA::Long) this->func (i),
+ ret_long));
+ this->error_count_++;
+ }
+ }
+}
- ACE_UNUSED_ARG (shutdown_object);
+// Cube a short.
- CORBA::Object_ptr objref = CORBA::Object::_nil ();
- CORBA::Environment env;
+void
+Cubit_Client::cube_short (int i)
+{
+ CORBA::Short arg_short = this->func (i);
+ // Cube a short.
+ CORBA::Short ret_short = cubit_->Cubit_cube_short (arg_short, this->env_);
- CORBA::ORB_ptr orb_ptr = CORBA::ORB_init (argc, argv, "internet", env);
+ this->call_count_++;
- if (env.exception () != 0)
+ if (this->env_.exception () != 0)
{
- env.print_exception ("ORB initialization");
- return 1;
+ this->env_.print_exception ("from cube_short");
+ this->error_count_++;
+ }
+ else
+ {
+ dmsg2 ("cube short: %d --> %d\n",
+ arg_short,
+ ret_short);
+ arg_short = arg_short * arg_short * arg_short;
+
+ if (arg_short != ret_short)
+ {
+ ACE_ERROR ((LM_ERROR, "** cube_short (%d) ERROR (--> %d)\n",
+ (CORBA::Short) this->func (i),
+ ret_short));
+ this->error_count_++;
+ }
}
+}
+
+// Cube the numbers in a struct
+
+void
+Cubit_Client::cube_struct (int i)
+{
+ Cubit_Many arg_struct;
+ Cubit_Many *ret_struct;
+
+ this->call_count_++;
+
+ arg_struct.l = this->func (i);
+ arg_struct.s = this->func (i);
+ arg_struct.o = this->func (i);
+
+ // Cube a "struct" ...
+ ret_struct = this->cubit_->Cubit_cube_struct (arg_struct, this->env_);
+
+ if (this->env_.exception () != 0)
+ {
+ this->env_.print_exception ("from cube_struct");
+ this->error_count_++;
+ }
+ else
+ {
+ dmsg ("cube struct ...");
+ arg_struct.l = arg_struct.l * arg_struct.l * arg_struct.l;
+ arg_struct.s = arg_struct.s * arg_struct.s * arg_struct.s;
+ arg_struct.o = arg_struct.o * arg_struct.o * arg_struct.o;
+
+ if (arg_struct.l != ret_struct->l
+ || arg_struct.s != ret_struct->s
+ || arg_struct.o != ret_struct->o)
+ {
+ ACE_ERROR ((LM_ERROR, "** cube_struct ERROR\n"));
+ this->error_count_++;
+ }
+ }
+ delete ret_struct;
+}
+
+int
+Cubit_Client::init (int argc, char **argv)
+{
+ this->argc_ = argc;
+ this->argv_ = argv;
// Parse command line and verify parameters.
- parse_args (argc, argv);
+ if (this->parse_args () == -1)
+ return -1;
- if (TAO_arg_ior == 0)
+ if (this->TAO_arg_ior_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"%s: must specify an object reference using -O <ior>\n",
- argv[0]),
- 1);
+ this->argv_[0]),
+ -1);
- objref = orb_ptr->string_to_object ((CORBA::String) TAO_arg_ior, env);
+ // Retrieve the ORB.
+ this->orb_ptr_ = CORBA::ORB_init (this->argc_,
+ this->argv_,
+ "internet",
+ this->env_);
- ACE_OS::free ((void *) TAO_arg_ior);
- TAO_arg_ior = 0;
+ if (this->env_.exception () != 0)
+ {
+ this->env_.print_exception ("ORB initialization");
+ return -1;
+ }
+
+ this->objref_ = this->orb_ptr_->string_to_object ((CORBA::String) this->TAO_arg_ior_,
+ this->env_);
- if (env.exception () != 0)
+ ACE_OS::free ((void *) this->TAO_arg_ior_);
+ this->TAO_arg_ior_ = 0;
+
+ if (this->env_.exception () != 0)
{
- env.print_exception ("string2object");
+ this->env_.print_exception ("string2object");
return 1;
}
- if (CORBA::is_nil (objref) == CORBA::B_TRUE)
+ if (CORBA::is_nil (this->objref_) == CORBA::B_TRUE)
ACE_ERROR_RETURN ((LM_ERROR,
"%s: must identify non-null target objref\n",
- argv [0]),
- 1);
+ this->argv_ [0]),
+ -1);
// Narrow the CORBA::Object reference to the stub object, checking
// the type along the way using _is_a.
- Cubit_ptr cubit = Cubit::_narrow (objref);
+ this->cubit_ = Cubit::_narrow (this->objref_);
- if (cubit == 0)
+ if (this->cubit_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to narrow object reference to a Cubit_ptr.\n"),
- 1);
+ -1);
- // Make the calls in a loop.
+ return 0;
+}
- u_int i;
- u_int call_count, error_count;
+// Simple test for DII: call "cube_struct".
- call_count = 0;
- error_count = 0;
+void
+Cubit_Client::simple_DII_cube_struct (void)
+{
+ // Create the request ...
- //ACE_Time_Value before;
+ CORBA::Request_ptr req =
+ this->objref_->_request ((const CORBA::String) "cube_struct", this->env_);
- // @@ We should use an ACE_Profile_Timer here...
- //before = ACE_OS::gettimeofday ();
- ACE_Profile_Timer timer;
- ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time;
-
- // We start an ACE_Profile_Timer here...
- timer.start ();
+ if (this->env_.exception () != 0)
+ {
+ this->env_.print_exception ("DII request create");
+ return;
+ }
- for (i = 0; i < loop_count; i++)
+ // ... initialise the argument list and result ...
+ Cubit_Many arg, *result;
+
+ arg.o = 3;
+ arg.l = 5;
+ arg.s = -7;
+
+ CORBA::Any tmp_arg (TC_Cubit_Many, &arg, CORBA::B_FALSE);
+
+ req->arguments ()->add_value (0, tmp_arg, CORBA::ARG_IN, this->env_);
+
+ if (this->env_.exception () != 0)
{
- CORBA::Octet arg_octet;
- CORBA::Octet ret_octet;
+ this->env_.print_exception ("DII request arg add");
+ CORBA::release (req);
+ return;
+ }
- call_count++;
+ req->result ()->value ()->replace (TC_Cubit_Many, 0, CORBA::B_TRUE, this->env_);
+
+ if (this->env_.exception () != 0)
+ {
+ this->env_.print_exception ("DII request result type");
+ CORBA::release (req);
+ return;
+ }
- // Cube an octet.
- ret_octet = cubit->Cubit_cube_octet (arg_octet = func (i), env);
+ // Make the invocation, verify the result
- if (env.exception () != 0)
- {
- env.print_exception ("from cube_octet");
- error_count++;
- }
- else
- {
- dmsg2 ("cube octet: %d --> %d\n", arg_octet, ret_octet);
- arg_octet = arg_octet * arg_octet * arg_octet;
- if (arg_octet != ret_octet) {
- ACE_DEBUG ((LM_DEBUG,
- "** cube_octet (%d) ERROR (--> %d)\n",
- (CORBA::Octet) func (i),
- ret_octet));
- error_count++;
- }
- }
+ req->invoke ();
- CORBA::Short arg_short, ret_short;
+ if (req->env ()->exception () != 0)
+ {
+ req->env ()->print_exception ("DII invoke");
+ CORBA::release (req);
+ return;
+ }
+
+ result = (Cubit_Many *) req->result ()->value ()->value ();
- call_count++;
+ if (result->o != 27 || result->l != 125 || result->s != -343)
+ ACE_ERROR ((LM_ERROR, "DII cube_struct -- bad results\n"));
+ else
+ dmsg ("DII cube_struct ... success!!");
+
+ CORBA::release (req);
+}
- // Cube a short.
- ret_short = cubit->Cubit_cube_short (arg_short = func (i), env);
+// Execute client example code.
- if (env.exception () != 0)
- {
- env.print_exception ("from cube_short");
- error_count++;
- }
- else
- {
- dmsg2 ("cube short: %d --> %d\n",
- arg_short,
- ret_short);
- arg_short = arg_short * arg_short * arg_short;
-
- if (arg_short != ret_short)
- {
- ACE_ERROR ((LM_ERROR, "** cube_short (%d) ERROR (--> %d)\n",
- (CORBA::Short) func (i),
- ret_short));
- error_count++;
- }
- }
+int
+Cubit_Client::run (void)
+{
+ u_int i;
- CORBA::Long arg_long, ret_long;
-
- call_count++;
+ ACE_Profile_Timer timer;
+ ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time;
- // Cube a long.
- ret_long = cubit->Cubit_cube_long (arg_long = func (i), env);
+ // ACE_Time_Value before;
- if (env.exception () != 0)
- {
- env.print_exception ("from cube_long");
- error_count++;
- }
- else
- {
- dmsg2 ("cube long: %d --> %d\n", arg_long, ret_long);
- arg_long = arg_long * arg_long * arg_long;
- if (arg_long != ret_long) {
- ACE_ERROR ((LM_ERROR,
- "** cube_long (%ld) ERROR (--> %ld)\n",
- (CORBA::Long) func (i),
- ret_long));
- error_count++;
- }
- }
+ // We start an ACE_Profile_Timer here...
+ timer.start ();
- Cubit_Many arg_struct, *ret_struct;
-
- call_count++;
-
- arg_struct.l = func (i);
- arg_struct.s = func (i);
- arg_struct.o = func (i);
-
- // Cube a "struct" ...
- ret_struct = cubit->Cubit_cube_struct (arg_struct, env);
+ // Make the calls in a loop.
+ for (i = 0; i < this->loop_count_; i++)
+ {
+ this->cube_short (i);
- if (env.exception () != 0)
- {
- env.print_exception ("from cube_struct");
- error_count++;
- }
- else
- {
- dmsg ("cube struct ...");
- arg_struct.l = arg_struct.l * arg_struct.l * arg_struct.l;
- arg_struct.s = arg_struct.s * arg_struct.s * arg_struct.s;
- arg_struct.o = arg_struct.o * arg_struct.o * arg_struct.o;
-
- if (arg_struct.l != ret_struct->l
- || arg_struct.s != ret_struct->s
- || arg_struct.o != ret_struct->o)
- {
- ACE_ERROR ((LM_ERROR, "** cube_struct ERROR\n"));
- error_count++;
- }
-
- delete ret_struct;
- }
-
+ this->cube_octet (i);
+
+ this->cube_long (i);
+
+ this->cube_struct (i);
}
-
- // ACE_Time_Value after = ACE_OS::gettimeofday ();
-
- // We start an ACE_Profile_Timer here...
+
+ // stop the timer.
timer.stop ();
-
- if (call_count > 0)
+
+ // compute call average call time.
+ if (this->call_count_ > 0)
{
- if (error_count == 0)
+ if (this->error_count_ == 0)
{
-
timer.elapsed_time (elapsed_time);
double tmp;
@@ -426,11 +540,11 @@ main (int argc, char *argv[])
elapsed_time.user_time *= ACE_ONE_SECOND_IN_MSECS;
elapsed_time.system_time *= ACE_ONE_SECOND_IN_MSECS;
- elapsed_time.real_time /= call_count;
- elapsed_time.user_time /= call_count;
- elapsed_time.system_time /= call_count;
+ elapsed_time.real_time /= this->call_count_;
+ elapsed_time.user_time /= this->call_count_;
+ elapsed_time.system_time /= this->call_count_;
- tmp = 1000/(elapsed_time.real_time + elapsed_time.user_time + elapsed_time.system_time);
+ tmp = 1000 / (elapsed_time.real_time + elapsed_time.user_time + elapsed_time.system_time);
ACE_DEBUG ((LM_DEBUG,
"cube average call:\n\treal_time\t= %0.06f ms, \n\t"
@@ -442,110 +556,68 @@ main (int argc, char *argv[])
elapsed_time.system_time < 0.0? 0.0:elapsed_time.system_time,
tmp < 0.0? 0.0 : tmp));
-#if 0
- ACE_Time_Value diff = after - before;
- unsigned long us = diff.sec () * 1000 * 1000 + diff.usec ();
-
- us /= call_count;
-
- if (us > 0)
- ACE_DEBUG ((LM_DEBUG,
- "cube average call ACE_OS::time\t= %d.%.03dms, \t"
- "%d calls/second\n",
- us / 1000, us % 1000,
- 1000000L / us));
-#endif
}
- ACE_DEBUG ((LM_DEBUG, "%d calls, %d errors\n", call_count, error_count));
+ ACE_DEBUG ((LM_DEBUG,
+ "\t%d calls, %d errors\n",
+ this->call_count_,
+ this->error_count_));
}
// Simple test for DII: call "cube_struct". (It's not timed since
// the copious mallocation of DII would bias numbers against typical
// stub-based calls).
- do
- {
- // Create the request ...
- CORBA::Request_ptr req =
- objref->_request ((const CORBA::String) "cube_struct", env);
+ timer.start ();
- if (env.exception () != 0)
- {
- env.print_exception ("DII request create");
- break;
- }
+ this->simple_DII_cube_struct ();
- // ... initialise the argument list and result ...
- Cubit_Many arg, *result;
-
- arg.o = 3;
- arg.l = 5;
- arg.s = -7;
-
- CORBA::Any tmp_arg (TC_Cubit_Many, &arg, CORBA::B_FALSE);
-
- req->arguments ()->add_value (0, tmp_arg, CORBA::ARG_IN, env);
-
- if (env.exception () != 0)
- {
- env.print_exception ("DII request arg add");
- CORBA::release (req);
- break;
- }
-
- req->result ()->value ()->replace (TC_Cubit_Many, 0, CORBA::B_TRUE, env);
- if (env.exception () != 0)
- {
- env.print_exception ("DII request result type");
- CORBA::release (req);
- break;
- }
+ timer.start ();
+ this->cube_union_dii ();
+ timer.stop ();
- // Make the invocation, verify the result
+ timer.elapsed_time (elapsed_time);
+ ACE_DEBUG ((LM_DEBUG,
+ "cube_union_dii() call:\n\treal_time\t= %0.06f ms, \n\t"
+ "user_time\t= %0.06f ms, \n\t"
+ "system_time\t= %0.06f ms\n",
+ elapsed_time.real_time < 0.0? 0.0:elapsed_time.real_time,
+ elapsed_time.user_time < 0.0? 0.0:elapsed_time.user_time,
+ elapsed_time.system_time < 0.0? 0.0:elapsed_time.system_time));
- req->invoke ();
+ timer.start ();
+ this->cube_union_stub ();
+ timer.stop ();
- if (req->env ()->exception () != 0)
- {
- req->env ()->print_exception ("DII invoke");
- CORBA::release (req);
- break;
- }
-
- result = (Cubit_Many *) req->result ()->value ()->value ();
-
- if (result->o != 27 || result->l != 125 || result->s != -343)
- ACE_ERROR ((LM_ERROR, "DII cube_struct -- bad results\n"));
- else
- dmsg ("DII cube_struct ... success!!");
-
- CORBA::release (req);
-
- } while (0);
+ timer.elapsed_time (elapsed_time);
+ ACE_DEBUG ((LM_DEBUG,
+ "cube_union_stub() call:\n\treal_time\t= %0.06f ms, \n\t"
+ "user_time\t= %0.06f ms, \n\t"
+ "system_time\t= %0.06f ms\n",
+ elapsed_time.real_time < 0.0? 0.0:elapsed_time.real_time,
+ elapsed_time.user_time < 0.0? 0.0:elapsed_time.user_time,
+ elapsed_time.system_time < 0.0? 0.0:elapsed_time.system_time));
- // Two more tests, using the "cube_union" function
+ if (this->exit_later_)
+ {
+ this->cubit_->Cubit_please_exit (this->env_);
+ dexc (this->env_, "server, please ACE_OS::exit");
+ }
- cube_union_dii (call_count, error_count, objref, env);
+ return this->error_count_ == 0 ? 0 : 1;
+}
- if (env.exception () != 0)
- error_count++;
-
- cube_union_stub (i, call_count, error_count, objref, env);
- if (env.exception () != 0)
- error_count++;
-
- if (exit_later)
- {
- cubit->Cubit_please_exit (env);
- dexc (env, "server, please exit");
- }
-
- // Free resources
- CORBA::release (objref);
- CORBA::release (orb_ptr);
+// This function runs the test.
- return error_count == 0 ? 0 : 1;
+int
+main (int argc, char **argv)
+{
+ Cubit_Client cubit_client;
+
+ if (cubit_client.init (argc, argv) == -1)
+ return 1;
+ else
+ return cubit_client.run ();
}
diff --git a/TAO/tests/Cubit/TAO/DII_Cubit/clnt.h b/TAO/tests/Cubit/TAO/DII_Cubit/clnt.h
new file mode 100644
index 00000000000..bbdd9d9aa83
--- /dev/null
+++ b/TAO/tests/Cubit/TAO/DII_Cubit/clnt.h
@@ -0,0 +1,126 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/tests/DII_Cubit
+//
+// = FILENAME
+// clnt.h
+//
+// = DESCRIPTION
+// This class implements a simple wrapper around the "cube" CORBA
+// client for the Cubit example using stubs generated by the TAO
+// ORB IDL compiler.
+//
+// = AUTHORS
+// Sergio Flores-Gaitan
+//
+// ============================================================================
+
+#include "ace/Get_Opt.h"
+#include "tao/corba.h"
+#include "cubitC.h"
+
+class ACE_winsock_proper_shutdown
+// @@ We need this helper class to properly shutdown
+// WinSock before we figure out how to do this properly.
+{
+public:
+ ~ACE_winsock_proper_shutdown (void)
+ {
+ ACE_OS::socket_fini ();
+ }
+};
+
+class Cubit_Client
+ // = TITLE
+ // Defines a class that encapsulates behaviour of the Cubit client
+ // example. Provides a better understanding of the logic in an
+ // object oriented way.
+ //
+ // = DESCRIPTION
+ // This class declares an interface to run the example client for
+ // Cubit CORBA server. All the complexity for initializing the
+ // server is hidden in the class. Just the run() interface is needed.
+{
+public:
+ // = Constructor and destructor.
+ Cubit_Client (void);
+ ~Cubit_Client (void);
+
+ int run (void);
+ // Execute client example code.
+
+ int init (int argc, char **argv);
+ // Initialize the client communication endpoint with server.
+
+private:
+ int func (u_int i);
+ // simple function that returns the substraction of 117 from the parameter.
+
+ int parse_args (void);
+ // Parses the arguments passed on the command line.
+
+ void cube_union_stub (void);
+ // Exercise the union. Cube a union.
+
+ void cube_union_dii (void);
+ // Exercise the union using dii.
+
+ void cube_struct (int i);
+ // calculate the cube from a struct.
+
+ void cube_long (int i);
+ // calculate the cube from a long
+
+ void cube_octet (int i);
+ // Cube an octet
+
+ void cube_short (int i);
+ // Cube a short.
+
+ void cube_struct_dii (void);
+ // Cube the numbers in a struct
+
+ void simple_DII_cube_struct (void);
+ // Simple test for DII: call "cube_struct".
+
+ // private member variables.
+
+ int argc_;
+ // # of arguments on the command line.
+
+ char **argv_;
+ // arguments from command line.
+
+ u_int loop_count_;
+ // Number of times to do the cube operations.
+
+ int exit_later_;
+ // Flag to tell server to not exit immediately
+
+ CORBA::Object_ptr objref_;
+ // storage of the factory objref
+
+ CORBA::Environment env_;
+ // Environment variable
+
+ Cubit_ptr cubit_;
+ // Cubit obj ref
+
+ CORBA::ORB_ptr orb_ptr_;
+ // Remember our orb
+
+ u_int call_count_;
+ // # of calls made to functions
+
+ u_int error_count_;
+ // # of errors incurred in the lifetime of the application.
+
+ ACE_winsock_proper_shutdown shutdown_object;
+ // Winsock shutdown object.
+
+ const char *TAO_arg_ior_;
+ // pointer to object reference string.
+};