2 //=============================================================================
6 * Visitor generating code for Root in the server template header
10 //=============================================================================
14 be_visitor_root_sth::be_visitor_root_sth (be_visitor_context
*ctx
)
15 : be_visitor_root (ctx
)
19 be_visitor_root_sth::~be_visitor_root_sth ()
24 be_visitor_root_sth::visit_root (be_root
*node
)
26 if (! be_global
->gen_tie_classes ())
31 if (this->init () == -1)
33 ACE_ERROR_RETURN ((LM_ERROR
,
34 ACE_TEXT ("be_visitor_root_sth::init - ")
35 ACE_TEXT ("failed to initialize\n")),
39 if (this->visit_scope (node
) == -1)
41 ACE_ERROR_RETURN ((LM_ERROR
,
42 ACE_TEXT ("be_visitor_root_sth::visit_root - ")
43 ACE_TEXT ("codegen for scope failed\n")),
47 (void) tao_cg
->end_server_template_header ();
53 be_visitor_root_sth::visit_module (be_module
*node
)
55 if (node
->imported ())
60 TAO_OutStream
*os
= tao_cg
->server_template_header ();
62 // Generate the skeleton class name.
64 TAO_INSERT_COMMENT (os
);
66 // Now generate the class definition. The prefix POA_ is prepended to our
67 // name only if we are the outermost module.
70 if (node
->is_nested ())
72 // We are inside another module.
73 *os
<< node
->local_name () << be_nl
;
77 // We are outermost module.
78 *os
<< "POA_" << node
->local_name () << be_nl
;
83 if (this->visit_scope (node
) == -1)
85 ACE_ERROR_RETURN ((LM_ERROR
,
86 "(%N:%l) be_visitor_root_sth::"
88 "codegen for scope failed\n"),
92 *os
<< be_uidt_nl
<< "} // module " << node
->name ();
98 be_visitor_root_sth::visit_interface (be_interface
*node
)
100 if (node
->imported () || node
->is_local ())
105 // Generate the TIE class.
107 this->ctx_
->node (node
);
108 be_visitor_interface_tie_sh
visitor (this->ctx_
);
110 if (node
->accept (&visitor
) == -1)
112 ACE_ERROR_RETURN ((LM_ERROR
,
113 "be_visitor_root_sth::"
115 "codegen for TIE class failed\n"),
123 be_visitor_root_sth::visit_component (be_component
*node
)
125 return this->visit_interface (node
);
129 be_visitor_root_sth::init ()
131 /// First open the server-side file for writing
133 tao_cg
->start_server_template_header (
134 be_global
->be_get_server_template_hdr_fname ());
138 ACE_ERROR_RETURN ((LM_ERROR
,
139 ACE_TEXT ("be_visitor_root_sth::init - ")
140 ACE_TEXT ("Error opening server ")
141 ACE_TEXT ("template header file\n")),
145 /// Initialize the stream.
146 this->ctx_
->stream (tao_cg
->server_template_header ());