2 //=============================================================================
6 * Visitor generating code for TIE class for an Interface in the header
9 * @author Aniruddha Gokhale
11 //=============================================================================
13 #include "interface.h"
15 be_visitor_interface_tie_sh::be_visitor_interface_tie_sh (
16 be_visitor_context
*ctx
)
17 : be_visitor_interface (ctx
)
21 be_visitor_interface_tie_sh::~be_visitor_interface_tie_sh ()
26 be_visitor_interface_tie_sh::visit_interface (be_interface
*node
)
28 if (node
->imported () || node
->is_abstract ())
33 static char namebuf
[NAMEBUFSIZE
];
34 static char tiename
[NAMEBUFSIZE
];
36 ACE_OS::memset (namebuf
,
39 ACE_OS::memset (tiename
,
43 TAO_OutStream
*os
= this->ctx_
->stream ();
45 // Generate the skeleton class name which will be used to determine the TIE
48 // We shall have a POA_ prefix only if we are at the topmost level.
49 if (node
->is_nested ())
51 ACE_OS::sprintf (namebuf
,
54 ACE_OS::sprintf (tiename
,
61 ACE_OS::sprintf (namebuf
,
64 ACE_OS::sprintf (tiename
,
69 // Now generate the class definition.
70 TAO_INSERT_COMMENT (os
);
72 *os
<< "// TIE class: Refer to CORBA v2.2, Section 20.34.4" << be_nl
;
73 *os
<< "template <class T>" << be_nl
;
74 *os
<< "class " << " " << tiename
<< " : public " << namebuf
<< be_nl
;
76 << "public:" << be_idt_nl
77 << "/// the T& ctor" << be_nl
78 << tiename
<< " (T &t);" << be_nl
79 << "/// ctor taking a POA" << be_nl
80 << tiename
<< " (T &t, PortableServer::POA_ptr poa);" << be_nl
81 << "/// ctor taking pointer and an ownership flag" << be_nl
82 << tiename
<< " (T *tp, ::CORBA::Boolean release = true);" << be_nl
83 << "/// ctor with T*, ownership flag and a POA" << be_nl
84 << tiename
<< " (" << be_idt
<< be_idt_nl
86 << "PortableServer::POA_ptr poa," << be_nl
87 << "::CORBA::Boolean release = true);" << be_uidt
89 << "/// dtor" << be_nl
90 << "~" << tiename
<< " ();" << be_nl
91 << "// TIE specific functions" << be_nl
92 << "/// return the underlying object" << be_nl
93 << "T *_tied_object ();" << be_nl
94 << "/// set the underlying object" << be_nl
95 << "void _tied_object (T &obj);" << be_nl
96 << "/// set the underlying object and the ownership flag" << be_nl
97 << "void _tied_object (T *obj, ::CORBA::Boolean release = true);" << be_nl
98 << "/// do we own it" << be_nl
99 << "::CORBA::Boolean _is_owner ();" << be_nl
100 << "/// set the ownership" << be_nl_2
101 << "void _is_owner (::CORBA::Boolean b);" << be_nl
102 << "// overridden ServantBase operations" << be_nl
103 << "PortableServer::POA_ptr _default_POA ();";
106 node
->traverse_inheritance_graph (
107 be_visitor_interface_tie_sh::method_helper
,
113 ACE_ERROR_RETURN ((LM_ERROR
,
114 "be_visitor_interface_tie_sh_ss::"
116 "traversal of inhertance graph failed\n"),
120 *os
<< be_uidt_nl
<< be_nl
121 << "private:" << be_idt_nl
122 << "T *ptr_;" << be_nl
123 << "PortableServer::POA_var poa_;" << be_nl
124 << "::CORBA::Boolean rel_;" << be_nl_2
125 << tiename
<< " (const " << tiename
<< " &) = delete;" << be_nl
126 << "void operator= (const " << tiename
<< " &) = delete;" << be_uidt_nl
133 be_visitor_interface_tie_sh::visit_component (be_component
*node
)
135 return this->visit_interface (node
);
139 be_visitor_interface_tie_sh::method_helper (be_interface
*,
143 // Any methods from abstract parents have already been
144 // "added" to the derived interface scope by the overridden
145 // visit_scope() method in be_visitor_interface, so we can skip
146 // this base interface, if it is abstract.
147 if (node
->is_abstract ())
152 be_visitor_context ctx
;
154 ctx
.state (TAO_CodeGen::TAO_ROOT_TIE_SH
);
155 be_visitor_interface_tie_sh
visitor (&ctx
);
157 if (visitor
.visit_scope (node
) == -1)
159 ACE_ERROR_RETURN ((LM_ERROR
,
160 "be_visitor_interface_tie_sh::"