summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-06-27 20:19:43 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-06-27 20:19:43 +0000
commitdd14997d768b277425879c3c3bacafe523fe33a5 (patch)
tree2a8f3cb1b06ee6ba6d8ed392d76664514ff85c82
parentc4eaa063c926af21cae4109beac5bc8b6e48eef8 (diff)
downloadATCD-dd14997d768b277425879c3c3bacafe523fe33a5.tar.gz
ChangeLogTag: Wed Jun 27 15:18:21 2001 Jeff Parsons <parsons@cs.wustl.edu>
-rw-r--r--TAO/tests/Explicit_Event_Loop/client.cpp61
-rw-r--r--TAO/tests/Explicit_Event_Loop/server.cpp79
2 files changed, 87 insertions, 53 deletions
diff --git a/TAO/tests/Explicit_Event_Loop/client.cpp b/TAO/tests/Explicit_Event_Loop/client.cpp
index f9df0405b05..6537950ca44 100644
--- a/TAO/tests/Explicit_Event_Loop/client.cpp
+++ b/TAO/tests/Explicit_Event_Loop/client.cpp
@@ -33,53 +33,72 @@ main (int argc, char *argv[])
ACE_TRY
{
// Initialize orb
- CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv,
+ "",
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
- // Check arguments
+ // Check arguments.
if (argc != 2)
{
- cerr << "Usage: client IOR_string" << endl;
- return 1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Usage: client IOR_string\n"),
+ 1);
}
- // Destringify argv[1]
- CORBA::Object_var obj = orb->string_to_object (argv[1]);
+ // Destringify argv[1].
+ CORBA::Object_var obj = orb->string_to_object (argv[1],
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
if (CORBA::is_nil (obj.in ()))
{
- cerr << "Nil Time reference" << endl;
- return 1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Nil Time reference\n"),
+ 1);
}
- // Narrow
- Time_var tm = Time::_narrow (obj.in ());
+ // Narrow.
+ Time_var tm = Time::_narrow (obj.in (),
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
if (CORBA::is_nil (tm.in ()))
{
- cerr << "Argument is not a Time reference" << endl;
- return 1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Argument is not a Time reference\n"),
+ 1);
}
- // Get time
+ // Get time.
TimeOfDay tod = tm->get_gmt (ACE_TRY_ENV);
ACE_TRY_CHECK;
- cout << "Time in Greenwich is "
- << setw (2) << setfill ('0') << tod.hour << ":"
- << setw (2) << setfill ('0') << tod.minute << ":"
- << setw (2) << setfill ('0') << tod.second << endl;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "%s%s%d:%s%d:%d\n",
+ "Time in Greenwich is ",
+ tod.hour < 10 ? "0" : "",
+ tod.hour,
+ tod.minute < 10 ? "0" : "",
+ tod.minute,
+ tod.second));
}
ACE_CATCHANY
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "A CORBA exception occured");
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "client: a CORBA exception occured");
return 1;
}
ACE_CATCHALL
{
- cerr << "An unknown exception was caught" << endl;
- return 1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "client: an unknown exception was caught\n"),
+ 1);
}
ACE_ENDTRY;
- ACE_CHECK_RETURN(-1);
+ ACE_CHECK_RETURN (-1);
return 0;
}
diff --git a/TAO/tests/Explicit_Event_Loop/server.cpp b/TAO/tests/Explicit_Event_Loop/server.cpp
index df130a20d4e..eb040211863 100644
--- a/TAO/tests/Explicit_Event_Loop/server.cpp
+++ b/TAO/tests/Explicit_Event_Loop/server.cpp
@@ -23,11 +23,6 @@
#include "tao/debug.h"
#include "ace/Get_Opt.h"
-// The following headers are #included automatically by ACE+TAO.
-// Therefore, they don't need to be included explicitly.
-//#include <time.h>
-//#include <iostream.h>
-
const char *ior_output_file = "server.ior";
int done = 0;
@@ -88,8 +83,6 @@ void do_something_else()
int
main (int argc, char *argv[])
{
- int ret = 0;
-
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
@@ -101,76 +94,98 @@ main (int argc, char *argv[])
ACE_TRY_CHECK;
if (parse_args (argc, argv) != 0)
- return 1;
+ {
+ return 1;
+ }
// Get reference to Root POA.
CORBA::Object_var obj
= orb->resolve_initial_references ("RootPOA",
ACE_TRY_ENV);
ACE_TRY_CHECK;
+
PortableServer::POA_var poa
= PortableServer::POA::_narrow (obj.in (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
- // Activate POA manager
+ // Activate POA manager.
PortableServer::POAManager_var mgr
= poa->the_POAManager (ACE_TRY_ENV);
ACE_TRY_CHECK;
+
mgr->activate (ACE_TRY_ENV);
ACE_TRY_CHECK;
- // Create an object
+ // Create an object.
Time_impl time_servant;
- // Write its stringified reference to stdout
+ // Write its stringified reference to stdout.
Time_var tm = time_servant._this (ACE_TRY_ENV);
ACE_TRY_CHECK;
+
CORBA::String_var str = orb->object_to_string (tm.in (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
- cout << str.in () << endl;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "%s\n",
+ str.in ()));
if (ior_output_file != 0)
- {
- FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
- if (output_file == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Cannot open output file for writing IOR: %s",
- ior_output_file),
- 1);
- ACE_OS::fprintf (output_file, "%s", str.in ());
- ACE_OS::fclose (output_file);
- }
-
- // Explicit Event Loop
+ {
+ FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
+
+ if (output_file == 0)
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ "Cannot open output file for writing IOR: %s",
+ ior_output_file
+ ),
+ 1
+ );
+ }
+
+ ACE_OS::fprintf (output_file,
+ "%s",
+ str.in ());
+ ACE_OS::fclose (output_file);
+ }
+
+ // Explicit Event Loop.
while (!done)
{
CORBA::Boolean pending =
- orb->work_pending(ACE_TRY_ENV);
+ orb->work_pending (ACE_TRY_ENV);
ACE_TRY_CHECK;
+
if (pending)
{
- orb->perform_work(ACE_TRY_ENV);
+ orb->perform_work (ACE_TRY_ENV);
ACE_TRY_CHECK;
}
- do_something_else();
+ do_something_else ();
}
+
orb->shutdown ();
orb->destroy ();
}
ACE_CATCHANY
{
- ACE_PRINT_EXCEPTION(ACE_ANY_EXCEPTION, "A CORBA exception occured");
- ret = 1;
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "server: a CORBA exception occured");
+ return 1;
}
ACE_CATCHALL
{
- cerr << "An unknown exception was caught" << endl;
- ret = 1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%s\n",
+ "client: an unknown exception was caught\n"),
+ 1);
}
ACE_ENDTRY;
- return ret;
+ return 0;
}