Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_interface / tie_ss.cpp
blob156f84501230d12719d7ebe89e974ccf22262f25
2 //=============================================================================
3 /**
4 * @file tie_ss.cpp
6 * Visitor generating code for TIE classes for the Interface node in the
7 * inline file.
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 ()
25 int
26 be_visitor_interface_tie_ss::visit_interface (be_interface *node)
28 if (node->srv_inline_gen ()
29 || node->imported ()
30 || node->is_abstract ())
32 return 0;
35 static char fulltiename [NAMEBUFSIZE];
36 static char localtiename [NAMEBUFSIZE];
37 static char localskelname [NAMEBUFSIZE];
39 ACE_OS::memset (fulltiename,
40 '\0',
41 NAMEBUFSIZE);
42 ACE_OS::memset (localtiename,
43 '\0',
44 NAMEBUFSIZE);
45 ACE_OS::memset (localskelname,
46 '\0',
47 NAMEBUFSIZE);
49 // Generate the skeleton class name which will be used to determine the TIE
50 // class name.
52 // We are outermost.
53 ACE_OS::sprintf (fulltiename,
54 "%s_tie",
55 node->full_skel_name ());
57 if (!node->is_nested ())
59 ACE_OS::sprintf (localskelname,
60 "POA_%s",
61 node->local_name ());
62 ACE_OS::sprintf (localtiename,
63 "POA_%s_tie",
64 node->local_name ());
66 else
68 ACE_OS::sprintf (localskelname,
69 "%s",
70 node->local_name ());
71 ACE_OS::sprintf (localtiename,
72 "%s_tie",
73 node->local_name ());
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
85 << "{}" << be_nl_2;
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
93 << "{}" << be_nl_2;
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
101 << "{}" << be_nl_2;
103 *os << "template <class T>" << be_nl
104 << fulltiename << "<T>::" << localtiename
105 << " (T *tp, ::PortableServer::POA_ptr poa, ::CORBA::Boolean release)"
106 << be_idt_nl
107 << ": ptr_ (tp)," << be_idt_nl
108 << "poa_ (::PortableServer::POA::_duplicate (poa))," << be_nl
109 << "rel_ (release)" << be_uidt << be_uidt_nl
110 << "{}" << be_nl_2;
112 *os << "template <class T>" << be_nl
113 << fulltiename << "<T>::~" << localtiename << " ()" << be_nl
114 << "{" << be_idt_nl
115 << "if (this->rel_)" << be_idt_nl
116 << "{" << be_idt_nl
117 << "delete this->ptr_;" << be_uidt_nl
118 << "}" << be_uidt << be_uidt_nl
119 << "}" << be_nl_2;
121 *os << "template <class T> T *" << be_nl
122 << fulltiename << "<T>::_tied_object ()" << be_nl
123 << "{" << be_idt_nl
124 << "return this->ptr_;" << be_uidt_nl
125 << "}" << be_nl_2;
127 *os << "template <class T> void" << be_nl
128 << fulltiename << "<T>::_tied_object (T &obj)" << be_nl
129 << "{" << be_idt_nl
130 << "if (this->rel_)" << be_idt_nl
131 << "{" << 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
136 << "}" << be_nl_2;
138 *os << "template <class T> void" << be_nl
139 << fulltiename << "<T>::_tied_object (T *obj, "
140 << "::CORBA::Boolean release)" << be_nl
141 << "{" << be_idt_nl
142 << "if (this->rel_)" << be_idt_nl
143 << "{" << 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
148 << "}" << be_nl_2;
150 *os << "template <class T> ::CORBA::Boolean" << be_nl
151 << fulltiename << "<T>::_is_owner ()" << be_nl
152 << "{" << be_idt_nl
153 << "return this->rel_;" << be_uidt_nl
154 << "}" << be_nl_2;
156 *os << "template <class T> void" << be_nl
157 << fulltiename << "<T>::_is_owner (::CORBA::Boolean b)" << be_nl
158 << "{" << be_idt_nl
159 << "this->rel_ = b;" << be_uidt_nl
160 << "}" << be_nl_2;
162 *os << "template <class T> "
163 << "PortableServer::POA_ptr" << be_nl
164 << fulltiename
165 << "<T>::_default_POA ()" << be_nl
166 << "{" << be_idt_nl
167 << "if (! ::CORBA::is_nil (this->poa_.in ()))" << be_idt_nl
168 << "{" << be_idt_nl
169 << "return ::PortableServer::POA::_duplicate (this->poa_.in ());"
170 << be_uidt_nl
171 << "}" << be_uidt_nl << be_nl
172 << "return this->" << localskelname
173 << "::_default_POA ();" << be_uidt_nl
174 << "}";
176 int const status =
177 node->traverse_inheritance_graph (
178 be_visitor_interface_tie_ss::method_helper,
182 if (status == -1)
184 ACE_ERROR_RETURN ((LM_ERROR,
185 "be_visitor_interface_tie_sh_ss::"
186 "visit_interface - "
187 "traversal of inhertance graph failed\n"),
188 -1);
191 return 0;
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,
202 be_interface *node,
203 TAO_OutStream *os)
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 ())
211 return 0;
214 be_visitor_context ctx;
215 ctx.interface (derived);
216 ctx.stream (os);
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::"
225 "method_helper\n"),
226 -1);
229 return 0;