Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / performance-tests / Pluggable / PP_Test_Server.cpp
bloba8121b86a852df4d85c43589bc9c35ca661f621a
1 #include "PP_Test_Server.h"
2 #include "tao/TAO_Internal.h"
3 #include "tao/debug.h"
4 #include "ace/OS_NS_stdio.h"
6 PP_Test_Server::PP_Test_Server (void)
7 : ior_output_file_ (0)
11 int
12 PP_Test_Server::parse_args (void)
14 ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("do:"));
15 int c;
17 while ((c = get_opts ()) != -1)
18 switch (c)
20 case 'd': // debug flag.
21 TAO_debug_level++;
22 break;
23 case 'o': // output the IOR to a file.
24 this->ior_output_file_ = ACE_OS::fopen (get_opts.opt_arg (), "w");
25 if (this->ior_output_file_ == 0)
26 ACE_ERROR_RETURN ((LM_ERROR,
27 "Unable to open %s for writing: %p\n",
28 get_opts.opt_arg ()),
29 -1);
30 break;
31 case '?':
32 default:
33 ACE_ERROR_RETURN ((LM_ERROR,
34 "usage: %s"
35 " [-d]"
36 " [-o] <ior_output_file>"
37 "\n",
38 argv_ [0]),
39 -1);
42 // Indicates successful parsing of command line.
43 return 0;
46 int
47 PP_Test_Server::init (int argc,
48 ACE_TCHAR** argv)
50 // Call the init of <TAO_ORB_Manager> to initialize the ORB and
51 // create a child POA under the root POA.
52 if (this->orb_manager_.init_child_poa (argc,
53 argv,
54 "child_poa") == -1)
55 ACE_ERROR_RETURN ((LM_ERROR,
56 "%p\n",
57 "init_child_poa"),
58 -1);
59 this->argc_ = argc;
60 this->argv_ = argv;
62 if (this->parse_args () == -1)
63 ACE_ERROR_RETURN ((LM_ERROR,
64 "%p\n",
65 "parse_args"),
66 -1);
67 // Get the orb
68 CORBA::ORB_var orb = this->orb_manager_.orb ();
70 // Now create the implementations
71 this->factory_impl_ = new Pluggable_Test_Factory_i (orb.in ());
73 this->factory_id_ =
74 this->orb_manager_.activate_under_child_poa ("factory",
75 this->factory_impl_);
77 ACE_DEBUG ((LM_DEBUG,
78 "The IOR is: <%s>\n",
79 this->factory_id_.in ()));
81 if (this->ior_output_file_)
83 ACE_OS::fprintf (this->ior_output_file_,
84 "%s",
85 this->factory_id_.in ());
87 ACE_OS::fclose (this->ior_output_file_);
90 return 0;
93 int
94 PP_Test_Server::run ()
96 int result = this->orb_manager_.run ();
99 if (result == -1)
100 ACE_ERROR_RETURN ((LM_ERROR,
101 "PP_Test_Server::run"),
102 -1);
103 return 0;
106 PP_Test_Server::~PP_Test_Server (void)
108 if (this->factory_id_.in ())
109 this->orb_manager_.deactivate_under_child_poa (this->factory_id_.in ());
111 delete this->factory_impl_;