Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_attribute / ccm_init.cpp
blob7175cdf71f945ddc86822b8b58e828507ffcaaf4
2 //=============================================================================
3 /**
4 * @file ccm_init.cpp
6 * Visitor for generation of code for CIAO component or home
7 * attribute initialization
9 * @author Jeff Parsons
11 //=============================================================================
13 #include "attribute.h"
15 be_visitor_attribute_ccm_init::be_visitor_attribute_ccm_init (
16 be_visitor_context *ctx)
17 : be_visitor_any_extracted_type_decl (ctx),
18 attr_ (nullptr)
22 be_visitor_attribute_ccm_init::~be_visitor_attribute_ccm_init (
27 int
28 be_visitor_attribute_ccm_init::visit_attribute (
29 be_attribute *node)
31 if (node->readonly ())
33 return 0;
36 be_interface *intf = this->ctx_->interface ();
38 if (intf != nullptr)
40 AST_Decl::NodeType snt = intf->node_type ();
41 AST_Decl::NodeType ant =
42 ScopeAsDecl (node->defined_in ())->node_type ();
44 if (snt == AST_Decl::NT_component
45 && ant == AST_Decl::NT_porttype)
47 return 0;
51 attr_ = node;
52 be_type *ft = dynamic_cast<be_type*> (node->field_type ());
53 return ft->accept (this);
56 int
57 be_visitor_attribute_ccm_init::visit_array (
58 be_array *)
60 this->emit_init_block ();
61 return 0;
64 int
65 be_visitor_attribute_ccm_init::visit_component (
66 be_component *)
68 this->emit_error ("component");
69 return 0;
72 int
73 be_visitor_attribute_ccm_init::visit_enum (
74 be_enum *)
76 this->emit_init_block ();
77 return 0;
80 int
81 be_visitor_attribute_ccm_init::visit_eventtype (
82 be_eventtype *)
84 this->emit_error ("eventtype");
85 return 0;
88 int
89 be_visitor_attribute_ccm_init::visit_home (
90 be_home *)
92 this->emit_error ("home");
93 return 0;
96 int
97 be_visitor_attribute_ccm_init::visit_interface (
98 be_interface *)
100 this->emit_error ("interface");
101 return 0;
105 be_visitor_attribute_ccm_init::visit_predefined_type (
106 be_predefined_type *)
108 this->emit_init_block ();
109 return 0;
113 be_visitor_attribute_ccm_init::visit_sequence (
114 be_sequence *)
116 this->emit_init_block ();
117 return 0;
121 be_visitor_attribute_ccm_init::visit_string (
122 be_string *)
124 this->emit_init_block ();
125 return 0;
129 be_visitor_attribute_ccm_init::visit_structure (
130 be_structure *)
132 this->emit_init_block ();
133 return 0;
137 be_visitor_attribute_ccm_init::visit_typedef (
138 be_typedef *node)
140 return node->primitive_base_type ()->accept (this);
144 be_visitor_attribute_ccm_init::visit_union (
145 be_union *)
147 this->emit_init_block ();
148 return 0;
152 be_visitor_attribute_ccm_init::visit_valuebox (
153 be_valuebox *)
155 this->emit_error ("valuebox");
156 return 0;
160 be_visitor_attribute_ccm_init::visit_valuetype (
161 be_valuetype *)
163 this->emit_error ("valuetype");
164 return 0;
167 void
168 be_visitor_attribute_ccm_init::emit_init_block ()
170 this->open_if_block ();
172 be_visitor_any_extracted_type_decl decl_emitter (this->ctx_);
173 be_type *ft = dynamic_cast<be_type*> (attr_->field_type ());
175 if (ft->accept (&decl_emitter) == -1)
177 ACE_ERROR ((LM_ERROR,
178 ACE_TEXT ("be_visitor_attribute_ccm_init")
179 ACE_TEXT ("::emit_init_block - ")
180 ACE_TEXT ("Any extraction type visitor ")
181 ACE_TEXT ("failed\n")));
183 return;
186 os_ << be_nl
187 << "if (!(descr_value >>= _extract_val))" << be_idt_nl
188 << "{" << be_idt_nl
189 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
190 << "}" << be_uidt_nl << be_nl
191 << "this->" << this->ctx_->port_prefix ().c_str ()
192 << attr_->local_name ()->get_string ()
193 << " (";
195 be_visitor_attribute_set_from_extracted arg_emitter (this->ctx_);
197 if (ft->accept (&arg_emitter) == -1)
199 ACE_ERROR ((LM_ERROR,
200 ACE_TEXT ("be_visitor_attribute_ccm_init")
201 ACE_TEXT ("::emit_init_block - ")
202 ACE_TEXT ("Attribute set type visitor ")
203 ACE_TEXT ("failed\n")));
205 return;
208 os_ << ");";
210 this->close_if_block ();
213 void
214 be_visitor_attribute_ccm_init::emit_error (
215 const char *corba_kind)
217 this->open_if_block ();
219 os_ << "ACE_ERROR ((LM_ERROR," << be_nl
220 << " \"CCM attributes of "
221 << corba_kind << "\"" << be_nl
222 << " \"IDL type are not yet "
223 << "supported by CIAO\\n\"));"
224 << be_nl_2
225 << "ACE_UNUSED_ARG (descr_value);" << be_nl;
227 this->close_if_block ();
230 void
231 be_visitor_attribute_ccm_init::open_if_block ()
233 os_ << be_nl_2
234 << "if (ACE_OS::strcmp (descr_name, \""
235 << this->ctx_->port_prefix ().c_str ()
236 << attr_->local_name ()->get_string ()
237 << "\") == 0)" << be_idt_nl
238 << "{" << be_idt_nl;
241 void
242 be_visitor_attribute_ccm_init::close_if_block ()
244 os_ << be_nl
245 << "continue;" << be_uidt_nl
246 << "}" << be_uidt;