1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// $Id$
#include "tao/IFR_Client/IFR_ComponentsC.h"
#include "ace/Get_Opt.h"
#include "tao/ORB.h"
namespace
{
const ACE_TCHAR *ifr_ior_file = 0;
const ACE_TCHAR *idl_value = 0;
}
int
parse_args (int argc, ACE_TCHAR *argv[])
{
ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("i:s:"));
const unsigned char full_success = 0x03;
unsigned char success = 0;
while (true)
{
int c = get_opts ();
if (success == full_success)
{
break;
}
if (c == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"usage: %s"
" -i <ifr_ior>"
" -s <idl_valuetype>"
"\n",
argv [0]),
-1);
}
switch (c)
{
case 'i':
ifr_ior_file = get_opts.opt_arg ();
success |= 0x01;
break;
case 's':
idl_value = get_opts.opt_arg ();
success |= 0x02;
break;
}
}
// Indicates successful parsing of the command line
return 0;
}
// ----------------------------------------------------------------------
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
// init orb
CORBA::ORB_var the_orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) == -1)
{
return -1;
}
// get IFR
CORBA::Object_var objref =
the_orb->string_to_object (ifr_ior_file);
if (objref.in () == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"The received objref is nil\n"),
-1);
}
CORBA::ComponentIR::Repository_var the_repo_ref;
try
{
the_repo_ref = CORBA::ComponentIR::Repository::_narrow (objref.in ());
}
catch (CORBA::Exception &ex)
{
ex._tao_print_exception ("Can't narrow the IFR:");
return 1;
}
// search in repository
CORBA::Contained_var current_contained =
the_repo_ref->lookup_id (ACE_TEXT_ALWAYS_CHAR (idl_value));
if (CORBA::is_nil(current_contained.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Can't look up the valuetype\n"),
-1);
}
// get value type definition
CORBA::ExtValueDef_var value_def =
CORBA::ExtValueDef::_narrow (current_contained.in ());
CORBA::ExtValueDef::ExtFullValueDescription_var value_descr;
try
{
value_descr = value_def->describe_ext_value ();
}
catch (CORBA::Exception &ex)
{
ex._tao_print_exception ("Can't describe_ext_value:");
return 1;
}
CORBA::ValueMemberSeq& the_value_members =
value_descr->members;
for (CORBA::ULong ct = 0; ct < the_value_members.length (); ++ct)
{
const CORBA::ValueMember& current_member =
the_value_members [ct];
ACE_DEBUG ((LM_DEBUG,
"value type member '%C'\n",
current_member.name.in ()));
}
return 0;
}
|