Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_interface / facet_svts.cpp
blob441df38fd93508083a059dbb88ad81f48ade9bcd
2 //=============================================================================
3 /**
4 * @file facet_svts.cpp
6 * Visitor generating code for a facet servant class in the
7 * servant source.
9 * @author Jeff Parsons
11 //=============================================================================
13 #include "interface.h"
15 be_visitor_facet_svts::be_visitor_facet_svts (be_visitor_context *ctx)
16 : be_visitor_interface (ctx)
20 be_visitor_facet_svts::~be_visitor_facet_svts ()
24 int
25 be_visitor_facet_svts::visit_interface (be_interface *node)
27 if (node->imported () ||
28 node->svnt_src_facet_gen () ||
29 idl_global->ami_connector_seen_ ||
30 node->original_interface () ||
31 node->is_local ())
33 return 0;
36 const char *lname = node->local_name ();
38 be_decl *scope =
39 dynamic_cast<be_scope*> (node->defined_in ())->decl ();
41 ACE_CString sname_str (scope->full_name ());
43 const char *global = (sname_str == "" ? "" : "::");
45 ACE_CString suffix (scope->flat_name ());
47 if (suffix != "")
49 suffix = ACE_CString ("_") + suffix;
52 os_ << be_nl_2
53 << "namespace CIAO_FACET" << suffix.c_str () << be_nl
54 << "{" << be_idt_nl;
56 os_ << "template <typename BASE, typename EXEC, typename CONTEXT>" << be_nl
57 << lname << "_Servant_T<BASE, EXEC, CONTEXT>::"
58 << lname << "_Servant_T (" << be_idt << be_idt_nl
59 << "typename EXEC::_ptr_type executor," << be_nl
60 << "::Components::CCMContext_ptr ctx)" << be_uidt_nl
61 << ": " << global << "CIAO::Facet_Servant_Base_T<BASE, EXEC, "
62 << "CONTEXT> (executor, ctx)"
63 << be_uidt_nl
64 << "{" << be_nl
65 << "}";
67 os_ << be_nl_2 << "template <typename BASE, typename EXEC, typename CONTEXT>" << be_nl
68 << lname << "_Servant_T<BASE, EXEC, CONTEXT>::~"
69 << lname << "_Servant_T ()" << be_nl
70 << "{" << be_nl
71 << "}";
73 bool is_intf = node->node_type () == AST_Decl::NT_interface;
75 if (is_intf)
77 be_interface *op_scope =
78 dynamic_cast<be_interface*> (node);
80 os_ << be_nl_2
81 << "// All facet operations and attributes.";
83 /// The overload of traverse_inheritance_graph() used here
84 /// doesn't automatically prime the queues.
85 op_scope->get_insert_queue ().reset ();
86 op_scope->get_del_queue ().reset ();
87 op_scope->get_insert_queue ().enqueue_tail (op_scope);
89 be_facet_op_attr_defn_helper helper (op_scope);
91 int status =
92 op_scope->traverse_inheritance_graph (helper,
93 &os_,
94 false,
95 false);
97 if (status == -1)
99 ACE_ERROR_RETURN ((LM_ERROR,
100 ACE_TEXT ("be_provides::")
101 ACE_TEXT ("gen_facet_svnt_defn - ")
102 ACE_TEXT ("traverse_inheritance_graph() ")
103 ACE_TEXT ("failed\n")),
104 -1);
108 os_ << be_uidt_nl << "}";
110 node->svnt_src_facet_gen (true);
111 return 0;
114 // ********************************************
116 be_facet_op_attr_defn_helper::be_facet_op_attr_defn_helper (
117 be_interface *op_scope)
118 : op_scope_ (op_scope)
123 be_facet_op_attr_defn_helper::emit (be_interface * /* derived_interface */,
124 TAO_OutStream *os,
125 be_interface *base_interface)
127 AST_Decl::NodeType nt = base_interface->node_type ();
129 if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector)
131 return 0;
134 be_visitor_context ctx;
135 ctx.stream (os);
136 ctx.state (TAO_CodeGen::TAO_ROOT_SVTS);
138 for (UTL_ScopeActiveIterator i (base_interface, UTL_Scope::IK_decls);
139 !i.is_done ();
140 i.next ())
142 AST_Decl *d = i.item ();
143 AST_Decl::NodeType nt = d->node_type ();
145 switch (nt)
147 case AST_Decl::NT_op:
149 be_operation *op =
150 dynamic_cast<be_operation*> (d);
152 /// If AMI implied IDL was generated for the
153 /// original interface, we don't want those
154 /// extra operations in the facet servant.
155 if (op->is_sendc_ami ())
157 continue;
160 be_visitor_operation_svs v (&ctx);
161 v.scope (op_scope_);
163 if (v.visit_operation (op) == -1)
165 ACE_ERROR_RETURN ((LM_ERROR,
166 ACE_TEXT ("be_facet_op_attr_defn_helper")
167 ACE_TEXT ("::emit - ")
168 ACE_TEXT ("visit_operation() failed\n")),
169 -1);
172 break;
174 case AST_Decl::NT_attr:
176 be_attribute *attr =
177 dynamic_cast<be_attribute*> (d);
179 be_visitor_attribute v (&ctx);
180 v.op_scope (op_scope_);
182 if (v.visit_attribute (attr) == -1)
184 ACE_ERROR_RETURN ((LM_ERROR,
185 ACE_TEXT ("be_facet_op_attr_defn_helper")
186 ACE_TEXT ("::emit - ")
187 ACE_TEXT ("visit_attribute() failed\n")),
188 -1);
191 break;
193 default:
194 continue;
198 return 0;
201 // ********************************************