Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_component / servant_svs.cpp
blob34f73a86050fe8aca0e707ac317e89e973ee6447
1 //=============================================================================
2 /**
3 * @file servant_svs.cpp
5 * Visitor generating code for a servant class in the
6 * servant source file.
8 * @author Jeff Parsons
9 */
10 //=============================================================================
12 #include "component.h"
14 be_visitor_servant_svs::be_visitor_servant_svs (be_visitor_context *ctx)
15 : be_visitor_component_scope (ctx),
16 op_scope_ (nullptr)
20 int
21 be_visitor_servant_svs::visit_component (be_component *node)
23 // This visitor is spawned by be_visitor_component_svh,
24 // which already does a check for imported node, so none
25 // is needed here.
26 node_ = node;
28 AST_Decl *scope = ScopeAsDecl (node_->defined_in ());
29 ACE_CString sname_str (scope->full_name ());
30 const char *sname = sname_str.c_str ();
31 const char *lname = node->local_name ();
32 const char *global = (sname_str == "" ? "" : "::");
33 AST_Decl::NodeType nt = this->node_->node_type ();
35 bool const is_connector = (nt == AST_Decl::NT_connector);
36 bool no_events = false;
38 if (!is_connector)
40 no_events =
41 (node->n_consumes () == 0UL
42 && node->n_emits () == 0UL
43 && node->n_publishes () == 0UL);
46 bool const de_facto = (is_connector || no_events);
48 const char *opt_conn =
49 (de_facto ? "Connector_" : "");
51 os_ << be_nl_2
52 << lname << "_Servant::"
53 << lname << "_Servant (" << be_idt << be_idt << be_idt_nl
54 << global << sname << "::CCM_" << lname
55 << "_ptr exe," << be_nl
56 << "::Components::CCMHome_ptr h," << be_nl
57 << "const char * ins_name," << be_nl
58 << "::CIAO::Home_Servant_Impl_Base * hs," << be_nl
59 << "::CIAO::" << be_global->ciao_container_type ()
60 << "_Container_ptr c)" << be_uidt << be_uidt_nl
61 << ": ::CIAO::" << opt_conn
62 << "Servant_Impl_Base (h, hs, c)," << be_idt_nl
63 << "::CIAO::" << be_global->ciao_container_type ()
64 << "_Servant_Impl_T<" << be_idt_nl
65 << "::" << node_->full_skel_name ()
66 << "," << be_nl
67 << global << sname << "::CCM_"
68 << lname << "," << be_nl
69 << lname << "_Context_T< " << be_idt_nl
70 << "::CIAO::" << be_global->ciao_container_type ()
71 << "_Container, ::CIAO::" << be_global->ciao_container_type () << "_Context_Impl_T< "
72 << be_idt_nl << global << sname << "::CCM_" << lname << "_Context, " << be_nl
73 << global << sname << "::" << lname << "> > > (exe, h, ins_name, hs, c)"
74 << be_uidt << be_uidt << be_uidt << be_uidt << be_uidt_nl
75 << "{" << be_idt_nl;
77 be_visitor_obv_factory_reg ofr_visitor (this->ctx_);
79 if (ofr_visitor.visit_component_scope (node) == -1)
81 ACE_ERROR_RETURN ((LM_ERROR,
82 "be_visitor_servant_svs::"
83 "visit_component - "
84 "OBV factory registration failed\n"),
85 -1);
88 /// If a component has neither facets nor event sinks, the
89 /// setup methods aren't generated.
90 if (this->node_->n_remote_provides () > 0UL
91 || this->node_->n_consumes () > 0UL)
93 be_visitor_populate_port_tables ppt_visitor (this->ctx_);
95 if (ppt_visitor.visit_component_scope (node) == -1)
97 ACE_ERROR_RETURN ((LM_ERROR,
98 "be_visitor_servant_svs::"
99 "visit_component - "
100 "populate port tables visitor failed\n"),
101 -1);
105 os_ << be_uidt_nl << "}";
107 os_ << be_nl_2
108 << lname << "_Servant::~"
109 << lname << "_Servant ()" << be_nl
110 << "{" << be_nl
111 << "}";
113 if (this->node_->has_rw_attributes ())
115 os_ << be_nl_2
116 << "void" << be_nl
117 << lname << "_Servant::set_attributes (" << be_idt_nl
118 << "const ::Components::ConfigValues & descr)"
119 << be_uidt_nl
120 << "{" << be_idt_nl;
122 os_ << "for (::CORBA::ULong i = 0; i < descr.length (); ++i)"
123 << be_idt_nl
124 << "{" << be_idt_nl
125 << "const char * descr_name = descr[i]->name ();"
126 << be_nl
127 << "::CORBA::Any & descr_value = descr[i]->value ();";
129 be_visitor_attr_set as_visitor (this->ctx_);
131 /// This will get assigned to the visitor's interface_
132 /// member later so it can catch and skip porttype
133 /// attributes in a component.
134 as_visitor.node (this->node_);
136 if (as_visitor.visit_component_scope (node) == -1)
138 ACE_ERROR_RETURN ((LM_ERROR,
139 "servant_svs::"
140 "visit_component - "
141 "attr init visitor failed\n"),
142 -1);
145 os_ << be_uidt_nl
146 << "}" << be_uidt << be_uidt_nl
147 << "}";
150 os_ << be_nl_2
151 << "/// Supported operations and attributes.";
153 this->op_scope_ = node;
155 /// This overload of traverse_inheritance_graph() used here
156 /// doesn't automatically prime the queues.
157 this->node_->get_insert_queue ().reset ();
158 this->node_->get_del_queue ().reset ();
159 this->node_->get_insert_queue ().enqueue_tail (node);
161 Component_Op_Attr_Generator op_attr_gen (this);
163 int status =
164 this->node_->traverse_inheritance_graph (op_attr_gen,
165 &os_,
166 false,
167 false);
169 if (status == -1)
171 ACE_ERROR_RETURN ((LM_ERROR,
172 "be_visitor_servant_svs::"
173 "visit_component - "
174 "inheritance graph traversal failed\n"),
175 -1);
178 os_ << be_nl_2
179 << "/// All ports and component attributes.";
181 /// Port operations that require scope traversal to get all the
182 /// possible string name matches.
184 this->gen_provides_top ();
185 this->gen_uses_top ();
187 /// If we are visiting a connector we can skip these.
188 if (this->node_->node_type () == AST_Decl::NT_component)
190 this->gen_publishes_top ();
191 this->gen_emits_top ();
194 /// This call will generate all other operations and attributes,
195 /// including inherited ones.
196 if (this->visit_component_scope (node) == -1)
198 ACE_ERROR_RETURN ((LM_ERROR,
199 "be_visitor_servant_svs::"
200 "visit_component - "
201 "visit_component_scope() failed\n"),
202 -1);
205 return 0;
209 be_visitor_servant_svs::visit_connector (be_connector *node)
211 return this->visit_component (node);
215 be_visitor_servant_svs::visit_operation (be_operation *node)
217 AST_Decl::NodeType nt =
218 ScopeAsDecl (node->defined_in ())->node_type ();
220 // Components have implied IDL operations added to the AST, but
221 // we are interested only in supported interface operations.
222 if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector)
224 return 0;
227 be_visitor_operation_svs v (this->ctx_);
228 v.scope (this->op_scope_);
230 return v.visit_operation (node);
234 be_visitor_servant_svs::visit_attribute (be_attribute *node)
236 AST_Decl::NodeType nt = this->node_->node_type ();
238 // Executor attribute code generated for porttype attributes
239 // always in connectors and only for mirrorports in components.
240 if (this->in_ext_port_ && nt == AST_Decl::NT_component)
242 return 0;
245 this->ctx_->interface (this->node_);
246 be_visitor_attribute v (this->ctx_);
248 v.for_facets (false);
249 v.op_scope (this->op_scope_);
251 return v.visit_attribute (node);
255 be_visitor_servant_svs::visit_provides (be_provides *node)
257 if (node->provides_type ()->is_local ()) // @TODO || be_global->gen_lwccm ())
259 return 0;
262 ACE_CString prefix (this->ctx_->port_prefix ());
263 prefix += node->local_name ()->get_string ();
264 const char *port_name = prefix.c_str ();
266 AST_Type *obj = node->provides_type ();
267 const char *obj_name = obj->full_name ();
268 AST_Decl *scope = ScopeAsDecl (obj->defined_in ());
269 ACE_CString sname_str (scope->full_name ());
270 const char *sname = sname_str.c_str ();
272 // Avoid '_cxx_' prefix.
273 const char *lname =
274 obj->original_local_name ()->get_string ();
276 const char *global = (sname_str == "" ? "" : "::");
277 const char *prefix_connector = (sname_str == "" ? "" : "_");
279 if (!be_global->gen_lwccm ())
281 os_ << be_nl_2
282 << "::" << obj_name << "_ptr" << be_nl
283 << node_->local_name () << "_Servant::provide_"
284 << port_name << " ()" << be_nl
285 << "{" << be_idt_nl;
287 os_ << "return" << be_idt_nl
288 << "::" << obj_name << "::_duplicate (this->provide_"
289 << port_name << "_.in ());" << be_uidt << be_uidt_nl
290 << "}";
293 os_ << be_nl_2
294 << "void" << be_nl
295 << node_->local_name () << "_Servant::setup_"
296 << port_name << "_i ()" << be_nl
297 << "{" << be_idt_nl
298 << "ACE_CString obj_id (this->ins_name_);" << be_nl
299 << "obj_id += \"_" << port_name << "\";" << be_nl_2
300 << "::CIAO::Container_var cnt_safe =" << be_idt_nl
301 << "::CIAO::Container::_duplicate ("
302 << "this->container_.in ());" << be_uidt_nl << be_nl
303 << "if (::CORBA::is_nil (cnt_safe.in ()))" << be_idt_nl
304 << "{" << be_idt_nl << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
305 << "}" << be_uidt_nl << be_nl
306 << "PortableServer::POA_var POA = cnt_safe->the_port_POA ();" << be_nl
307 << "::CORBA::Object_var tmp =" << be_idt_nl
308 << "this->get_facet_executor (\"" << port_name << "\");"<< be_uidt_nl << be_nl
309 << global << sname << "::CCM_" << lname << "_var tmp_var = " << be_idt_nl
310 << global << sname <<"::CCM_" << lname
311 << "::_narrow (tmp.in());" << be_uidt_nl << be_nl
312 << "typedef " << global << "CIAO_FACET" << prefix_connector
313 << scope->flat_name () << "::" << obj->local_name () << "_Servant_T <" << be_idt_nl
314 << "POA_" << sname << global << obj->local_name ()
315 << "," << be_nl << global << sname <<"::CCM_" << lname << "," << be_nl
316 << global << "Components::" << be_global->ciao_container_type ()
317 << "Context>" << be_idt_nl << lname
318 << "_type;" << be_uidt_nl << be_uidt_nl
319 << lname << "_type *" << port_name << "_servant_impl = 0;" << be_nl
320 << "ACE_NEW_THROW_EX (" << be_idt_nl
321 << port_name << "_servant_impl," << be_nl
322 << lname << "_type (" << be_idt_nl
323 << "tmp_var.in(), " << be_nl
324 << "this->context_)," << be_uidt_nl
325 << "CORBA::NO_MEMORY ());" << be_uidt_nl << be_nl
326 << "PortableServer::ServantBase_var safe_base_servant ("
327 << port_name << "_servant_impl);" << be_nl << be_nl
328 << "PortableServer::ObjectId_var " << port_name << "_servant_oid =" << be_idt_nl
329 << "PortableServer::string_to_ObjectId (obj_id.c_str());" << be_uidt_nl << be_nl
330 << "POA->activate_object_with_id(" << port_name << "_servant_oid.in(),"
331 << port_name << "_servant_impl);" << be_nl
332 << "::CORBA::Object_var " << port_name << "_servant_impl_obj = " << be_idt_nl
333 << "cnt_safe->generate_reference ( " << be_idt_nl
334 << "obj_id.c_str ()," << be_nl
335 << "\"" << obj->repoID () << "\"," << be_nl
336 << "::CIAO::Container_Types::FACET_CONSUMER_t);"
337 << be_uidt_nl << be_uidt_nl
338 << "this->add_facet (\"" << port_name << "\", " << port_name << "_servant_impl_obj.in ());"
339 << be_uidt_nl
340 << "}";
342 return 0;
346 be_visitor_servant_svs::visit_uses (be_uses *node)
348 if (node->uses_type ()->is_local () || be_global->gen_lwccm ())
350 return 0;
353 ACE_CString prefix (this->ctx_->port_prefix ());
354 prefix += node->local_name ()->get_string ();
355 const char *port_name = prefix.c_str ();
357 const char *obj_name = node->uses_type ()->full_name ();
358 bool const is_multiple = node->is_multiple ();
360 os_ << be_nl_2
361 << (is_multiple ? "::Components::Cookie *" : "void")
362 << be_nl
363 << node_->local_name () << "_Servant::connect_"
364 << port_name << " (" << be_idt_nl
365 << "::" << obj_name << "_ptr c)" << be_uidt_nl
366 << "{" << be_idt_nl;
368 if (is_multiple)
370 os_ << "return ";
373 os_ << "this->context_->connect_" << port_name
374 << " (c);" << be_uidt_nl
375 << "}";
377 os_ << be_nl_2
378 << "::" << obj_name << "_ptr" << be_nl
379 << node_->local_name () << "_Servant::disconnect_"
380 << port_name << " (";
382 if (is_multiple)
384 os_ << be_idt_nl
385 << "::Components::Cookie * ck" << be_uidt;
387 else
389 os_ << "void";
392 os_ << ")" << be_nl
393 << "{" << be_idt_nl
394 << "return this->context_->disconnect_"
395 << port_name << " (" << (is_multiple ? "ck" : "")
396 << ");" << be_uidt_nl
397 << "}";
399 os_ << be_nl_2
400 << "::";
402 if (is_multiple)
404 os_ << node_->full_name () << "::" << port_name
405 << "Connections *";
407 else
409 os_ << obj_name << "_ptr";
412 os_ << be_nl
413 << node_->local_name () << "_Servant::get_connection"
414 << (is_multiple ? "s" : "") << "_"
415 << port_name << " ()" << be_nl
416 << "{" << be_idt_nl
417 << "return this->context_->get_connection"
418 << (is_multiple ? "s" : "") << "_"
419 << port_name << " ();" << be_uidt_nl
420 << "}";
422 return 0;
426 be_visitor_servant_svs::visit_publishes (be_publishes *node)
428 if (be_global->gen_lwccm ())
430 return 0;
433 const char *obj_name = node->publishes_type ()->full_name ();
434 const char *port_name = node->local_name ()->get_string ();
436 os_ << be_nl_2
437 << "::Components::Cookie *" << be_nl
438 << node_->local_name () << "_Servant::subscribe_"
439 << port_name << " (" << be_idt_nl
440 << "::" << obj_name << "Consumer_ptr c)" << be_uidt_nl
441 << "{" << be_idt_nl;
443 os_ << "return this->context_->subscribe_" << port_name
444 << " (c);" << be_uidt_nl
445 << "}";
447 os_ << be_nl_2
448 << "::" << obj_name << "Consumer_ptr" << be_nl
449 << node_->local_name () << "_Servant::unsubscribe_"
450 << port_name << " (" << be_idt_nl
451 << "::Components::Cookie * ck)" << be_uidt_nl
452 << "{" << be_idt_nl;
454 os_ << "return this->context_->unsubscribe_" << port_name
455 << " (ck);" << be_uidt_nl
456 << "}";
458 return 0;
462 be_visitor_servant_svs::visit_emits (be_emits *node)
464 if (be_global->gen_lwccm ())
466 return 0;
469 const char *obj_name = node->emits_type ()->full_name ();
470 const char *port_name = node->local_name ()->get_string ();
472 os_ << be_nl_2
473 << "void" << be_nl
474 << node_->local_name () << "_Servant::connect_"
475 << port_name << " (" << be_idt_nl
476 << "::" << obj_name << "Consumer_ptr c)" << be_uidt_nl
477 << "{" << be_idt_nl
478 << "this->context_->connect_" << port_name
479 << " (c);" << be_uidt_nl
480 << "}";
482 os_ << be_nl_2
483 << "::" << obj_name << "Consumer_ptr" << be_nl
484 << node_->local_name () << "_Servant::disconnect_"
485 << port_name << " ()" << be_nl
486 << "{" << be_idt_nl
487 << "return this->context_->disconnect_"
488 << port_name << " ();" << be_uidt_nl
489 << "}";
491 return 0;
495 be_visitor_servant_svs::visit_consumes (be_consumes *node)
497 AST_Type *obj = node->consumes_type ();
498 const char *port_name = node->local_name ()->get_string ();
500 const char *comp_lname = node_->local_name ();
501 ACE_CString comp_sname_str (
502 ScopeAsDecl (node_->defined_in ())->full_name ());
503 const char *comp_sname = comp_sname_str.c_str ();
504 const char *global = (comp_sname_str == "" ? "" : "::");
506 const char *lname = obj->local_name ()->get_string ();
507 const char *fname = obj->full_name ();
509 os_ << be_nl_2
510 << comp_lname << "_Servant::" << lname << "Consumer_"
511 << port_name << "_Servant::" << lname << "Consumer_"
512 << port_name << "_Servant (" << be_idt << be_idt_nl
513 << global << comp_sname << "::CCM_" << comp_lname
514 << "_ptr executor," << be_nl
515 << global << comp_sname << "::CCM_" << comp_lname
516 << "_Context_ptr c)" << be_uidt_nl
517 << ": executor_ ( " << global << comp_sname << "::CCM_"
518 << comp_lname << "::_duplicate (executor))," << be_idt_nl
519 << "ctx_ ( " << global << comp_sname
520 << "::CCM_" << comp_lname
521 << "_Context::_duplicate (c))" << be_uidt << be_uidt_nl
522 << "{" << be_nl
523 << "}";
525 os_ << be_nl_2
526 << comp_lname << "_Servant::" << lname << "Consumer_"
527 << port_name << "_Servant::~" << lname << "Consumer_"
528 << port_name << "_Servant ()" << be_nl
529 << "{" << be_nl
530 << "}";
532 os_ << be_nl_2
533 << "::CORBA::Object_ptr" << be_nl
534 << comp_lname << "_Servant::" << lname << "Consumer_"
535 << port_name << "_Servant::_get_component ()" << be_nl
536 << "{" << be_idt_nl;
538 if (ACE_OS::strcmp (be_global->ciao_container_type (), "Session") == 0)
540 os_ << "return this->ctx_->get_CCM_object ();";
542 else
544 os_ << "return ::CORBA::Object::_nil ();";
547 os_ << be_uidt_nl << "}";
549 os_ << be_nl_2
550 << "void" << be_nl
551 << comp_lname << "_Servant::" << lname << "Consumer_"
552 << port_name << "_Servant::push_" << lname
553 << " (" << be_idt_nl
554 << "::" << fname << " * evt)" << be_uidt_nl
555 << "{" << be_idt_nl
556 << "this->executor_->push_" << port_name
557 << " (evt);" << be_uidt_nl
558 << "}";
560 os_ << be_nl_2
561 << "/// Inherited from ::Components::EventConsumerBase."
562 << be_nl
563 << "void" << be_nl
564 << comp_lname << "_Servant::" << lname << "Consumer_"
565 << port_name << "_Servant::push_event (" << be_idt_nl
566 << "::Components::EventBase * ev)" << be_uidt_nl
567 << "{" << be_idt_nl
568 << "::" << fname << " * ev_type =" << be_idt_nl
569 << "::" << fname << "::_downcast (ev);"
570 << be_uidt_nl << be_nl
571 << "if (ev_type != 0)" << be_idt_nl
572 << "{" << be_idt_nl
573 << "this->push_" << lname << " (ev_type);" << be_nl
574 << "return;" << be_uidt_nl
575 << "}" << be_uidt_nl << be_nl
576 << "throw ::Components::BadEventType ();" << be_uidt_nl
577 << "}";
579 if (!be_global->gen_lwccm ())
581 os_ << be_nl_2
582 << "::" << fname << "Consumer_ptr" << be_nl
583 << node_->local_name () << "_Servant::get_consumer_"
584 << port_name << " ()" << be_nl
585 << "{" << be_idt_nl
586 << "return" << be_idt_nl
587 << "::" << fname << "Consumer::_duplicate (" << be_idt_nl
588 << "this->consumes_" << port_name << "_.in ());"
589 << be_uidt << be_uidt << be_uidt_nl
590 << "}";
593 os_ << be_nl_2
594 << "void" << be_nl
595 << node_->local_name () << "_Servant::setup_consumer_"
596 << port_name << "_i ()" << be_nl
597 << "{" << be_idt_nl
598 << "ACE_CString obj_id (this->ins_name_);" << be_nl
599 << "obj_id += \"_" << port_name << "\";" << be_nl_2
600 << "::CIAO::Container_var cnt_safe =" << be_idt_nl
601 << "::CIAO::Container::_duplicate ("
602 << "this->container_.in ());" << be_uidt_nl << be_nl
603 << "if (::CORBA::is_nil (cnt_safe.in ()))" << be_idt_nl
604 << "{" << be_idt_nl << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
605 << "}" << be_uidt_nl << be_nl
606 << "PortableServer::POA_var POA = cnt_safe->the_port_POA ();" << be_nl
607 << node_->local_name () << "_Servant::" << lname
608 << "Consumer_" << port_name << "_Servant *"
609 << port_name << "_servant_impl = " << be_idt_nl
610 << "new " << node_->local_name () << "_Servant::" << lname
611 << "Consumer_" << port_name << "_Servant (" << be_idt_nl
612 << " this->executor_, this->context_);" << be_uidt_nl << be_uidt_nl << be_nl
613 << "PortableServer::ServantBase_var safe_base_servant ("
614 << port_name << "_servant_impl);" << be_nl
615 << "PortableServer::ObjectId_var " << port_name << "_servant_oid =" << be_idt_nl
616 << "PortableServer::string_to_ObjectId (obj_id.c_str());" << be_uidt_nl << be_nl
617 << "POA->activate_object_with_id(" << be_idt_nl
618 << port_name << "_servant_oid.in()," << be_nl
619 << port_name << "_servant_impl);" << be_uidt_nl << be_nl
621 << "::CORBA::Object_var " << port_name << "_servant_impl_obj = " << be_idt_nl
622 << "cnt_safe->generate_reference ( " << be_idt_nl
623 << "obj_id.c_str ()," << be_nl
624 << "\"";
626 ACE_CString work (obj->repoID ());
627 ACE_CString result (work.substr (0, work.rfind (':')));
628 result += "Consumer:1.0";
630 os_ << result.c_str ();
632 os_ << "\"," << be_nl
633 << "::CIAO::Container_Types::FACET_CONSUMER_t);"
634 << be_uidt_nl << be_uidt_nl
635 << "::Components::EventConsumerBase_var ecb =" << be_idt_nl
636 << "::Components::EventConsumerBase::_narrow ("
637 << port_name << "_servant_impl_obj.in ());"
638 << be_uidt_nl << be_nl
639 << "this->add_consumer (\"" << port_name << "\", ecb.in ());"
640 << be_uidt_nl
641 << "}";
643 return 0;
646 void
647 be_visitor_servant_svs::gen_provides_top ()
649 if (this->node_->n_provides () == 0UL)
651 return;
654 ACE_CString comp_sname_str (
655 ScopeAsDecl (node_->defined_in ())->full_name ());
656 const char *global = (comp_sname_str == "" ? "" : "::");
657 ACE_CString sname_str (ScopeAsDecl (node_->defined_in ())->full_name ());
659 os_ << be_nl_2
660 << "/// CIAO-specific." << be_nl
661 << "::CORBA::Object_ptr" << be_nl
662 << node_->local_name ()
663 << "_Servant::get_facet_executor (" << be_idt_nl
664 << "const char * name)" << be_uidt_nl
665 << "{" << be_idt_nl;
667 os_ << "if (!name)" << be_idt_nl
668 << "{" << be_idt_nl
669 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
670 << "}" << be_uidt << be_nl_2;
672 os_ << "::" << sname_str << global << "CCM_" << node_->original_local_name ()
673 << "_var executor = " << be_idt_nl
674 << "::" << sname_str << global << "CCM_" << node_->original_local_name ()
675 << "::_duplicate (this->executor_.in ());" << be_uidt << be_nl_2;
677 os_ << "if (::CORBA::is_nil (executor.in ()))"
678 << be_idt_nl
679 << "{"<< be_idt_nl
680 << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
681 << "}" << be_uidt;
683 be_visitor_facet_executor_block feb_visitor (this->ctx_);
685 if (feb_visitor.visit_component_scope (node_) == -1)
687 ACE_ERROR ((LM_ERROR,
688 "be_visitor_servant_svs::"
689 "gen_provides_top - "
690 "facet executor block visitor failed\n"));
692 return;
695 os_ << be_nl_2
696 << "throw ::Components::InvalidName ();" << be_uidt_nl
697 << "}";
700 void
701 be_visitor_servant_svs::gen_publishes_top ()
703 ACE_CDR::ULong npubs = this->node_->n_publishes ();
705 if (npubs > 0UL)
707 os_ << be_nl_2
708 << "::Components::Cookie *" << be_nl
709 << node_->local_name () << "_Servant::subscribe ("
710 << be_idt_nl
711 << "const char * publisher_name," << be_nl
712 << "::Components::EventConsumerBase_ptr subscribe)"
713 << be_uidt_nl
714 << "{" << be_idt_nl;
716 os_ << "if (!publisher_name)" << be_idt_nl
717 << "{" << be_idt_nl
718 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
719 << "}" << be_uidt;
721 be_visitor_subscribe_block sb_visitor (this->ctx_);
723 if (sb_visitor.visit_component_scope (node_) == -1)
725 ACE_ERROR ((LM_ERROR,
726 "be_visitor_servant_svs::"
727 "gen_publishes_top - "
728 "subscribe block visitor failed\n"));
730 return;
733 os_ << be_nl_2
734 << "throw ::Components::InvalidName ();" << be_uidt_nl
735 << "}";
737 os_ << be_nl_2
738 << "::Components::EventConsumerBase_ptr" << be_nl
739 << node_->local_name () << "_Servant::unsubscribe ("
740 << be_idt_nl
741 << "const char * publisher_name," << be_nl
742 << "::Components::Cookie * ck)" << be_uidt_nl
743 << "{" << be_idt_nl;
745 os_ << "if (!publisher_name)" << be_idt_nl
746 << "{" << be_idt_nl
747 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
748 << "}" << be_uidt;
750 be_visitor_unsubscribe_block ub_visitor (this->ctx_);
752 if (ub_visitor.visit_component_scope (node_) == -1)
754 ACE_ERROR ((LM_ERROR,
755 "be_visitor_servant_svs::"
756 "gen_publishes_top - "
757 "unsubscribe block visitor failed\n"));
759 return;
762 os_ << be_nl_2
763 << "throw ::Components::InvalidName ();" << be_uidt_nl
764 << "}";
767 if (!be_global->gen_lwccm () && !be_global->gen_noeventccm () && this->node_->n_publishes () != 0)
769 os_ << be_nl_2
770 << "::Components::PublisherDescriptions *" << be_nl
771 << node_->local_name ()
772 << "_Servant::get_all_publishers ()" << be_nl
773 << "{" << be_idt_nl
774 << "::Components::PublisherDescriptions *retval {};"
775 << be_nl
776 << "ACE_NEW_THROW_EX (retval," << be_nl
777 << " ::Components::PublisherDescriptions,"
778 << be_nl
779 << " ::CORBA::NO_MEMORY ());" << be_nl_2
780 << "::Components::PublisherDescriptions_var "
781 << "safe_retval = retval;" << be_nl
782 << "safe_retval->length (" << this->node_->n_publishes ()
783 << "UL);";
785 if (npubs > 0UL)
787 be_visitor_event_source_desc esd_visitor (this->ctx_);
789 if (esd_visitor.visit_component_scope (node_) == -1)
791 ACE_ERROR ((LM_ERROR,
792 ACE_TEXT ("be_visitor_servant_svs::")
793 ACE_TEXT ("gen_publishes_top - ")
794 ACE_TEXT ("event source description ")
795 ACE_TEXT ("visitor failed\n")));
797 return;
801 os_ << be_nl_2
802 << "return safe_retval._retn ();" << be_uidt_nl
803 << "}";
807 void
808 be_visitor_servant_svs::gen_uses_top ()
810 ACE_CDR::ULong nuses = this->node_->n_uses ();
812 if (nuses > 0UL)
814 os_ << be_nl_2
815 << "::Components::Cookie *" << be_nl
816 << node_->local_name () << "_Servant::connect ("
817 << be_idt_nl
818 << "const char * name," << be_nl
819 << "::CORBA::Object_ptr connection)" << be_uidt_nl
820 << "{" << be_idt_nl;
822 os_ << "if (!name)" << be_idt_nl
823 << "{" << be_idt_nl
824 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
825 << "}" << be_uidt;
827 be_visitor_connect_block cb_visitor (this->ctx_);
829 if (cb_visitor.visit_component_scope (node_) == -1)
831 ACE_ERROR ((LM_ERROR,
832 ACE_TEXT ("be_visitor_servant_svs::")
833 ACE_TEXT ("gen_uses_top - ")
834 ACE_TEXT ("connect block visitor failed\n")));
836 return;
839 os_ << be_nl_2
840 << "throw ::Components::InvalidName ();" << be_uidt_nl
841 << "}";
843 os_ << be_nl_2
844 << "::CORBA::Object_ptr" << be_nl
845 << node_->local_name () << "_Servant::disconnect ("
846 << be_idt_nl
847 << "const char * name," << be_nl
848 << "::Components::Cookie * "
849 << (this->node_->has_uses_multiple () ? "ck" : "/* ck */")
850 << ")" << be_uidt_nl
851 << "{" << be_idt_nl
852 << "if (!name)" << be_idt_nl
853 << "{" << be_idt_nl
854 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
855 << "}" << be_uidt;
857 be_visitor_disconnect_block db_visitor (this->ctx_);
859 if (db_visitor.visit_component_scope (node_) == -1)
861 ACE_ERROR ((LM_ERROR,
862 "be_visitor_servant_svs::"
863 "gen_uses_top - "
864 "disconnect block visitor failed\n"));
866 return;
869 os_ << be_nl_2
870 << "throw ::Components::InvalidName ();" << be_uidt_nl
871 << "}";
872 } // nuses > 0UL
874 if (!be_global->gen_lwccm () && nuses > 0)
876 os_ << be_nl_2
877 << "::Components::ReceptacleDescriptions *" << be_nl
878 << node_->local_name ()
879 << "_Servant::get_all_receptacles ()" << be_nl
880 << "{" << be_idt_nl
881 << "::Components::ReceptacleDescriptions * retval {};"
882 << be_nl
883 << "ACE_NEW_THROW_EX (retval," << be_nl
884 << " ::Components::ReceptacleDescriptions,"
885 << be_nl
886 << " ::CORBA::NO_MEMORY ());" << be_nl_2
887 << "::Components::ReceptacleDescriptions_var "
888 << "safe_retval = retval;" << be_nl
889 << "safe_retval->length (" << nuses
890 << "UL);";
892 if (nuses > 0UL)
894 be_visitor_receptacle_desc rd_visitor (this->ctx_, this->node_);
896 if (rd_visitor.visit_component_scope (node_) == -1)
898 ACE_ERROR ((LM_ERROR,
899 ACE_TEXT ("be_visitor_servant_svs::")
900 ACE_TEXT ("gen_uses_top - ")
901 ACE_TEXT ("receptacle description ")
902 ACE_TEXT ("visitor failed\n")));
904 return;
908 os_ << be_nl_2
909 << "return safe_retval._retn ();" << be_uidt_nl
910 << "}";
914 void
915 be_visitor_servant_svs::gen_emits_top ()
917 /// Generated whether the component has emits ports
918 /// or not, except if we are generating a LwCCM
919 /// profile, in which case this call returns
920 /// immediately, and the base class method
921 /// (returning a null pointer to a sequence of
922 /// emitter descriptions) is seen instead.
923 this->gen_get_all_emitters ();
925 if (this->node_->n_emits () == 0UL)
927 return;
930 os_ << be_nl_2
931 << "void" << be_nl
932 << node_->local_name () << "_Servant::connect_consumer ("
933 << be_idt_nl
934 << "const char * emitter_name," << be_nl
935 << "::Components::EventConsumerBase_ptr consumer)"
936 << be_uidt_nl
937 << "{" << be_idt_nl;
939 os_ << "if (!emitter_name)" << be_idt_nl
940 << "{" << be_idt_nl
941 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
942 << "}" << be_uidt;
944 be_visitor_connect_consumer_block ccb_visitor (this->ctx_);
946 if (ccb_visitor.visit_component_scope (node_) == -1)
948 ACE_ERROR ((LM_ERROR,
949 "be_visitor_servant_svs::"
950 "gen_emits_top - "
951 "connect consumer block visitor failed\n"));
953 return;
956 os_ << be_nl_2
957 << "throw ::Components::InvalidName ();" << be_uidt_nl
958 << "}";
960 os_ << be_nl_2
961 << "::Components::EventConsumerBase_ptr" << be_nl
962 << node_->local_name ()
963 << "_Servant::disconnect_consumer (" << be_idt_nl
964 << "const char * source_name)" << be_uidt_nl
965 << "{" << be_idt_nl;
967 os_ << "if (!source_name)" << be_idt_nl
968 << "{" << be_idt_nl
969 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
970 << "}" << be_uidt;
972 be_visitor_disconnect_consumer_block dcb_visitor (this->ctx_);
974 if (dcb_visitor.visit_component_scope (node_) == -1)
976 ACE_ERROR ((LM_ERROR,
977 "be_visitor_servant_svs::"
978 "gen_emits_top - "
979 "disconnect consumer block visitor failed\n"));
981 return;
984 os_ << be_nl_2
985 << "throw ::Components::InvalidName ();" << be_uidt_nl
986 << "}";
989 void
990 be_visitor_servant_svs::gen_get_all_emitters ()
992 if (be_global->gen_lwccm () || be_global->gen_noeventccm () || this->node_->n_emits () == 0UL)
994 return;
997 os_ << be_nl_2
998 << "::Components::EmitterDescriptions *" << be_nl
999 << node_->local_name ()
1000 << "_Servant::get_all_emitters ()" << be_nl
1001 << "{" << be_idt_nl
1002 << "::Components::EmitterDescriptions *retval {};"
1003 << be_nl
1004 << "ACE_NEW_THROW_EX (retval," << be_nl
1005 << " ::Components::EmitterDescriptions,"
1006 << be_nl
1007 << " ::CORBA::NO_MEMORY ());" << be_nl_2
1008 << "::Components::EmitterDescriptions_var "
1009 << "safe_retval = retval;" << be_nl
1010 << "safe_retval->length (" << this->node_->n_emits ()
1011 << "UL);";
1013 be_visitor_emitter_desc ed_visitor (this->ctx_);
1015 if (ed_visitor.visit_component_scope (node_) == -1)
1017 ACE_ERROR ((LM_ERROR,
1018 "be_visitor_servant_svs::"
1019 "gen_emits_top - "
1020 "emitter description visitor failed\n"));
1022 return;
1025 os_ << be_nl_2
1026 << "return safe_retval._retn ();" << be_uidt_nl
1027 << "}";
1030 // ==========================================================
1032 be_visitor_obv_factory_reg::be_visitor_obv_factory_reg (
1033 be_visitor_context *ctx)
1034 : be_visitor_component_scope (ctx)
1038 be_visitor_obv_factory_reg::~be_visitor_obv_factory_reg ()
1043 be_visitor_obv_factory_reg::visit_publishes (be_publishes *node)
1045 this->gen_obv_factory_registration (node->field_type ());
1047 return 0;
1051 be_visitor_obv_factory_reg::visit_emits (be_emits *node)
1053 this->gen_obv_factory_registration (node->field_type ());
1055 return 0;
1059 be_visitor_obv_factory_reg::visit_consumes (be_consumes *node)
1061 this->gen_obv_factory_registration (node->field_type ());
1063 return 0;
1066 void
1067 be_visitor_obv_factory_reg::gen_obv_factory_registration (AST_Type *t)
1069 if (be_global->gen_ciao_valuefactory_reg ())
1071 const char *fname = t->full_name ();
1073 os_ << "TAO_OBV_REGISTER_FACTORY (" << be_idt_nl
1074 << "::" << fname << "_init," << be_nl
1075 << "::" << fname << ");" << be_uidt_nl;
1079 // ==========================================================
1081 be_visitor_attr_set::be_visitor_attr_set (be_visitor_context *ctx)
1082 : be_visitor_component_scope (ctx)
1086 be_visitor_attr_set::~be_visitor_attr_set ()
1091 be_visitor_attr_set::visit_attribute (be_attribute *node)
1093 be_visitor_attribute_ccm_init v (this->ctx_);
1095 if (v.visit_attribute (node) == -1)
1097 ACE_ERROR_RETURN ((LM_ERROR,
1098 ACE_TEXT ("be_visitor_attr_set")
1099 ACE_TEXT ("::visit_attribute - ")
1100 ACE_TEXT ("ccm attr init visitor ")
1101 ACE_TEXT ("failed\n")),
1102 -1);
1105 return 0;
1109 be_visitor_attr_set::visit_component_scope (be_component *node)
1111 if (node == nullptr)
1113 return 0;
1116 this->ctx_->interface (node);
1118 if (this->visit_scope (node) == -1)
1120 ACE_ERROR_RETURN ((LM_ERROR,
1121 ACE_TEXT ("be_visitor_attr_set")
1122 ACE_TEXT ("::visit_component_scope - ")
1123 ACE_TEXT ("visit_scope() failed\n")),
1124 -1);
1127 /// This overload of traverse_inheritance_graph() used here
1128 /// doesn't automatically prime the queues.
1129 node->get_insert_queue ().reset ();
1130 node->get_del_queue ().reset ();
1131 node->get_insert_queue ().enqueue_tail (node);
1133 Component_Op_Attr_Generator component_inher (this);
1135 int status =
1136 node->traverse_inheritance_graph (component_inher,
1137 &os_,
1138 false,
1139 false);
1140 if (status == -1)
1142 ACE_ERROR_RETURN ((LM_ERROR,
1143 ACE_TEXT ("be_visitor_attr_set")
1144 ACE_TEXT ("::visit_component_scope - ")
1145 ACE_TEXT ("traverse_inheritance_graph() ")
1146 ACE_TEXT ("failed\n")),
1147 -1);
1150 // Recurse to the base class method for the base component(s)
1151 // so traverse_inheritance_graph() will not be called again,
1152 // which would output assignments for the attributes inherited
1153 // from the base componnent's supported interfaces multiple times.
1154 return
1155 this->be_visitor_component_scope::visit_component_scope (node->base_component ());
1158 // ==========================================================
1160 be_visitor_facet_executor_block::be_visitor_facet_executor_block (
1161 be_visitor_context *ctx)
1162 : be_visitor_component_scope (ctx)
1166 be_visitor_facet_executor_block::~be_visitor_facet_executor_block (
1172 be_visitor_facet_executor_block::visit_provides (
1173 be_provides *node)
1175 ACE_CString prefix (this->ctx_->port_prefix ());
1176 prefix += node->local_name ()->get_string ();
1177 const char *port_name = prefix.c_str ();
1179 os_ << be_nl_2
1180 << "if (ACE_OS::strcmp (name, \"" << port_name
1181 << "\") == 0)" << be_idt_nl
1182 << "{" << be_idt_nl
1183 << "return executor->get_" << port_name
1184 << " ();" << be_uidt_nl
1185 << "}" << be_uidt;
1187 return 0;
1190 // ======================================================
1192 be_visitor_connect_block::be_visitor_connect_block (
1193 be_visitor_context *ctx)
1194 : be_visitor_component_scope (ctx)
1198 be_visitor_connect_block::~be_visitor_connect_block ()
1203 be_visitor_connect_block::visit_uses (be_uses *node)
1205 ACE_CString prefix (this->ctx_->port_prefix ());
1206 prefix += node->local_name ()->get_string ();
1207 const char *port_name = prefix.c_str ();
1209 const char *obj_name = node->uses_type ()->full_name ();
1210 bool const is_multiple = node->is_multiple ();
1212 os_ << be_nl_2
1213 << "if (ACE_OS::strcmp (name, \"" << port_name
1214 << "\") == 0)" << be_idt_nl
1215 << "{" << be_idt_nl
1216 << "::" << obj_name << "_var _ciao_conn =" << be_idt_nl
1217 << "::" << obj_name << "::_narrow (connection);"
1218 << be_uidt_nl << be_nl;
1220 os_ << "/// " << (is_multiple ? "Multiplex" : "Simplex")
1221 << " connect." << be_nl
1222 << (is_multiple ? "return " : "") << "this->context_->connect_"
1223 << port_name << " (_ciao_conn.in ());";
1225 if (! is_multiple)
1227 os_ << be_nl
1228 << "return 0;";
1231 os_ << be_uidt_nl
1232 << "}" << be_uidt;
1234 return 0;
1237 // ======================================================
1239 be_visitor_disconnect_block::be_visitor_disconnect_block (
1240 be_visitor_context *ctx)
1241 : be_visitor_component_scope (ctx)
1245 be_visitor_disconnect_block::~be_visitor_disconnect_block (
1251 be_visitor_disconnect_block::visit_uses (be_uses *node)
1253 ACE_CString prefix (this->ctx_->port_prefix ());
1254 prefix += node->local_name ()->get_string ();
1255 const char *port_name = prefix.c_str ();
1257 bool const is_multiple = node->is_multiple ();
1259 os_ << be_nl_2
1260 << "if (ACE_OS::strcmp (name, \"" << port_name
1261 << "\") == 0)" << be_idt_nl
1262 << "{" << be_idt_nl
1263 << "/// " << (is_multiple ? "Multiplex" : "Simplex")
1264 << " disconnect." << be_nl;
1266 if (is_multiple)
1268 os_ << "if (!ck)" << be_idt_nl
1269 << "{" << be_idt_nl
1270 << "throw ::Components::CookieRequired ();" << be_uidt_nl
1271 << "}" << be_uidt_nl << be_nl;
1274 os_ << "return this->context_->disconnect_" << port_name
1275 << " (" << (is_multiple ? "ck" : "") << ");" << be_uidt_nl
1276 << "}" << be_uidt;
1278 return 0;
1281 // ======================================================
1283 be_visitor_receptacle_desc::be_visitor_receptacle_desc (
1284 be_visitor_context *ctx,
1285 be_component *node)
1286 : be_visitor_component_scope (ctx),
1287 slot_ (0UL),
1288 comp_ (node)
1290 node_ = node;
1293 be_visitor_receptacle_desc::~be_visitor_receptacle_desc (
1299 be_visitor_receptacle_desc::visit_uses (be_uses *node)
1301 ACE_CString prefix (this->ctx_->port_prefix ());
1302 prefix += node->local_name ()->get_string ();
1303 const char *port_name = prefix.c_str ();
1305 AST_Type *obj = node->uses_type ();
1306 bool const is_multiple = node->is_multiple ();
1308 os_ << be_nl_2;
1310 ACE_CString sname_str (comp_->full_name ());
1311 const char *sname = sname_str.c_str ();
1313 const char *global = (sname_str == "" ? "" : "::");
1315 if (!is_multiple)
1317 os_ << obj->full_name () << "_var ciao_"
1318 << port_name << " = " << be_idt_nl
1319 << "this->context_->get_connection_"
1320 << port_name << " ();" << be_uidt_nl;
1322 else
1324 os_ << "::" << sname << global << port_name << "Connections_var ciao_"
1325 << port_name << " = " << be_idt_nl
1326 << "this->context_->get_connections_"
1327 << port_name << " ();" << be_uidt_nl;
1330 os_ << "::CIAO::Servant::describe_"
1331 << (is_multiple ? "multiplex" : "simplex")
1332 << "_receptacle<" << be_idt_nl;
1334 if (!is_multiple)
1336 os_ << "::" << obj->full_name () << "> (" << be_idt_nl;
1338 else
1340 os_ << "::" << sname << global << port_name << "Connections> (" << be_idt_nl;
1343 os_ << "\"" << port_name << "\"," << be_nl
1344 << "\"" << obj->repoID () << "\"," << be_nl;
1346 os_ << "ciao_" << port_name << ".in ()," << be_nl;
1348 os_ << "safe_retval," << be_nl
1349 << slot_++ << "UL);" << be_uidt << be_uidt;
1351 return 0;
1354 // ======================================================
1356 be_visitor_subscribe_block::be_visitor_subscribe_block (
1357 be_visitor_context *ctx)
1358 : be_visitor_component_scope (ctx)
1362 be_visitor_subscribe_block::~be_visitor_subscribe_block (
1368 be_visitor_subscribe_block::visit_publishes (
1369 be_publishes *node)
1371 const char *obj_name =
1372 node->publishes_type ()->full_name ();
1373 const char *port_name =
1374 node->local_name ()->get_string ();
1376 os_ << be_nl_2
1377 << "if (ACE_OS::strcmp (publisher_name, \""
1378 << port_name << "\") == 0)" << be_idt_nl
1379 << "{" << be_idt_nl
1380 << "::" << obj_name << "Consumer_var sub =" << be_idt_nl
1381 << "::" << obj_name << "Consumer::_narrow (subscribe);"
1382 << be_uidt_nl << be_nl
1383 << "return this->context_->subscribe_" << port_name
1384 << " (sub.in ());" << be_uidt_nl
1385 << "}" << be_uidt;
1387 return 0;
1390 // ==========================================================
1392 be_visitor_unsubscribe_block::be_visitor_unsubscribe_block (
1393 be_visitor_context *ctx)
1394 : be_visitor_component_scope (ctx)
1398 be_visitor_unsubscribe_block::~be_visitor_unsubscribe_block (
1404 be_visitor_unsubscribe_block::visit_publishes (
1405 be_publishes *node)
1407 const char *port_name =
1408 node->local_name ()->get_string ();
1410 os_ << be_nl_2
1411 << "if (ACE_OS::strcmp (publisher_name, \""
1412 << port_name << "\") == 0)" << be_idt_nl
1413 << "{" << be_idt_nl
1414 << "return this->context_->unsubscribe_" << port_name
1415 << " (ck);" << be_uidt_nl
1416 << "}" << be_uidt;
1418 return 0;
1421 // ==========================================================
1423 be_visitor_event_source_desc::be_visitor_event_source_desc (
1424 be_visitor_context *ctx)
1425 : be_visitor_component_scope (ctx),
1426 slot_ (0UL)
1430 be_visitor_event_source_desc::~be_visitor_event_source_desc (
1436 be_visitor_event_source_desc::visit_publishes (
1437 be_publishes *node)
1439 AST_Type *obj = node->publishes_type ();
1440 const char *port_name =
1441 node->local_name ()->get_string ();
1443 os_ << be_nl_2;
1445 os_ << "{" << be_idt_nl
1446 << "ACE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
1447 << " mon," << be_nl
1448 << " this->context_->"
1449 << port_name << "_lock_," << be_nl
1450 << " 0);" << be_nl_2;
1452 os_ << "::CIAO::Servant::describe_pub_event_source<"
1453 << be_idt_nl
1454 << "::" << obj->full_name () << "Consumer_var> ("
1455 << be_idt_nl
1456 << "\"" << port_name << "\"," << be_nl
1457 << "\"" << obj->repoID () << "\"," << be_nl
1458 << "this->context_->ciao_publishes_"
1459 << port_name << "_," << be_nl
1460 << "safe_retval," << be_nl
1461 << slot_++ << "UL);" << be_uidt << be_uidt;
1463 os_ << be_uidt_nl
1464 << "}";
1466 return 0;
1469 // ======================================================
1471 be_visitor_connect_consumer_block::be_visitor_connect_consumer_block (
1472 be_visitor_context *ctx)
1473 : be_visitor_component_scope (ctx)
1477 be_visitor_connect_consumer_block::~be_visitor_connect_consumer_block ()
1482 be_visitor_connect_consumer_block::visit_emits (
1483 be_emits *node)
1485 const char *obj_name =
1486 node->emits_type ()->full_name ();
1487 const char *port_name =
1488 node->local_name ()->get_string ();
1490 os_ << be_nl_2
1491 << "if (ACE_OS::strcmp (emitter_name, \""
1492 << port_name << "\") == 0)" << be_idt_nl
1493 << "{" << be_idt_nl
1494 << "::" << obj_name
1495 << "Consumer_var _ciao_consumer =" << be_idt_nl
1496 << "::" << obj_name
1497 << "Consumer::_narrow (consumer);" << be_uidt_nl << be_nl
1498 << "this->context_->connect_" << port_name
1499 << " (_ciao_consumer.in ());" << be_nl_2
1500 << "return;" << be_uidt_nl
1501 << "}" << be_uidt;
1503 return 0;
1506 // ======================================================
1508 be_visitor_disconnect_consumer_block::be_visitor_disconnect_consumer_block (
1509 be_visitor_context *ctx)
1510 : be_visitor_component_scope (ctx)
1514 be_visitor_disconnect_consumer_block::~be_visitor_disconnect_consumer_block (
1520 be_visitor_disconnect_consumer_block::visit_emits (
1521 be_emits *node)
1523 const char *port_name =
1524 node->local_name ()->get_string ();
1526 os_ << be_nl_2
1527 << "if (ACE_OS::strcmp (source_name, \""
1528 << port_name << "\") == 0)" << be_idt_nl
1529 << "{" << be_idt_nl
1530 << "return this->context_->disconnect_" << port_name
1531 << " ();" << be_uidt_nl
1532 << "}" << be_uidt;
1534 return 0;
1537 // ======================================================
1539 be_visitor_emitter_desc::be_visitor_emitter_desc (
1540 be_visitor_context *ctx)
1541 : be_visitor_component_scope (ctx),
1542 slot_ (0UL)
1546 be_visitor_emitter_desc::~be_visitor_emitter_desc (
1552 be_visitor_emitter_desc::visit_emits (be_emits *node)
1554 AST_Type *obj = node->emits_type ();
1555 const char *port_name =
1556 node->local_name ()->get_string ();
1558 os_ << be_nl_2
1559 << "::CIAO::Servant::describe_emit_event_source<"
1560 << be_idt_nl
1561 << "::" << obj->full_name () << "Consumer_var> ("
1562 << be_idt_nl
1563 << "\"" << port_name << "\"," << be_nl
1564 << "\"" << obj->repoID () << "\"," << be_nl
1565 << "this->context_->ciao_emits_" << port_name
1566 << "_consumer_," << be_nl
1567 << "safe_retval," << be_nl
1568 << slot_++ << "UL);" << be_uidt << be_uidt;
1570 return 0;
1573 // ======================================================
1575 be_visitor_populate_port_tables::be_visitor_populate_port_tables (
1576 be_visitor_context *ctx)
1577 : be_visitor_component_scope (ctx)
1581 be_visitor_populate_port_tables::~be_visitor_populate_port_tables (
1587 be_visitor_populate_port_tables::visit_provides (
1588 be_provides *node)
1590 if (node->provides_type ()->is_local ())
1592 return 0;
1595 ACE_CString prefix (this->ctx_->port_prefix ());
1596 prefix += node->local_name ()->get_string ();
1597 const char *port_name = prefix.c_str ();
1599 os_ << be_nl
1600 << "this->setup_"
1601 << port_name << "_i ();";
1603 return 0;
1607 be_visitor_populate_port_tables::visit_consumes (
1608 be_consumes *node)
1610 os_ << be_nl
1611 << "this->setup_consumer_"
1612 << node->local_name ()->get_string () << "_i ();";
1614 return 0;
1617 // ======================================================
1619 Component_Op_Attr_Generator::Component_Op_Attr_Generator (
1620 be_visitor_scope * visitor)
1621 : visitor_ (visitor)
1626 Component_Op_Attr_Generator::emit (be_interface * /* derived_interface */,
1627 TAO_OutStream * /* os */,
1628 be_interface * base_interface)
1630 AST_Decl::NodeType nt = base_interface->node_type ();
1632 if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector)
1634 return 0;
1637 return visitor_->visit_scope (base_interface);