Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / NestedUpcall / Triangle_Test / server_A.cpp
blob88246d49b64ccc592532743492da2dd55fb6940f
2 //=============================================================================
3 /**
4 * @file server_A.cpp
6 * This class implements a simple server for the
7 * Nested Upcalls - Triangle test.
9 * @author Michael Kircher
11 //=============================================================================
14 #include "server_A.h"
15 #include "tao/debug.h"
16 #include "ace/OS_NS_stdio.h"
18 Object_A_Server::Object_A_Server ()
19 : ior_output_file_ (0)
23 int
24 Object_A_Server::parse_args ()
26 ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("do:"));
27 int c;
29 while ((c = get_opts ()) != -1)
30 switch (c)
32 case 'd': // debug flag.
33 TAO_debug_level++;
34 break;
35 case 'o': // output the IOR to a file.
36 this->ior_output_file_ = ACE_OS::fopen (get_opts.opt_arg (), "w");
37 if (this->ior_output_file_ == 0)
38 ACE_ERROR_RETURN ((LM_ERROR,
39 "Unable to open %s for writing: %p\n",
40 get_opts.opt_arg ()), -1);
41 break;
42 case '?':
43 default:
44 ACE_ERROR_RETURN ((LM_ERROR,
45 "usage: %s"
46 " [-d]"
47 " [-o] <ior_output_file>"
48 "\n",
49 argv_ [0]),
50 1);
53 // Indicates successful parsing of command line.
54 return 0;
57 int
58 Object_A_Server::init (int argc,
59 ACE_TCHAR** argv)
61 // Call the init of TAO_ORB_Manager to create a child POA
62 // under the root POA.
63 this->orb_manager_.init_child_poa (argc,
64 argv,
65 "child_poa");
67 this->argc_ = argc;
68 this->argv_ = argv;
70 this->parse_args ();
71 // ~~ check for the return value here
73 CORBA::String_var str =
74 this->orb_manager_.activate_under_child_poa ("object_A",
75 &this->object_A_i_);
77 if (this->ior_output_file_)
79 ACE_OS::fprintf (this->ior_output_file_,
80 "%s",
81 str.in ());
82 ACE_OS::fclose (this->ior_output_file_);
86 return 0;
90 int
91 Object_A_Server::run ()
93 int r = this->orb_manager_.run ();
95 if (r == -1)
96 ACE_ERROR_RETURN ((LM_ERROR,
97 "NestedUpCalls_Server::run"),
98 -1);
99 return 0;}
102 Object_A_Server::~Object_A_Server ()
107 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
109 Object_A_Server object_A_Server;
111 ACE_DEBUG ((LM_DEBUG,
112 "\n \t NestedUpCalls.Triangle_Test: Object A Server \n\n"));
116 int retval =
117 object_A_Server.init (argc,argv);
119 if (retval == -1)
120 return 1;
121 else
123 object_A_Server.run ();
126 catch (const CORBA::SystemException& sysex)
128 sysex._tao_print_exception ("System Exception");
129 return -1;
131 catch (const CORBA::UserException& userex)
133 userex._tao_print_exception ("User Exception");
134 return -1;
136 return 0;