2 //=============================================================================
6 * Visitor generating code for TIE classes for the Interface node in the
9 * @author Aniruddha Gokhale
11 //=============================================================================
13 #include "interface.h"
15 be_visitor_interface_tie_ss::be_visitor_interface_tie_ss (
16 be_visitor_context
*ctx
)
17 : be_visitor_interface (ctx
)
21 be_visitor_interface_tie_ss::~be_visitor_interface_tie_ss ()
26 be_visitor_interface_tie_ss::visit_interface (be_interface
*node
)
28 if (node
->srv_inline_gen ()
30 || node
->is_abstract ())
35 static char fulltiename
[NAMEBUFSIZE
];
36 static char localtiename
[NAMEBUFSIZE
];
37 static char localskelname
[NAMEBUFSIZE
];
39 ACE_OS::memset (fulltiename
,
42 ACE_OS::memset (localtiename
,
45 ACE_OS::memset (localskelname
,
49 // Generate the skeleton class name which will be used to determine the TIE
53 ACE_OS::sprintf (fulltiename
,
55 node
->full_skel_name ());
57 if (!node
->is_nested ())
59 ACE_OS::sprintf (localskelname
,
62 ACE_OS::sprintf (localtiename
,
68 ACE_OS::sprintf (localskelname
,
71 ACE_OS::sprintf (localtiename
,
76 TAO_OutStream
*os
= this->ctx_
->stream ();
78 TAO_INSERT_COMMENT (os
);
80 *os
<< "template <class T>" << be_nl
81 << fulltiename
<< "<T>::" << localtiename
<< " (T &t)" << be_idt_nl
82 << ": ptr_ (std::addressof(t))," << be_idt_nl
83 << "poa_ (::PortableServer::POA::_nil ())," << be_nl
84 << "rel_ (false)" << be_uidt
<< be_uidt_nl
87 *os
<< "template <class T>" << be_nl
88 << fulltiename
<< "<T>::" << localtiename
89 << " (T &t, ::PortableServer::POA_ptr poa)" << be_idt_nl
90 << ": ptr_ (std::addressof(t))," << be_idt_nl
91 << "poa_ (::PortableServer::POA::_duplicate (poa))," << be_nl
92 << "rel_ (false)" << be_uidt
<< be_uidt_nl
95 *os
<< "template <class T>" << be_nl
96 << fulltiename
<< "<T>::" << localtiename
97 << " (T *tp, ::CORBA::Boolean release)" << be_idt_nl
98 << ": ptr_ (tp)," << be_idt_nl
99 << "poa_ (::PortableServer::POA::_nil ())," << be_nl
100 << "rel_ (release)" << be_uidt
<< be_uidt_nl
103 *os
<< "template <class T>" << be_nl
104 << fulltiename
<< "<T>::" << localtiename
105 << " (T *tp, ::PortableServer::POA_ptr poa, ::CORBA::Boolean release)"
107 << ": ptr_ (tp)," << be_idt_nl
108 << "poa_ (::PortableServer::POA::_duplicate (poa))," << be_nl
109 << "rel_ (release)" << be_uidt
<< be_uidt_nl
112 *os
<< "template <class T>" << be_nl
113 << fulltiename
<< "<T>::~" << localtiename
<< " ()" << be_nl
115 << "if (this->rel_)" << be_idt_nl
117 << "delete this->ptr_;" << be_uidt_nl
118 << "}" << be_uidt
<< be_uidt_nl
121 *os
<< "template <class T> T *" << be_nl
122 << fulltiename
<< "<T>::_tied_object ()" << be_nl
124 << "return this->ptr_;" << be_uidt_nl
127 *os
<< "template <class T> void" << be_nl
128 << fulltiename
<< "<T>::_tied_object (T &obj)" << be_nl
130 << "if (this->rel_)" << be_idt_nl
132 << "delete this->ptr_;" << be_uidt_nl
133 << "}" << be_uidt_nl
<< be_nl
134 << "this->ptr_ = std::addressof(obj);" << be_nl
135 << "this->rel_ = false;" << be_uidt_nl
138 *os
<< "template <class T> void" << be_nl
139 << fulltiename
<< "<T>::_tied_object (T *obj, "
140 << "::CORBA::Boolean release)" << be_nl
142 << "if (this->rel_)" << be_idt_nl
144 << "delete this->ptr_;" << be_uidt_nl
145 << "}" << be_uidt_nl
<< be_nl
146 << "this->ptr_ = obj;" << be_nl
147 << "this->rel_ = release;" << be_uidt_nl
150 *os
<< "template <class T> ::CORBA::Boolean" << be_nl
151 << fulltiename
<< "<T>::_is_owner ()" << be_nl
153 << "return this->rel_;" << be_uidt_nl
156 *os
<< "template <class T> void" << be_nl
157 << fulltiename
<< "<T>::_is_owner (::CORBA::Boolean b)" << be_nl
159 << "this->rel_ = b;" << be_uidt_nl
162 *os
<< "template <class T> "
163 << "PortableServer::POA_ptr" << be_nl
165 << "<T>::_default_POA ()" << be_nl
167 << "if (! ::CORBA::is_nil (this->poa_.in ()))" << be_idt_nl
169 << "return ::PortableServer::POA::_duplicate (this->poa_.in ());"
171 << "}" << be_uidt_nl
<< be_nl
172 << "return this->" << localskelname
173 << "::_default_POA ();" << be_uidt_nl
177 node
->traverse_inheritance_graph (
178 be_visitor_interface_tie_ss::method_helper
,
184 ACE_ERROR_RETURN ((LM_ERROR
,
185 "be_visitor_interface_tie_sh_ss::"
187 "traversal of inhertance graph failed\n"),
195 be_visitor_interface_tie_ss::visit_component (be_component
*node
)
197 return this->visit_interface (node
);
201 be_visitor_interface_tie_ss::method_helper (be_interface
*derived
,
205 // Any methods from abstract parents have already been
206 // "added" to the derived interface scope by the overridden
207 // visit_scope() method in be_visitor_interface, so we can skip
208 // this base interface, if it is abstract.
209 if (node
->is_abstract ())
214 be_visitor_context ctx
;
215 ctx
.interface (derived
);
217 ctx
.state (TAO_CodeGen::TAO_ROOT_TIE_SS
);
218 be_visitor_interface_tie_ss
visitor (&ctx
);
220 if (visitor
.visit_scope (node
) == -1)
223 ACE_ERROR_RETURN ((LM_ERROR
,
224 "be_visitor_interface_tie_ss::"