summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-07-18 14:10:24 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-07-18 14:10:24 +0000
commit1a05dd9d58f6ed1bbef9bcc6a0b7b3c0767b266d (patch)
tree69b7e7c42a1aa087fb2ada502467285c2dd3aeb7
parent8365c8ca7d21fd459667eba73aa534693c1d9846 (diff)
downloadATCD-1a05dd9d58f6ed1bbef9bcc6a0b7b3c0767b266d.tar.gz
*** empty log message ***
-rw-r--r--TAO/orbsvcs/tests/Simple_Naming/client.cpp141
-rw-r--r--TAO/orbsvcs/tests/Simple_Naming/client.h69
2 files changed, 210 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/Simple_Naming/client.cpp b/TAO/orbsvcs/tests/Simple_Naming/client.cpp
new file mode 100644
index 00000000000..8c9c884d90a
--- /dev/null
+++ b/TAO/orbsvcs/tests/Simple_Naming/client.cpp
@@ -0,0 +1,141 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/orbsvcs/Naming_Service/
+//
+// = FILENAME
+// client.cpp
+//
+// = DESCRIPTION
+// This class implements a simple CORBA client for the CosNaming
+// example using stubs generated by the TAO ORB IDL compiler.
+//
+// = AUTHORS
+// Sergio Flores-Gaitan <sergio@cs.wustl.edu> and
+// Douglas C. Schmidt <schmidt@cs.wustl.edu>
+// ============================================================================
+
+#include "client.h"
+#include "ace/Get_Opt.h"
+
+// constructor
+
+CosNaming_Client::CosNaming_Client (void)
+ : argc_ (0),
+ argv_ (0),
+ exit_later_ (0)
+{
+}
+
+// Parses the command line arguments and returns an error status.
+
+int
+CosNaming_Client::parse_args (void)
+{
+ ACE_Get_Opt get_opts (argc_, argv_, "dx");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'd': // debug flag
+ TAO_debug_level++;
+ break;
+ case 'x':
+ this->exit_later_++;
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s"
+ " [-d]"
+ " [-x]"
+ "\n",
+ this->argv_ [0]),
+ -1);
+ }
+
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+// Execute client example code.
+
+int
+CosNaming_Client::run (void)
+{
+ // Dummy object instantiation.
+ Test_Object_var myObject_var =
+ myObject._this (TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ // Bind an object to the Naming Context.
+ CosNaming::Name test_name (1);
+ test_name.length (1);
+ test_name[0].id =
+ CORBA::string_dup ("Foo");
+
+ my_name_server->bind (test_name,
+ myObject_var.in (),
+ TAO_TRY_ENV);
+
+ TAO_CHECK_ENV;
+ ACE_DEBUG ((LM_DEBUG,
+ "Bound name OK"));
+
+ // @@ TODO, add some more interesting tests here, for instance
+ // creating some nested naming contexts and registering a number of
+ // objreferences in there. We could even use the Iterators and the
+ // TAO_Client_Naming abstraction to simply this.
+ return 0;
+}
+
+CosNaming_Client::~CosNaming_Client (void)
+{
+}
+
+int
+CosNaming_Client::init (int argc, char **argv)
+{
+ this->argc_ = argc;
+ this->argv_ = argv;
+
+ TAO_TRY
+ {
+ // Parse command line and verify parameters.
+ if (this->parse_args () == -1)
+ return -1;
+
+ // Initialize ORB.
+ this->orbmgr_.init (argc,
+ argv,
+ 0,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ return this->naming_client_.init (this->orbmgr_.orb ())
+ }
+ TAO_CATCHANY
+ {
+ TAO_TRY_ENV.print_exception ("init");
+ return -1;
+ }
+ TAO_ENDTRY;
+
+ return 0;
+}
+
+// This function runs the test.
+
+int
+main (int argc, char **argv)
+{
+ CosNaming_Client cosnaming_client;
+
+ if (cosnaming_client.init (argc, argv) == -1)
+ return 1;
+
+ return cosnaming_client.run ();
+}
diff --git a/TAO/orbsvcs/tests/Simple_Naming/client.h b/TAO/orbsvcs/tests/Simple_Naming/client.h
new file mode 100644
index 00000000000..3e0b85933a5
--- /dev/null
+++ b/TAO/orbsvcs/tests/Simple_Naming/client.h
@@ -0,0 +1,69 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/orbsvcs/tests
+//
+// = FILENAME
+// client.h
+//
+// = DESCRIPTION
+// This class tests the facilities to connect to the naming service.
+//
+// = AUTHORS
+// Sergio Flores-Gaitan <sergio@cs.wustl.edu>
+//
+// ============================================================================
+
+#include "tao/corba.h"
+#include "tao/TAO.h"
+#include "orbsvcs/Naming/Naming_Utils.h"
+#include "orbsvcs/CosNamingC.h"
+
+class CosNaming_Client
+{
+ // = TITLE
+ // Defines a class that encapsulates behaviour of the CosNaming
+ // 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
+ // CosNaming CORBA server. All the complexity for initializing
+ // the server is hidden in the class. Just the <run> interface
+ // is needed.
+public:
+ // = Initialization and termination methods.
+ CosNaming_Client (void);
+ // Constructor.
+
+ ~CosNaming_Client (void);
+ // Destructor.
+
+ int run (void);
+ // Execute client example code.
+
+ int init (int argc, char **argv);
+ // Initialize the client communication endpoint with server.
+
+private:
+ int parse_args (void);
+ // Parses the arguments passed on the command line.
+
+ int argc_;
+ // # of arguments on the command line.
+
+ char **argv_;
+ // arguments from command line.
+
+ int exit_later_;
+ // Flag to tell server to not exit immediately.
+
+ TAO_ORB_Manager orbmgr_;
+ // Our ORB manager helper class.
+
+ TAO_Naming_Client naming_client_;
+ // Our naming client helper class.
+};