Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_interface / interface_is.cpp
blobd786778da987ba103e260721f4eeb95a68a1ddd8
2 //=============================================================================
3 /**
4 * @file interface_is.cpp
6 * Visitor generating code for Interfaces in the implementation skeletons file.
8 * @author Yamuna Krishnamurthy (yamuna@cs.wustl.edu)
9 */
10 //=============================================================================
12 #include "interface.h"
14 be_visitor_interface_is::be_visitor_interface_is (be_visitor_context *ctx)
15 : be_visitor_interface (ctx)
19 be_visitor_interface_is::~be_visitor_interface_is ()
23 int
24 be_visitor_interface_is::visit_interface (be_interface *node)
26 if (node->impl_skel_gen () || node->imported () || node->is_abstract ())
28 return 0;
31 this->ctx_->interface (node);
32 TAO_OutStream *os = this->ctx_->stream ();
34 // Generate the skeleton class name.
36 if (be_global->gen_impl_debug_info ())
38 TAO_INSERT_COMMENT (os);
41 *os << "// Implementation skeleton constructor" << be_nl;
43 // Find if we are at the top scope or inside some module.
44 *os << be_global->impl_class_prefix () << node->flat_name ()
45 << be_global->impl_class_suffix () <<"::"
46 << be_global->impl_class_prefix () << node->flat_name ()
47 << be_global->impl_class_suffix ()
48 << " ()" << be_nl;
50 *os << "{" << be_nl
51 << "}" << be_nl_2;
53 os->indent ();
54 *os << "// Implementation skeleton destructor" << be_nl;
56 *os << be_global->impl_class_prefix () << node->flat_name ()
57 << be_global->impl_class_suffix () <<"::~"
58 << be_global->impl_class_prefix () << node->flat_name ()
59 << be_global->impl_class_suffix ()
60 << " ()" << be_nl;
62 *os << "{" <<be_nl;
63 *os << "}" << be_nl_2;
65 if (be_global->gen_copy_ctor () && !node->is_local ())
67 *os << "//Implementation Skeleton Copy Constructor" << be_nl;
69 *os << be_global->impl_class_prefix () << node->flat_name ()
70 << be_global->impl_class_suffix () <<"::"
71 << be_global->impl_class_prefix () << node->flat_name ()
72 << be_global->impl_class_suffix () << " (const "
73 << be_global->impl_class_prefix () << node->flat_name ()
74 << be_global->impl_class_suffix () << "& rhs)" << be_idt_nl
75 << ": TAO_Abstract_ServantBase (rhs)," << be_nl
76 << " TAO_ServantBase (rhs)";
78 if (node->traverse_inheritance_graph (be_interface::copy_ctor_helper,
79 os)
80 == -1)
82 ACE_ERROR_RETURN ((LM_ERROR,
83 "be_visitor_interface_is::visit_interface - "
84 " copy ctor generation failed\n"),
85 -1);
88 if (!node->is_local ())
90 *os << "," << be_nl;
92 if (node->is_nested ())
94 be_decl *scope = nullptr;
95 scope = dynamic_cast<be_scope*> (node->defined_in ())->decl ();
97 *os << " POA_" << scope->name () << "::"
98 << node->local_name () << " (rhs)";
100 else
102 *os << " " << node->full_skel_name () << " (rhs)";
106 *os << be_uidt_nl
107 << "{" << be_nl
108 << "}" << be_nl << be_uidt_nl;
111 if (be_global->gen_assign_op ())
113 *os << "//Implementation Skeleton Copy Assignment" << be_nl;
115 *os << be_global->impl_class_prefix () << node->flat_name ()
116 << be_global->impl_class_suffix () << "& "
117 << be_global->impl_class_prefix () << node->flat_name ()
118 << be_global->impl_class_suffix () << "::operator=(const "
119 << be_global->impl_class_prefix () << node->flat_name ()
120 << be_global->impl_class_suffix () << "& t)" <<be_idt_nl
121 << "{" << be_idt_nl
122 << "return *this;" << be_uidt_nl
123 << "}" << be_nl << be_uidt_nl;
126 // Generate code for elements in the scope (e.g., operations).
128 if (this->visit_scope (node) == -1)
130 ACE_ERROR_RETURN ((LM_ERROR,
131 "be_visitor_interface_is::"
132 "visit_interface - "
133 "codegen for scope failed\n"),
134 -1);
137 int status =
138 node->traverse_inheritance_graph (
139 be_visitor_interface_is::method_helper,
143 if (status == -1)
145 ACE_ERROR_RETURN ((LM_ERROR,
146 "be_visitor_interface_is::"
147 "visit_interface - "
148 "traversal of inhertance graph failed\n"),
149 -1);
152 return 0;
156 // Helper method to generate the members in the scope of the base classes.
158 be_visitor_interface_is::method_helper (be_interface *derived,
159 be_interface *node,
160 TAO_OutStream *os)
162 if (ACE_OS::strcmp (derived->flat_name (), node->flat_name ()) != 0)
164 be_visitor_context ctx;
165 ctx.state (TAO_CodeGen::TAO_ROOT_IS);
166 ctx.interface (derived);
167 ctx.stream (os);
168 be_visitor_interface_is visitor (&ctx);
170 if (visitor.visit_scope (node) == -1)
173 ACE_ERROR_RETURN ((LM_ERROR,
174 "be_visitor_interface_is::"
175 "method_helper\n"),
176 -1);
181 return 0;