3 //=============================================================================
7 * Options for the Param_Test application
9 * @author Jeff Parsonss
11 //=============================================================================
15 #include "tao/debug.h"
16 #include "ace/Read_Buffer.h"
17 #include "ace/Get_Opt.h"
18 #include "ace/OS_NS_string.h"
19 #include "ace/OS_NS_fcntl.h"
20 #include "ace/Log_Msg.h"
24 : ior_ (CORBA::string_dup ("file://test.ior")),
25 test_type_ (Options::NO_TEST
),
26 invoke_type_ (Options::SII
),
37 // Parses the command line arguments and returns an error status.
40 Options::parse_args (int argc
, ACE_TCHAR
**argv
)
42 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("xdn:f:i:t:k:"));
46 while ((c
= get_opts ()) != -1)
49 case 'd': // debug flag
58 case 'n': // loop count
59 this->loop_count_
= (CORBA::ULong
) ACE_OS::atoi (get_opts
.opt_arg ());
63 result
= this->read_ior (get_opts
.opt_arg ());
66 ACE_ERROR_RETURN ((LM_ERROR
,
67 "Unable to read ior from %s : %p\n",
74 this->ior_
= CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(get_opts
.opt_arg ()));
77 case 'i': // invocation
78 if (!ACE_OS::strcmp (get_opts
.opt_arg (), ACE_TEXT("dii")))
79 this->invoke_type_
= Options::DII
;
82 case 't': // data type
83 if (!ACE_OS::strcmp (get_opts
.opt_arg (), ACE_TEXT("ubstring")))
84 this->test_type_
= Options::TEST_UB_STRING
;
85 else if (!ACE_OS::strcmp (get_opts
.opt_arg (), ACE_TEXT("ub_struct_seq")))
86 this->test_type_
= Options::TEST_UB_STRUCT_SEQUENCE
;
91 ACE_ERROR_RETURN ((LM_ERROR
,
95 " [-f servant-IOR-file]"
96 " [-i invocation (sii/dii)]"
103 // Indicates successful parsing of command line.
107 // Get the factory IOR from the file created by the server.
109 Options::read_ior (ACE_TCHAR
*filename
)
111 // Open the file for reading.
112 ACE_HANDLE f_handle
= ACE_OS::open (filename
, 0);
114 if (f_handle
== ACE_INVALID_HANDLE
)
115 ACE_ERROR_RETURN ((LM_ERROR
,
116 "Unable to open %s for writing: %p\n",
119 ACE_Read_Buffer
ior_buffer (f_handle
, true);
120 this->ior_
= ior_buffer
.read ();
122 if (this->ior_
.in () == 0)
123 ACE_ERROR_RETURN ((LM_ERROR
,
124 "Unable to allocate memory to read ior: %p\n"),
130 Options::param_test_ior () const
132 return this->ior_
.in ();
136 Options::test_type ()
138 return this->test_type_
;
142 Options::invoke_type ()
144 return this->invoke_type_
;
148 Options::loop_count ()
150 return this->loop_count_
;
154 Options::debug () const
160 Options::shutdown () const
162 return this->shutdown_
;
165 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton
, Options
, ACE_Recursive_Thread_Mutex
);