Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_interface / interface_ih.cpp
blob0ea927be15eaf44c966abd41fa8e889467b3bd00
2 //=============================================================================
3 /**
4 * @file interface_ih.cpp
6 * Visitor generating code for Interfaces in the implementation header
8 * @author Yamuna Krishnamurthy (yamuna@cs.wustl.edu)
9 */
10 //=============================================================================
12 #include "interface.h"
14 be_visitor_interface_ih::be_visitor_interface_ih (be_visitor_context *ctx)
15 : be_visitor_interface (ctx)
19 be_visitor_interface_ih::~be_visitor_interface_ih ()
23 int
24 be_visitor_interface_ih::visit_interface (be_interface *node)
26 if (node->impl_hdr_gen () || node->imported () || node->is_abstract ())
28 return 0;
31 TAO_OutStream *os = this->ctx_->stream ();
32 static char namebuf [NAMEBUFSIZE];
35 ACE_OS::memset (namebuf,
36 '\0',
37 NAMEBUFSIZE);
39 // Generate the skeleton class name.
41 ACE_OS::sprintf (namebuf, "%s", node->flat_name ());
43 if (be_global->gen_impl_debug_info ())
45 TAO_INSERT_COMMENT (os);
48 // Now generate the class definition.
49 *os << "class " << be_global->stub_export_macro ()
50 << " " << be_global->impl_class_prefix () << namebuf
51 << be_global->impl_class_suffix () << be_idt_nl << ": public virtual ";
53 // Inherit from the base skeleton name, unless the interface
54 // is local.
55 if (node->is_local ())
57 *os << node->full_name ();
59 else
61 *os << node->full_skel_name ();
64 if (node->is_local ())
66 *os << "," << be_idt_nl
67 << "public virtual ::CORBA::LocalObject"
68 << be_uidt;
71 *os << be_uidt_nl
72 << "{" << be_nl
73 << "public:" << be_idt_nl
74 << "// Constructor" << be_nl
75 << be_global->impl_class_prefix () << namebuf
76 << be_global->impl_class_suffix () << " ();" << be_nl_2;
78 if (be_global->gen_copy_ctor () && !node->is_local ())
80 *os << "// Copy Constructor"<<be_nl
81 << be_global->impl_class_prefix () << namebuf
82 << be_global->impl_class_suffix () << " (const "
83 << be_global->impl_class_prefix () << namebuf
84 << be_global->impl_class_suffix () << "&);" <<be_nl <<be_nl;
87 if (be_global->gen_assign_op ())
89 *os << "// Copy Assignment" << be_nl
90 << be_global->impl_class_prefix () << namebuf
91 << be_global->impl_class_suffix () << "& " << "operator=(const "
92 << be_global->impl_class_prefix () << namebuf
93 << be_global->impl_class_suffix () << "&);" << be_nl_2;
96 *os << "// Destructor" << be_nl
97 << "virtual " << "~" << be_global->impl_class_prefix () << namebuf
98 << be_global->impl_class_suffix () << " ();";
101 // Generate code for elements in the scope (e.g., operations).
102 if (this->visit_scope (node) == -1)
104 ACE_ERROR_RETURN ((LM_ERROR,
105 "be_visitor_interface_ih::"
106 "visit_interface - "
107 "codegen for scope failed\n"),
108 -1);
112 // Generate the code for the members of the derived classes.
113 int status =
114 node->traverse_inheritance_graph (
115 be_visitor_interface_ih::method_helper,
116 os);
118 if (status == -1)
120 ACE_ERROR_RETURN ((LM_ERROR,
121 "be_visitor_interface_tie_sh_ss::"
122 "visit_interface - "
123 "traversal of inhertance graph failed\n"),
124 -1);
128 *os << be_uidt_nl
129 << "};" << be_nl_2;
131 return 0;
135 // Helper method to generate members within the scope of the base classes.
137 be_visitor_interface_ih::method_helper (be_interface *derived,
138 be_interface *node,
139 TAO_OutStream *os)
141 int compare =
142 ACE_OS::strcmp (derived->flat_name (), node->flat_name ());
144 if (compare != 0)
146 be_visitor_context ctx;
147 ctx.state (TAO_CodeGen::TAO_ROOT_IH);
148 ctx.interface (derived);
149 ctx.stream (os);
150 be_visitor_interface_ih visitor (&ctx);
152 if (visitor.visit_scope (node) == -1)
154 ACE_ERROR_RETURN ((LM_ERROR,
155 "be_visitor_interface_is::"
156 "method_helper\n"),
157 -1);
161 return 0;