Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / tests / OBV / TC_Alignment / client.cpp
blob1cf7dde9dc52912a36cdba2524fa1960e6d175e3
1 #include "testC.h"
2 #include "ace/Get_Opt.h"
4 static const ACE_TCHAR *ior_input_file = ACE_TEXT("file://test.ior");
6 static obvmod::tcOffset1 *vt1 = 0;
7 static obvmod::tcOffset003 *vt3 = 0;
8 static obvmod::tcOffset00005 *vt5 = 0;
9 static obvmod::tcOffset0000007 *vt7 = 0;
11 int debug = 0;
12 int do_shutdown = 0;
14 int
15 register_factories (CORBA::ORB_ptr orb)
17 // Create and register factories.
19 obvmod::tcOffset1_init *factory1 = 0;
20 ACE_NEW_RETURN (factory1,
21 obvmod::tcOffset1_init,
22 -1);
24 orb->register_value_factory (factory1->tao_repository_id (),
25 factory1);
27 factory1->_remove_ref ();
29 obvmod::tcOffset003_init *factory3 = 0;
30 ACE_NEW_RETURN (factory3,
31 obvmod::tcOffset003_init,
32 -1);
34 orb->register_value_factory (factory3->tao_repository_id (),
35 factory3);
37 factory3->_remove_ref ();
39 obvmod::tcOffset00005_init *factory5 = 0;
40 ACE_NEW_RETURN (factory5,
41 obvmod::tcOffset00005_init,
42 -1);
44 orb->register_value_factory (factory5->tao_repository_id (),
45 factory5);
47 factory5->_remove_ref ();
49 obvmod::tcOffset0000007_init *factory7 = 0;
50 ACE_NEW_RETURN (factory7,
51 obvmod::tcOffset0000007_init,
52 -1);
54 orb->register_value_factory (factory7->tao_repository_id (),
55 factory7);
57 factory7->_remove_ref ();
58 return 0;
61 int
62 run_test (test_ptr objref,
63 CORBA::Long offset)
65 CORBA::Any_var result = objref->get_value (offset);
67 CORBA::Boolean status = 0;
68 CORBA::Long member_value = 0;
70 switch (offset)
72 case 1:
73 status = (result.in () >>= vt1);
74 member_value = vt1->mem ();
75 break;
76 case 3:
77 status = (result.in () >>= vt3);
78 member_value = vt3->mem ();
79 break;
80 case 5:
81 status = (result.in () >>= vt5);
82 member_value = vt5->mem ();
83 break;
84 case 7:
85 status = (result.in () >>= vt7);
86 member_value = vt7->mem ();
87 break;
88 default:
89 return -1;
92 if (status == 0)
94 if (debug)
96 ACE_DEBUG ((LM_DEBUG,
97 "Any extraction failed for repo id length offset"
98 " of %d from 8-byte boundary\n",
99 offset));
102 return -1;
105 return (member_value == offset);
109 parse_args (int argc, ACE_TCHAR *argv[])
111 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("dk:x"));
112 int c;
114 while ((c = get_opts ()) != -1)
115 switch (c)
117 case 'd':
118 debug = 1;
119 break;
121 case 'k':
122 ior_input_file = get_opts.optarg;
123 break;
125 case 'x':
126 do_shutdown = 1;
127 break;
129 case '?':
130 default:
131 ACE_ERROR_RETURN ((LM_ERROR,
132 "usage: %s "
133 "-d "
134 "-k <ior> "
135 "-x "
136 "\n",
137 argv [0]),
138 -1);
140 // Indicates successful parsing of the command line
141 return 0;
145 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
149 CORBA::ORB_var orb = CORBA::ORB_init (argc,
150 argv);
152 if (parse_args (argc, argv) != 0)
154 return 1;
157 CORBA::Object_var obj =
158 orb->string_to_object (ior_input_file);
160 int status = register_factories (orb.in ());
162 if (status != 0)
164 if (debug)
166 ACE_DEBUG ((LM_DEBUG,
167 "OBV factory registration failed\n"));
170 return -1;
173 test_var objref = test::_narrow (obj.in ());
175 for (CORBA::Long i = 1; i < 8; i += 2)
177 status = run_test (objref.in (), i);
179 if (status == 0)
181 if (debug)
183 ACE_DEBUG ((LM_DEBUG,
184 "Incorrect member value - expected %d\n",
185 i));
188 return -1;
192 if (do_shutdown)
194 objref->shutdown ();
197 orb->destroy ();
199 catch (const CORBA::Exception& ex)
201 ex._tao_print_exception ("exception:");
202 return 1;
205 return 0;