Remove redundant void from tao_idl
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_component / servant_svs.cpp
blob67f396e2cbd978f79e9e5afc3897f06e833b3a8a
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_ (0)
20 be_visitor_servant_svs::~be_visitor_servant_svs ()
24 int
25 be_visitor_servant_svs::visit_component (be_component *node)
27 // This visitor is spawned by be_visitor_component_svh,
28 // which already does a check for imported node, so none
29 // is needed here.
30 node_ = node;
32 AST_Decl *scope = ScopeAsDecl (node_->defined_in ());
33 ACE_CString sname_str (scope->full_name ());
34 const char *sname = sname_str.c_str ();
35 const char *lname = node->local_name ();
36 const char *global = (sname_str == "" ? "" : "::");
37 AST_Decl::NodeType nt = this->node_->node_type ();
39 bool const is_connector = (nt == AST_Decl::NT_connector);
40 bool no_events = false;
42 if (!is_connector)
44 no_events =
45 (node->n_consumes () == 0UL
46 && node->n_emits () == 0UL
47 && node->n_publishes () == 0UL);
50 bool const de_facto = (is_connector || no_events);
52 const char *opt_conn =
53 (de_facto ? "Connector_" : "");
55 os_ << be_nl_2
56 << lname << "_Servant::"
57 << lname << "_Servant (" << be_idt << be_idt << be_idt_nl
58 << global << sname << "::CCM_" << lname
59 << "_ptr exe," << be_nl
60 << "::Components::CCMHome_ptr h," << be_nl
61 << "const char * ins_name," << be_nl
62 << "::CIAO::Home_Servant_Impl_Base * hs," << be_nl
63 << "::CIAO::" << be_global->ciao_container_type ()
64 << "_Container_ptr c)" << be_uidt << be_uidt_nl
65 << ": ::CIAO::" << opt_conn
66 << "Servant_Impl_Base (h, hs, c)," << be_idt_nl
67 << "::CIAO::" << be_global->ciao_container_type ()
68 << "_Servant_Impl_T<" << be_idt_nl
69 << "::" << node_->full_skel_name ()
70 << "," << be_nl
71 << global << sname << "::CCM_"
72 << lname << "," << be_nl
73 << lname << "_Context_T< " << be_idt_nl
74 << "::CIAO::" << be_global->ciao_container_type ()
75 << "_Container, ::CIAO::" << be_global->ciao_container_type () << "_Context_Impl_T< "
76 << be_idt_nl << global << sname << "::CCM_" << lname << "_Context, " << be_nl
77 << global << sname << "::" << lname << "> > > (exe, h, ins_name, hs, c)"
78 << be_uidt << be_uidt << be_uidt << be_uidt << be_uidt_nl
79 << "{" << be_idt_nl;
81 be_visitor_obv_factory_reg ofr_visitor (this->ctx_);
83 if (ofr_visitor.visit_component_scope (node) == -1)
85 ACE_ERROR_RETURN ((LM_ERROR,
86 "be_visitor_servant_svs::"
87 "visit_component - "
88 "OBV factory registration failed\n"),
89 -1);
92 /// If a component has neither facets nor event sinks, the
93 /// setup methods aren't generated.
94 if (this->node_->n_remote_provides () > 0UL
95 || this->node_->n_consumes () > 0UL)
97 be_visitor_populate_port_tables ppt_visitor (this->ctx_);
99 if (ppt_visitor.visit_component_scope (node) == -1)
101 ACE_ERROR_RETURN ((LM_ERROR,
102 "be_visitor_servant_svs::"
103 "visit_component - "
104 "populate port tables visitor failed\n"),
105 -1);
109 os_ << be_uidt_nl << "}";
111 os_ << be_nl_2
112 << lname << "_Servant::~"
113 << lname << "_Servant (void)" << be_nl
114 << "{" << be_nl
115 << "}";
117 if (this->node_->has_rw_attributes ())
119 os_ << be_nl_2
120 << "void" << be_nl
121 << lname << "_Servant::set_attributes (" << be_idt_nl
122 << "const ::Components::ConfigValues & descr)"
123 << be_uidt_nl
124 << "{" << be_idt_nl;
126 os_ << "for ( ::CORBA::ULong i = 0; i < descr.length (); ++i)"
127 << be_idt_nl
128 << "{" << be_idt_nl
129 << "const char * descr_name = descr[i]->name ();"
130 << be_nl
131 << "::CORBA::Any & descr_value = descr[i]->value ();";
133 be_visitor_attr_set as_visitor (this->ctx_);
135 /// This will get assigned to the visitor's interface_
136 /// member later so it can catch and skip porttype
137 /// attributes in a component.
138 as_visitor.node (this->node_);
140 if (as_visitor.visit_component_scope (node) == -1)
142 ACE_ERROR_RETURN ((LM_ERROR,
143 "servant_svs::"
144 "visit_component - "
145 "attr init visitor failed\n"),
146 -1);
149 os_ << be_uidt_nl
150 << "}" << be_uidt << be_uidt_nl
151 << "}";
154 os_ << be_nl_2
155 << "/// Supported operations and attributes.";
157 this->op_scope_ = node;
159 /// This overload of traverse_inheritance_graph() used here
160 /// doesn't automatically prime the queues.
161 this->node_->get_insert_queue ().reset ();
162 this->node_->get_del_queue ().reset ();
163 this->node_->get_insert_queue ().enqueue_tail (node);
165 Component_Op_Attr_Generator op_attr_gen (this);
167 int status =
168 this->node_->traverse_inheritance_graph (op_attr_gen,
169 &os_,
170 false,
171 false);
173 if (status == -1)
175 ACE_ERROR_RETURN ((LM_ERROR,
176 "be_visitor_servant_svs::"
177 "visit_component - "
178 "inheritance graph traversal failed\n"),
179 -1);
182 os_ << be_nl_2
183 << "/// All ports and component attributes.";
185 /// Port operations that require scope traversal to get all the
186 /// possible string name matches.
188 this->gen_provides_top ();
189 this->gen_uses_top ();
191 /// If we are visiting a connector we can skip these.
192 if (this->node_->node_type () == AST_Decl::NT_component)
194 this->gen_publishes_top ();
195 this->gen_emits_top ();
198 /// This call will generate all other operations and attributes,
199 /// including inherited ones.
200 if (this->visit_component_scope (node) == -1)
202 ACE_ERROR_RETURN ((LM_ERROR,
203 "be_visitor_servant_svs::"
204 "visit_component - "
205 "visit_component_scope() failed\n"),
206 -1);
209 return 0;
213 be_visitor_servant_svs::visit_connector (be_connector *node)
215 return this->visit_component (node);
219 be_visitor_servant_svs::visit_operation (be_operation *node)
221 AST_Decl::NodeType nt =
222 ScopeAsDecl (node->defined_in ())->node_type ();
224 // Components have implied IDL operations added to the AST, but
225 // we are interested only in supported interface operations.
226 if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector)
228 return 0;
231 be_visitor_operation_svs v (this->ctx_);
232 v.scope (this->op_scope_);
234 return v.visit_operation (node);
238 be_visitor_servant_svs::visit_attribute (be_attribute *node)
240 AST_Decl::NodeType nt = this->node_->node_type ();
242 // Executor attribute code generated for porttype attributes
243 // always in connectors and only for mirrorports in components.
244 if (this->in_ext_port_ && nt == AST_Decl::NT_component)
246 return 0;
249 this->ctx_->interface (this->node_);
250 be_visitor_attribute v (this->ctx_);
252 v.for_facets (false);
253 v.op_scope (this->op_scope_);
255 return v.visit_attribute (node);
259 be_visitor_servant_svs::visit_provides (be_provides *node)
261 if (node->provides_type ()->is_local ()) // @TODO || be_global->gen_lwccm ())
263 return 0;
266 ACE_CString prefix (this->ctx_->port_prefix ());
267 prefix += node->local_name ()->get_string ();
268 const char *port_name = prefix.c_str ();
270 AST_Type *obj = node->provides_type ();
271 const char *obj_name = obj->full_name ();
272 AST_Decl *scope = ScopeAsDecl (obj->defined_in ());
273 ACE_CString sname_str (scope->full_name ());
274 const char *sname = sname_str.c_str ();
276 // Avoid '_cxx_' prefix.
277 const char *lname =
278 obj->original_local_name ()->get_string ();
280 const char *global = (sname_str == "" ? "" : "::");
281 const char *prefix_connector = (sname_str == "" ? "" : "_");
283 if (!be_global->gen_lwccm ())
285 os_ << be_nl_2
286 << "::" << obj_name << "_ptr" << be_nl
287 << node_->local_name () << "_Servant::provide_"
288 << port_name << " (void)" << be_nl
289 << "{" << be_idt_nl;
291 os_ << "return" << be_idt_nl
292 << "::" << obj_name << "::_duplicate (this->provide_"
293 << port_name << "_.in ());" << be_uidt << be_uidt_nl
294 << "}";
297 os_ << be_nl_2
298 << "void" << be_nl
299 << node_->local_name () << "_Servant::setup_"
300 << port_name << "_i (void)" << be_nl
301 << "{" << be_idt_nl
302 << "ACE_CString obj_id (this->ins_name_);" << be_nl
303 << "obj_id += \"_" << port_name << "\";" << be_nl_2
304 << "::CIAO::Container_var cnt_safe =" << be_idt_nl
305 << "::CIAO::Container::_duplicate ("
306 << "this->container_.in ());" << be_uidt_nl << be_nl
307 << "if (::CORBA::is_nil (cnt_safe.in ()))" << be_idt_nl
308 << "{" << be_idt_nl << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
309 << "}" << be_uidt_nl << be_nl
310 << "PortableServer::POA_var POA = cnt_safe->the_port_POA ();" << be_nl
311 << "::CORBA::Object_var tmp =" << be_idt_nl
312 << "this->get_facet_executor (\"" << port_name << "\");"<< be_uidt_nl << be_nl
313 << global << sname << "::CCM_" << lname << "_var tmp_var = " << be_idt_nl
314 << global << sname <<"::CCM_" << lname
315 << "::_narrow (tmp.in());" << be_uidt_nl << be_nl
316 << "typedef " << global << "CIAO_FACET" << prefix_connector
317 << scope->flat_name () << "::" << obj->local_name () << "_Servant_T <" << be_idt_nl
318 << "POA_" << sname << global << obj->local_name ()
319 << "," << be_nl << global << sname <<"::CCM_" << lname << "," << be_nl
320 << global << "Components::" << be_global->ciao_container_type ()
321 << "Context>" << be_idt_nl << lname
322 << "_type;" << be_uidt_nl << be_uidt_nl
323 << lname << "_type *" << port_name << "_servant_impl = 0;" << be_nl
324 << "ACE_NEW_THROW_EX (" << be_idt_nl
325 << port_name << "_servant_impl," << be_nl
326 << lname << "_type (" << be_idt_nl
327 << "tmp_var.in(), " << be_nl
328 << "this->context_)," << be_uidt_nl
329 << "CORBA::NO_MEMORY ());" << be_uidt_nl << be_nl
330 << "PortableServer::ServantBase_var safe_base_servant ("
331 << port_name << "_servant_impl);" << be_nl << be_nl
332 << "PortableServer::ObjectId_var " << port_name << "_servant_oid =" << be_idt_nl
333 << "PortableServer::string_to_ObjectId (obj_id.c_str());" << be_uidt_nl << be_nl
334 << "POA->activate_object_with_id(" << port_name << "_servant_oid.in(),"
335 << port_name << "_servant_impl);" << be_nl
336 << "::CORBA::Object_var " << port_name << "_servant_impl_obj = " << be_idt_nl
337 << "cnt_safe->generate_reference ( " << be_idt_nl
338 << "obj_id.c_str ()," << be_nl
339 << "\"" << obj->repoID () << "\"," << be_nl
340 << "::CIAO::Container_Types::FACET_CONSUMER_t);"
341 << be_uidt_nl << be_uidt_nl
342 << "this->add_facet (\"" << port_name << "\", " << port_name << "_servant_impl_obj.in ());"
343 << be_uidt_nl
344 << "}";
346 return 0;
350 be_visitor_servant_svs::visit_uses (be_uses *node)
352 if (node->uses_type ()->is_local () || be_global->gen_lwccm ())
354 return 0;
357 ACE_CString prefix (this->ctx_->port_prefix ());
358 prefix += node->local_name ()->get_string ();
359 const char *port_name = prefix.c_str ();
361 const char *obj_name = node->uses_type ()->full_name ();
362 bool const is_multiple = node->is_multiple ();
364 os_ << be_nl_2
365 << (is_multiple ? "::Components::Cookie *" : "void")
366 << be_nl
367 << node_->local_name () << "_Servant::connect_"
368 << port_name << " (" << be_idt_nl
369 << "::" << obj_name << "_ptr c)" << be_uidt_nl
370 << "{" << be_idt_nl;
372 if (is_multiple)
374 os_ << "return ";
377 os_ << "this->context_->connect_" << port_name
378 << " (c);" << be_uidt_nl
379 << "}";
381 os_ << be_nl_2
382 << "::" << obj_name << "_ptr" << be_nl
383 << node_->local_name () << "_Servant::disconnect_"
384 << port_name << " (";
386 if (is_multiple)
388 os_ << be_idt_nl
389 << "::Components::Cookie * ck" << be_uidt;
391 else
393 os_ << "void";
396 os_ << ")" << be_nl
397 << "{" << be_idt_nl
398 << "return this->context_->disconnect_"
399 << port_name << " (" << (is_multiple ? "ck" : "")
400 << ");" << be_uidt_nl
401 << "}";
403 os_ << be_nl_2
404 << "::";
406 if (is_multiple)
408 os_ << node_->full_name () << "::" << port_name
409 << "Connections *";
411 else
413 os_ << obj_name << "_ptr";
416 os_ << be_nl
417 << node_->local_name () << "_Servant::get_connection"
418 << (is_multiple ? "s" : "") << "_"
419 << port_name << " (void)" << be_nl
420 << "{" << be_idt_nl
421 << "return this->context_->get_connection"
422 << (is_multiple ? "s" : "") << "_"
423 << port_name << " ();" << be_uidt_nl
424 << "}";
426 return 0;
430 be_visitor_servant_svs::visit_publishes (be_publishes *node)
432 if (be_global->gen_lwccm ())
434 return 0;
437 const char *obj_name = node->publishes_type ()->full_name ();
438 const char *port_name = node->local_name ()->get_string ();
440 os_ << be_nl_2
441 << "::Components::Cookie *" << be_nl
442 << node_->local_name () << "_Servant::subscribe_"
443 << port_name << " (" << be_idt_nl
444 << "::" << obj_name << "Consumer_ptr c)" << be_uidt_nl
445 << "{" << be_idt_nl;
447 os_ << "return this->context_->subscribe_" << port_name
448 << " (c);" << be_uidt_nl
449 << "}";
451 os_ << be_nl_2
452 << "::" << obj_name << "Consumer_ptr" << be_nl
453 << node_->local_name () << "_Servant::unsubscribe_"
454 << port_name << " (" << be_idt_nl
455 << "::Components::Cookie * ck)" << be_uidt_nl
456 << "{" << be_idt_nl;
458 os_ << "return this->context_->unsubscribe_" << port_name
459 << " (ck);" << be_uidt_nl
460 << "}";
462 return 0;
466 be_visitor_servant_svs::visit_emits (be_emits *node)
468 if (be_global->gen_lwccm ())
470 return 0;
473 const char *obj_name = node->emits_type ()->full_name ();
474 const char *port_name = node->local_name ()->get_string ();
476 os_ << be_nl_2
477 << "void" << be_nl
478 << node_->local_name () << "_Servant::connect_"
479 << port_name << " (" << be_idt_nl
480 << "::" << obj_name << "Consumer_ptr c)" << be_uidt_nl
481 << "{" << be_idt_nl
482 << "this->context_->connect_" << port_name
483 << " (c);" << be_uidt_nl
484 << "}";
486 os_ << be_nl_2
487 << "::" << obj_name << "Consumer_ptr" << be_nl
488 << node_->local_name () << "_Servant::disconnect_"
489 << port_name << " (void)" << be_nl
490 << "{" << be_idt_nl
491 << "return this->context_->disconnect_"
492 << port_name << " ();" << be_uidt_nl
493 << "}";
495 return 0;
499 be_visitor_servant_svs::visit_consumes (be_consumes *node)
501 AST_Type *obj = node->consumes_type ();
502 const char *port_name = node->local_name ()->get_string ();
504 const char *comp_lname = node_->local_name ();
505 ACE_CString comp_sname_str (
506 ScopeAsDecl (node_->defined_in ())->full_name ());
507 const char *comp_sname = comp_sname_str.c_str ();
508 const char *global = (comp_sname_str == "" ? "" : "::");
510 const char *lname = obj->local_name ()->get_string ();
511 const char *fname = obj->full_name ();
513 os_ << be_nl_2
514 << comp_lname << "_Servant::" << lname << "Consumer_"
515 << port_name << "_Servant::" << lname << "Consumer_"
516 << port_name << "_Servant (" << be_idt << be_idt_nl
517 << global << comp_sname << "::CCM_" << comp_lname
518 << "_ptr executor," << be_nl
519 << global << comp_sname << "::CCM_" << comp_lname
520 << "_Context_ptr c)" << be_uidt_nl
521 << ": executor_ ( " << global << comp_sname << "::CCM_"
522 << comp_lname << "::_duplicate (executor))," << be_idt_nl
523 << "ctx_ ( " << global << comp_sname
524 << "::CCM_" << comp_lname
525 << "_Context::_duplicate (c))" << be_uidt << be_uidt_nl
526 << "{" << be_nl
527 << "}";
529 os_ << be_nl_2
530 << comp_lname << "_Servant::" << lname << "Consumer_"
531 << port_name << "_Servant::~" << lname << "Consumer_"
532 << port_name << "_Servant (void)" << be_nl
533 << "{" << be_nl
534 << "}";
536 os_ << be_nl_2
537 << "::CORBA::Object_ptr" << be_nl
538 << comp_lname << "_Servant::" << lname << "Consumer_"
539 << port_name << "_Servant::_get_component (void)" << be_nl
540 << "{" << be_idt_nl;
542 if (ACE_OS::strcmp (be_global->ciao_container_type (), "Session") == 0)
544 os_ << "return this->ctx_->get_CCM_object ();";
546 else
548 os_ << "return ::CORBA::Object::_nil ();";
551 os_ << be_uidt_nl << "}";
553 os_ << be_nl_2
554 << "void" << be_nl
555 << comp_lname << "_Servant::" << lname << "Consumer_"
556 << port_name << "_Servant::push_" << lname
557 << " (" << be_idt_nl
558 << "::" << fname << " * evt)" << be_uidt_nl
559 << "{" << be_idt_nl
560 << "this->executor_->push_" << port_name
561 << " (evt);" << be_uidt_nl
562 << "}";
564 os_ << be_nl_2
565 << "/// Inherited from ::Components::EventConsumerBase."
566 << be_nl
567 << "void" << be_nl
568 << comp_lname << "_Servant::" << lname << "Consumer_"
569 << port_name << "_Servant::push_event (" << be_idt_nl
570 << "::Components::EventBase * ev)" << be_uidt_nl
571 << "{" << be_idt_nl
572 << "::" << fname << " * ev_type =" << be_idt_nl
573 << "::" << fname << "::_downcast (ev);"
574 << be_uidt_nl << be_nl
575 << "if (ev_type != 0)" << be_idt_nl
576 << "{" << be_idt_nl
577 << "this->push_" << lname << " (ev_type);" << be_nl
578 << "return;" << be_uidt_nl
579 << "}" << be_uidt_nl << be_nl
580 << "throw ::Components::BadEventType ();" << be_uidt_nl
581 << "}";
583 if (!be_global->gen_lwccm ())
585 os_ << be_nl_2
586 << "::" << fname << "Consumer_ptr" << be_nl
587 << node_->local_name () << "_Servant::get_consumer_"
588 << port_name << " (void)" << be_nl
589 << "{" << be_idt_nl
590 << "return" << be_idt_nl
591 << "::" << fname << "Consumer::_duplicate (" << be_idt_nl
592 << "this->consumes_" << port_name << "_.in ());"
593 << be_uidt << be_uidt << be_uidt_nl
594 << "}";
597 os_ << be_nl_2
598 << "void" << be_nl
599 << node_->local_name () << "_Servant::setup_consumer_"
600 << port_name << "_i (void)" << be_nl
601 << "{" << be_idt_nl
602 << "ACE_CString obj_id (this->ins_name_);" << be_nl
603 << "obj_id += \"_" << port_name << "\";" << be_nl_2
604 << "::CIAO::Container_var cnt_safe =" << be_idt_nl
605 << "::CIAO::Container::_duplicate ("
606 << "this->container_.in ());" << be_uidt_nl << be_nl
607 << "if (::CORBA::is_nil (cnt_safe.in ()))" << be_idt_nl
608 << "{" << be_idt_nl << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
609 << "}" << be_uidt_nl << be_nl
610 << "PortableServer::POA_var POA = cnt_safe->the_port_POA ();" << be_nl
611 << node_->local_name () << "_Servant::" << lname
612 << "Consumer_" << port_name << "_Servant *"
613 << port_name << "_servant_impl = " << be_idt_nl
614 << "new " << node_->local_name () << "_Servant::" << lname
615 << "Consumer_" << port_name << "_Servant (" << be_idt_nl
616 << " this->executor_, this->context_);" << be_uidt_nl << be_uidt_nl << be_nl
617 << "PortableServer::ServantBase_var safe_base_servant ("
618 << port_name << "_servant_impl);" << be_nl
619 << "PortableServer::ObjectId_var " << port_name << "_servant_oid =" << be_idt_nl
620 << "PortableServer::string_to_ObjectId (obj_id.c_str());" << be_uidt_nl << be_nl
621 << "POA->activate_object_with_id(" << be_idt_nl
622 << port_name << "_servant_oid.in()," << be_nl
623 << port_name << "_servant_impl);" << be_uidt_nl << be_nl
625 << "::CORBA::Object_var " << port_name << "_servant_impl_obj = " << be_idt_nl
626 << "cnt_safe->generate_reference ( " << be_idt_nl
627 << "obj_id.c_str ()," << be_nl
628 << "\"";
630 ACE_CString work (obj->repoID ());
631 ACE_CString result (work.substr (0, work.rfind (':')));
632 result += "Consumer:1.0";
634 os_ << result.c_str ();
636 os_ << "\"," << be_nl
637 << "::CIAO::Container_Types::FACET_CONSUMER_t);"
638 << be_uidt_nl << be_uidt_nl
639 << "::Components::EventConsumerBase_var ecb =" << be_idt_nl
640 << "::Components::EventConsumerBase::_narrow ("
641 << port_name << "_servant_impl_obj.in ());"
642 << be_uidt_nl << be_nl
643 << "this->add_consumer (\"" << port_name << "\", ecb.in ());"
644 << be_uidt_nl
645 << "}";
647 return 0;
650 void
651 be_visitor_servant_svs::gen_provides_top ()
653 if (this->node_->n_provides () == 0UL)
655 return;
658 ACE_CString comp_sname_str (
659 ScopeAsDecl (node_->defined_in ())->full_name ());
660 const char *global = (comp_sname_str == "" ? "" : "::");
661 ACE_CString sname_str (ScopeAsDecl (node_->defined_in ())->full_name ());
663 os_ << be_nl_2
664 << "/// CIAO-specific." << be_nl
665 << "::CORBA::Object_ptr" << be_nl
666 << node_->local_name ()
667 << "_Servant::get_facet_executor (" << be_idt_nl
668 << "const char * name)" << be_uidt_nl
669 << "{" << be_idt_nl;
671 os_ << "if (name == 0)" << be_idt_nl
672 << "{" << be_idt_nl
673 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
674 << "}" << be_uidt << be_nl_2;
676 os_ << "::" << sname_str << global << "CCM_" << node_->original_local_name ()
677 << "_var executor = " << be_idt_nl
678 << "::" << sname_str << global << "CCM_" << node_->original_local_name ()
679 << "::_duplicate (this->executor_.in ());" << be_uidt << be_nl_2;
681 os_ << "if ( ::CORBA::is_nil (executor.in ()))"
682 << be_idt_nl
683 << "{"<< be_idt_nl
684 << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
685 << "}" << be_uidt;
687 be_visitor_facet_executor_block feb_visitor (this->ctx_);
689 if (feb_visitor.visit_component_scope (node_) == -1)
691 ACE_ERROR ((LM_ERROR,
692 "be_visitor_servant_svs::"
693 "gen_provides_top - "
694 "facet executor block visitor failed\n"));
696 return;
699 os_ << be_nl_2
700 << "throw ::Components::InvalidName ();" << be_uidt_nl
701 << "}";
704 void
705 be_visitor_servant_svs::gen_publishes_top ()
707 ACE_CDR::ULong npubs = this->node_->n_publishes ();
709 if (npubs > 0UL)
711 os_ << be_nl_2
712 << "::Components::Cookie *" << be_nl
713 << node_->local_name () << "_Servant::subscribe ("
714 << be_idt_nl
715 << "const char * publisher_name," << be_nl
716 << "::Components::EventConsumerBase_ptr subscribe)"
717 << be_uidt_nl
718 << "{" << be_idt_nl;
720 os_ << "if (publisher_name == 0)" << be_idt_nl
721 << "{" << be_idt_nl
722 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
723 << "}" << be_uidt;
725 be_visitor_subscribe_block sb_visitor (this->ctx_);
727 if (sb_visitor.visit_component_scope (node_) == -1)
729 ACE_ERROR ((LM_ERROR,
730 "be_visitor_servant_svs::"
731 "gen_publishes_top - "
732 "subscribe block visitor failed\n"));
734 return;
737 os_ << be_nl_2
738 << "throw ::Components::InvalidName ();" << be_uidt_nl
739 << "}";
741 os_ << be_nl_2
742 << "::Components::EventConsumerBase_ptr" << be_nl
743 << node_->local_name () << "_Servant::unsubscribe ("
744 << be_idt_nl
745 << "const char * publisher_name," << be_nl
746 << "::Components::Cookie * ck)" << be_uidt_nl
747 << "{" << be_idt_nl;
749 os_ << "if (publisher_name == 0)" << be_idt_nl
750 << "{" << be_idt_nl
751 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
752 << "}" << be_uidt;
754 be_visitor_unsubscribe_block ub_visitor (this->ctx_);
756 if (ub_visitor.visit_component_scope (node_) == -1)
758 ACE_ERROR ((LM_ERROR,
759 "be_visitor_servant_svs::"
760 "gen_publishes_top - "
761 "unsubscribe block visitor failed\n"));
763 return;
766 os_ << be_nl_2
767 << "throw ::Components::InvalidName ();" << be_uidt_nl
768 << "}";
771 if (!be_global->gen_lwccm () && !be_global->gen_noeventccm () && this->node_->n_publishes () != 0)
773 os_ << be_nl_2
774 << "::Components::PublisherDescriptions *" << be_nl
775 << node_->local_name ()
776 << "_Servant::get_all_publishers (void)" << be_nl
777 << "{" << be_idt_nl
778 << "::Components::PublisherDescriptions *retval = 0;"
779 << be_nl
780 << "ACE_NEW_THROW_EX (retval," << be_nl
781 << " ::Components::PublisherDescriptions,"
782 << be_nl
783 << " ::CORBA::NO_MEMORY ());" << be_nl_2
784 << "::Components::PublisherDescriptions_var "
785 << "safe_retval = retval;" << be_nl
786 << "safe_retval->length (" << this->node_->n_publishes ()
787 << "UL);";
789 if (npubs > 0UL)
791 be_visitor_event_source_desc esd_visitor (this->ctx_);
793 if (esd_visitor.visit_component_scope (node_) == -1)
795 ACE_ERROR ((LM_ERROR,
796 ACE_TEXT ("be_visitor_servant_svs::")
797 ACE_TEXT ("gen_publishes_top - ")
798 ACE_TEXT ("event source description ")
799 ACE_TEXT ("visitor failed\n")));
801 return;
805 os_ << be_nl_2
806 << "return safe_retval._retn ();" << be_uidt_nl
807 << "}";
811 void
812 be_visitor_servant_svs::gen_uses_top ()
814 ACE_CDR::ULong nuses = this->node_->n_uses ();
816 if (nuses > 0UL)
818 os_ << be_nl_2
819 << "::Components::Cookie *" << be_nl
820 << node_->local_name () << "_Servant::connect ("
821 << be_idt_nl
822 << "const char * name," << be_nl
823 << "::CORBA::Object_ptr connection)" << be_uidt_nl
824 << "{" << be_idt_nl;
826 os_ << "if (name == 0)" << be_idt_nl
827 << "{" << be_idt_nl
828 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
829 << "}" << be_uidt;
831 be_visitor_connect_block cb_visitor (this->ctx_);
833 if (cb_visitor.visit_component_scope (node_) == -1)
835 ACE_ERROR ((LM_ERROR,
836 ACE_TEXT ("be_visitor_servant_svs::")
837 ACE_TEXT ("gen_uses_top - ")
838 ACE_TEXT ("connect block visitor failed\n")));
840 return;
843 os_ << be_nl_2
844 << "throw ::Components::InvalidName ();" << be_uidt_nl
845 << "}";
847 os_ << be_nl_2
848 << "::CORBA::Object_ptr" << be_nl
849 << node_->local_name () << "_Servant::disconnect ("
850 << be_idt_nl
851 << "const char * name," << be_nl
852 << "::Components::Cookie * "
853 << (this->node_->has_uses_multiple () ? "ck" : "/* ck */")
854 << ")" << be_uidt_nl
855 << "{" << be_idt_nl
856 << "if (name == 0)" << be_idt_nl
857 << "{" << be_idt_nl
858 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
859 << "}" << be_uidt;
861 be_visitor_disconnect_block db_visitor (this->ctx_);
863 if (db_visitor.visit_component_scope (node_) == -1)
865 ACE_ERROR ((LM_ERROR,
866 "be_visitor_servant_svs::"
867 "gen_uses_top - "
868 "disconnect block visitor failed\n"));
870 return;
873 os_ << be_nl_2
874 << "throw ::Components::InvalidName ();" << be_uidt_nl
875 << "}";
876 } // nuses > 0UL
878 if (!be_global->gen_lwccm () && nuses > 0)
880 os_ << be_nl_2
881 << "::Components::ReceptacleDescriptions *" << be_nl
882 << node_->local_name ()
883 << "_Servant::get_all_receptacles (void)" << be_nl
884 << "{" << be_idt_nl
885 << "::Components::ReceptacleDescriptions * retval = 0;"
886 << be_nl
887 << "ACE_NEW_THROW_EX (retval," << be_nl
888 << " ::Components::ReceptacleDescriptions,"
889 << be_nl
890 << " ::CORBA::NO_MEMORY ());" << be_nl_2
891 << "::Components::ReceptacleDescriptions_var "
892 << "safe_retval = retval;" << be_nl
893 << "safe_retval->length (" << nuses
894 << "UL);";
896 if (nuses > 0UL)
898 be_visitor_receptacle_desc rd_visitor (this->ctx_, this->node_);
900 if (rd_visitor.visit_component_scope (node_) == -1)
902 ACE_ERROR ((LM_ERROR,
903 ACE_TEXT ("be_visitor_servant_svs::")
904 ACE_TEXT ("gen_uses_top - ")
905 ACE_TEXT ("receptacle description ")
906 ACE_TEXT ("visitor failed\n")));
908 return;
912 os_ << be_nl_2
913 << "return safe_retval._retn ();" << be_uidt_nl
914 << "}";
918 void
919 be_visitor_servant_svs::gen_emits_top ()
921 /// Generated whether the component has emits ports
922 /// or not, except if we are generating a LwCCM
923 /// profile, in which case this call returns
924 /// immediately, and the base class method
925 /// (returning a null pointer to a sequence of
926 /// emitter descriptions) is seen instead.
927 this->gen_get_all_emitters ();
929 if (this->node_->n_emits () == 0UL)
931 return;
934 os_ << be_nl_2
935 << "void" << be_nl
936 << node_->local_name () << "_Servant::connect_consumer ("
937 << be_idt_nl
938 << "const char * emitter_name," << be_nl
939 << "::Components::EventConsumerBase_ptr consumer)"
940 << be_uidt_nl
941 << "{" << be_idt_nl;
943 os_ << "if (emitter_name == 0)" << be_idt_nl
944 << "{" << be_idt_nl
945 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
946 << "}" << be_uidt;
948 be_visitor_connect_consumer_block ccb_visitor (this->ctx_);
950 if (ccb_visitor.visit_component_scope (node_) == -1)
952 ACE_ERROR ((LM_ERROR,
953 "be_visitor_servant_svs::"
954 "gen_emits_top - "
955 "connect consumer block visitor failed\n"));
957 return;
960 os_ << be_nl_2
961 << "throw ::Components::InvalidName ();" << be_uidt_nl
962 << "}";
964 os_ << be_nl_2
965 << "::Components::EventConsumerBase_ptr" << be_nl
966 << node_->local_name ()
967 << "_Servant::disconnect_consumer (" << be_idt_nl
968 << "const char * source_name)" << be_uidt_nl
969 << "{" << be_idt_nl;
971 os_ << "if (source_name == 0)" << be_idt_nl
972 << "{" << be_idt_nl
973 << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
974 << "}" << be_uidt;
976 be_visitor_disconnect_consumer_block dcb_visitor (this->ctx_);
978 if (dcb_visitor.visit_component_scope (node_) == -1)
980 ACE_ERROR ((LM_ERROR,
981 "be_visitor_servant_svs::"
982 "gen_emits_top - "
983 "disconnect consumer block visitor failed\n"));
985 return;
988 os_ << be_nl_2
989 << "throw ::Components::InvalidName ();" << be_uidt_nl
990 << "}";
993 void
994 be_visitor_servant_svs::gen_get_all_emitters ()
996 if (be_global->gen_lwccm () || be_global->gen_noeventccm () || this->node_->n_emits () == 0UL)
998 return;
1001 os_ << be_nl_2
1002 << "::Components::EmitterDescriptions *" << be_nl
1003 << node_->local_name ()
1004 << "_Servant::get_all_emitters (void)" << be_nl
1005 << "{" << be_idt_nl
1006 << "::Components::EmitterDescriptions *retval = 0;"
1007 << be_nl
1008 << "ACE_NEW_THROW_EX (retval," << be_nl
1009 << " ::Components::EmitterDescriptions,"
1010 << be_nl
1011 << " ::CORBA::NO_MEMORY ());" << be_nl_2
1012 << "::Components::EmitterDescriptions_var "
1013 << "safe_retval = retval;" << be_nl
1014 << "safe_retval->length (" << this->node_->n_emits ()
1015 << "UL);";
1017 be_visitor_emitter_desc ed_visitor (this->ctx_);
1019 if (ed_visitor.visit_component_scope (node_) == -1)
1021 ACE_ERROR ((LM_ERROR,
1022 "be_visitor_servant_svs::"
1023 "gen_emits_top - "
1024 "emitter description visitor failed\n"));
1026 return;
1029 os_ << be_nl_2
1030 << "return safe_retval._retn ();" << be_uidt_nl
1031 << "}";
1034 // ==========================================================
1036 be_visitor_obv_factory_reg::be_visitor_obv_factory_reg (
1037 be_visitor_context *ctx)
1038 : be_visitor_component_scope (ctx)
1042 be_visitor_obv_factory_reg::~be_visitor_obv_factory_reg ()
1047 be_visitor_obv_factory_reg::visit_publishes (be_publishes *node)
1049 this->gen_obv_factory_registration (node->field_type ());
1051 return 0;
1055 be_visitor_obv_factory_reg::visit_emits (be_emits *node)
1057 this->gen_obv_factory_registration (node->field_type ());
1059 return 0;
1063 be_visitor_obv_factory_reg::visit_consumes (be_consumes *node)
1065 this->gen_obv_factory_registration (node->field_type ());
1067 return 0;
1070 void
1071 be_visitor_obv_factory_reg::gen_obv_factory_registration (AST_Type *t)
1073 if (be_global->gen_ciao_valuefactory_reg ())
1075 const char *fname = t->full_name ();
1077 os_ << "TAO_OBV_REGISTER_FACTORY (" << be_idt_nl
1078 << "::" << fname << "_init," << be_nl
1079 << "::" << fname << ");" << be_uidt_nl;
1083 // ==========================================================
1085 be_visitor_attr_set::be_visitor_attr_set (be_visitor_context *ctx)
1086 : be_visitor_component_scope (ctx)
1090 be_visitor_attr_set::~be_visitor_attr_set ()
1095 be_visitor_attr_set::visit_attribute (be_attribute *node)
1097 be_visitor_attribute_ccm_init v (this->ctx_);
1099 if (v.visit_attribute (node) == -1)
1101 ACE_ERROR_RETURN ((LM_ERROR,
1102 ACE_TEXT ("be_visitor_attr_set")
1103 ACE_TEXT ("::visit_attribute - ")
1104 ACE_TEXT ("ccm attr init visitor ")
1105 ACE_TEXT ("failed\n")),
1106 -1);
1109 return 0;
1113 be_visitor_attr_set::visit_component_scope (be_component *node)
1115 if (node == 0)
1117 return 0;
1120 this->ctx_->interface (node);
1122 if (this->visit_scope (node) == -1)
1124 ACE_ERROR_RETURN ((LM_ERROR,
1125 ACE_TEXT ("be_visitor_attr_set")
1126 ACE_TEXT ("::visit_component_scope - ")
1127 ACE_TEXT ("visit_scope() failed\n")),
1128 -1);
1131 /// This overload of traverse_inheritance_graph() used here
1132 /// doesn't automatically prime the queues.
1133 node->get_insert_queue ().reset ();
1134 node->get_del_queue ().reset ();
1135 node->get_insert_queue ().enqueue_tail (node);
1137 Component_Op_Attr_Generator component_inher (this);
1139 int status =
1140 node->traverse_inheritance_graph (component_inher,
1141 &os_,
1142 false,
1143 false);
1144 if (status == -1)
1146 ACE_ERROR_RETURN ((LM_ERROR,
1147 ACE_TEXT ("be_visitor_attr_set")
1148 ACE_TEXT ("::visit_component_scope - ")
1149 ACE_TEXT ("traverse_inheritance_graph() ")
1150 ACE_TEXT ("failed\n")),
1151 -1);
1154 // Recurse to the base class method for the base component(s)
1155 // so traverse_inheritance_graph() will not be called again,
1156 // which would output assignments for the attributes inherited
1157 // from the base componnent's supported interfaces multiple times.
1158 return
1159 this->be_visitor_component_scope::visit_component_scope (node->base_component ());
1162 // ==========================================================
1164 be_visitor_facet_executor_block::be_visitor_facet_executor_block (
1165 be_visitor_context *ctx)
1166 : be_visitor_component_scope (ctx)
1170 be_visitor_facet_executor_block::~be_visitor_facet_executor_block (
1176 be_visitor_facet_executor_block::visit_provides (
1177 be_provides *node)
1179 ACE_CString prefix (this->ctx_->port_prefix ());
1180 prefix += node->local_name ()->get_string ();
1181 const char *port_name = prefix.c_str ();
1183 os_ << be_nl_2
1184 << "if (ACE_OS::strcmp (name, \"" << port_name
1185 << "\") == 0)" << be_idt_nl
1186 << "{" << be_idt_nl
1187 << "return executor->get_" << port_name
1188 << " ();" << be_uidt_nl
1189 << "}" << be_uidt;
1191 return 0;
1194 // ======================================================
1196 be_visitor_connect_block::be_visitor_connect_block (
1197 be_visitor_context *ctx)
1198 : be_visitor_component_scope (ctx)
1202 be_visitor_connect_block::~be_visitor_connect_block ()
1207 be_visitor_connect_block::visit_uses (be_uses *node)
1209 ACE_CString prefix (this->ctx_->port_prefix ());
1210 prefix += node->local_name ()->get_string ();
1211 const char *port_name = prefix.c_str ();
1213 const char *obj_name = node->uses_type ()->full_name ();
1214 bool const is_multiple = node->is_multiple ();
1216 os_ << be_nl_2
1217 << "if (ACE_OS::strcmp (name, \"" << port_name
1218 << "\") == 0)" << be_idt_nl
1219 << "{" << be_idt_nl
1220 << "::" << obj_name << "_var _ciao_conn =" << be_idt_nl
1221 << "::" << obj_name << "::_narrow (connection);"
1222 << be_uidt_nl << be_nl;
1224 os_ << "/// " << (is_multiple ? "Multiplex" : "Simplex")
1225 << " connect." << be_nl
1226 << (is_multiple ? "return " : "") << "this->context_->connect_"
1227 << port_name << " (_ciao_conn.in ());";
1229 if (! is_multiple)
1231 os_ << be_nl
1232 << "return 0;";
1235 os_ << be_uidt_nl
1236 << "}" << be_uidt;
1238 return 0;
1241 // ======================================================
1243 be_visitor_disconnect_block::be_visitor_disconnect_block (
1244 be_visitor_context *ctx)
1245 : be_visitor_component_scope (ctx)
1249 be_visitor_disconnect_block::~be_visitor_disconnect_block (
1255 be_visitor_disconnect_block::visit_uses (be_uses *node)
1257 ACE_CString prefix (this->ctx_->port_prefix ());
1258 prefix += node->local_name ()->get_string ();
1259 const char *port_name = prefix.c_str ();
1261 bool const is_multiple = node->is_multiple ();
1263 os_ << be_nl_2
1264 << "if (ACE_OS::strcmp (name, \"" << port_name
1265 << "\") == 0)" << be_idt_nl
1266 << "{" << be_idt_nl
1267 << "/// " << (is_multiple ? "Multiplex" : "Simplex")
1268 << " disconnect." << be_nl;
1270 if (is_multiple)
1272 os_ << "if (ck == 0)" << be_idt_nl
1273 << "{" << be_idt_nl
1274 << "throw ::Components::CookieRequired ();" << be_uidt_nl
1275 << "}" << be_uidt_nl << be_nl;
1278 os_ << "return this->context_->disconnect_" << port_name
1279 << " (" << (is_multiple ? "ck" : "") << ");" << be_uidt_nl
1280 << "}" << be_uidt;
1282 return 0;
1285 // ======================================================
1287 be_visitor_receptacle_desc::be_visitor_receptacle_desc (
1288 be_visitor_context *ctx,
1289 be_component *node)
1290 : be_visitor_component_scope (ctx),
1291 slot_ (0UL),
1292 comp_ (node)
1294 node_ = node;
1297 be_visitor_receptacle_desc::~be_visitor_receptacle_desc (
1303 be_visitor_receptacle_desc::visit_uses (be_uses *node)
1305 ACE_CString prefix (this->ctx_->port_prefix ());
1306 prefix += node->local_name ()->get_string ();
1307 const char *port_name = prefix.c_str ();
1309 AST_Type *obj = node->uses_type ();
1310 bool const is_multiple = node->is_multiple ();
1312 os_ << be_nl_2;
1314 ACE_CString sname_str (comp_->full_name ());
1315 const char *sname = sname_str.c_str ();
1317 const char *global = (sname_str == "" ? "" : "::");
1319 if (!is_multiple)
1321 os_ << obj->full_name () << "_var ciao_"
1322 << port_name << " = " << be_idt_nl
1323 << "this->context_->get_connection_"
1324 << port_name << " ();" << be_uidt_nl;
1326 else
1328 os_ << "::" << sname << global << port_name << "Connections_var ciao_"
1329 << port_name << " = " << be_idt_nl
1330 << "this->context_->get_connections_"
1331 << port_name << " ();" << be_uidt_nl;
1334 os_ << "::CIAO::Servant::describe_"
1335 << (is_multiple ? "multiplex" : "simplex")
1336 << "_receptacle<" << be_idt_nl;
1338 if (!is_multiple)
1340 os_ << "::" << obj->full_name () << "> (" << be_idt_nl;
1342 else
1344 os_ << "::" << sname << global << port_name << "Connections> (" << be_idt_nl;
1347 os_ << "\"" << port_name << "\"," << be_nl
1348 << "\"" << obj->repoID () << "\"," << be_nl;
1350 os_ << "ciao_" << port_name << ".in ()," << be_nl;
1352 os_ << "safe_retval," << be_nl
1353 << slot_++ << "UL);" << be_uidt << be_uidt;
1355 return 0;
1358 // ======================================================
1360 be_visitor_subscribe_block::be_visitor_subscribe_block (
1361 be_visitor_context *ctx)
1362 : be_visitor_component_scope (ctx)
1366 be_visitor_subscribe_block::~be_visitor_subscribe_block (
1372 be_visitor_subscribe_block::visit_publishes (
1373 be_publishes *node)
1375 const char *obj_name =
1376 node->publishes_type ()->full_name ();
1377 const char *port_name =
1378 node->local_name ()->get_string ();
1380 os_ << be_nl_2
1381 << "if (ACE_OS::strcmp (publisher_name, \""
1382 << port_name << "\") == 0)" << be_idt_nl
1383 << "{" << be_idt_nl
1384 << "::" << obj_name << "Consumer_var sub =" << be_idt_nl
1385 << "::" << obj_name << "Consumer::_narrow (subscribe);"
1386 << be_uidt_nl << be_nl
1387 << "return this->context_->subscribe_" << port_name
1388 << " (sub.in ());" << be_uidt_nl
1389 << "}" << be_uidt;
1391 return 0;
1394 // ==========================================================
1396 be_visitor_unsubscribe_block::be_visitor_unsubscribe_block (
1397 be_visitor_context *ctx)
1398 : be_visitor_component_scope (ctx)
1402 be_visitor_unsubscribe_block::~be_visitor_unsubscribe_block (
1408 be_visitor_unsubscribe_block::visit_publishes (
1409 be_publishes *node)
1411 const char *port_name =
1412 node->local_name ()->get_string ();
1414 os_ << be_nl_2
1415 << "if (ACE_OS::strcmp (publisher_name, \""
1416 << port_name << "\") == 0)" << be_idt_nl
1417 << "{" << be_idt_nl
1418 << "return this->context_->unsubscribe_" << port_name
1419 << " (ck);" << be_uidt_nl
1420 << "}" << be_uidt;
1422 return 0;
1425 // ==========================================================
1427 be_visitor_event_source_desc::be_visitor_event_source_desc (
1428 be_visitor_context *ctx)
1429 : be_visitor_component_scope (ctx),
1430 slot_ (0UL)
1434 be_visitor_event_source_desc::~be_visitor_event_source_desc (
1440 be_visitor_event_source_desc::visit_publishes (
1441 be_publishes *node)
1443 AST_Type *obj = node->publishes_type ();
1444 const char *port_name =
1445 node->local_name ()->get_string ();
1447 os_ << be_nl_2;
1449 os_ << "{" << be_idt_nl
1450 << "ACE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
1451 << " mon," << be_nl
1452 << " this->context_->"
1453 << port_name << "_lock_," << be_nl
1454 << " 0);" << be_nl_2;
1456 os_ << "::CIAO::Servant::describe_pub_event_source<"
1457 << be_idt_nl
1458 << "::" << obj->full_name () << "Consumer_var> ("
1459 << be_idt_nl
1460 << "\"" << port_name << "\"," << be_nl
1461 << "\"" << obj->repoID () << "\"," << be_nl
1462 << "this->context_->ciao_publishes_"
1463 << port_name << "_," << be_nl
1464 << "safe_retval," << be_nl
1465 << slot_++ << "UL);" << be_uidt << be_uidt;
1467 os_ << be_uidt_nl
1468 << "}";
1470 return 0;
1473 // ======================================================
1475 be_visitor_connect_consumer_block::be_visitor_connect_consumer_block (
1476 be_visitor_context *ctx)
1477 : be_visitor_component_scope (ctx)
1481 be_visitor_connect_consumer_block::~be_visitor_connect_consumer_block ()
1486 be_visitor_connect_consumer_block::visit_emits (
1487 be_emits *node)
1489 const char *obj_name =
1490 node->emits_type ()->full_name ();
1491 const char *port_name =
1492 node->local_name ()->get_string ();
1494 os_ << be_nl_2
1495 << "if (ACE_OS::strcmp (emitter_name, \""
1496 << port_name << "\") == 0)" << be_idt_nl
1497 << "{" << be_idt_nl
1498 << "::" << obj_name
1499 << "Consumer_var _ciao_consumer =" << be_idt_nl
1500 << "::" << obj_name
1501 << "Consumer::_narrow (consumer);" << be_uidt_nl << be_nl
1502 << "this->context_->connect_" << port_name
1503 << " (_ciao_consumer.in ());" << be_nl_2
1504 << "return;" << be_uidt_nl
1505 << "}" << be_uidt;
1507 return 0;
1510 // ======================================================
1512 be_visitor_disconnect_consumer_block::be_visitor_disconnect_consumer_block (
1513 be_visitor_context *ctx)
1514 : be_visitor_component_scope (ctx)
1518 be_visitor_disconnect_consumer_block::~be_visitor_disconnect_consumer_block (
1524 be_visitor_disconnect_consumer_block::visit_emits (
1525 be_emits *node)
1527 const char *port_name =
1528 node->local_name ()->get_string ();
1530 os_ << be_nl_2
1531 << "if (ACE_OS::strcmp (source_name, \""
1532 << port_name << "\") == 0)" << be_idt_nl
1533 << "{" << be_idt_nl
1534 << "return this->context_->disconnect_" << port_name
1535 << " ();" << be_uidt_nl
1536 << "}" << be_uidt;
1538 return 0;
1541 // ======================================================
1543 be_visitor_emitter_desc::be_visitor_emitter_desc (
1544 be_visitor_context *ctx)
1545 : be_visitor_component_scope (ctx),
1546 slot_ (0UL)
1550 be_visitor_emitter_desc::~be_visitor_emitter_desc (
1556 be_visitor_emitter_desc::visit_emits (be_emits *node)
1558 AST_Type *obj = node->emits_type ();
1559 const char *port_name =
1560 node->local_name ()->get_string ();
1562 os_ << be_nl_2
1563 << "::CIAO::Servant::describe_emit_event_source<"
1564 << be_idt_nl
1565 << "::" << obj->full_name () << "Consumer_var> ("
1566 << be_idt_nl
1567 << "\"" << port_name << "\"," << be_nl
1568 << "\"" << obj->repoID () << "\"," << be_nl
1569 << "this->context_->ciao_emits_" << port_name
1570 << "_consumer_," << be_nl
1571 << "safe_retval," << be_nl
1572 << slot_++ << "UL);" << be_uidt << be_uidt;
1574 return 0;
1577 // ======================================================
1579 be_visitor_populate_port_tables::be_visitor_populate_port_tables (
1580 be_visitor_context *ctx)
1581 : be_visitor_component_scope (ctx)
1585 be_visitor_populate_port_tables::~be_visitor_populate_port_tables (
1591 be_visitor_populate_port_tables::visit_provides (
1592 be_provides *node)
1594 if (node->provides_type ()->is_local ())
1596 return 0;
1599 ACE_CString prefix (this->ctx_->port_prefix ());
1600 prefix += node->local_name ()->get_string ();
1601 const char *port_name = prefix.c_str ();
1603 os_ << be_nl
1604 << "this->setup_"
1605 << port_name << "_i ();";
1607 return 0;
1611 be_visitor_populate_port_tables::visit_consumes (
1612 be_consumes *node)
1614 os_ << be_nl
1615 << "this->setup_consumer_"
1616 << node->local_name ()->get_string () << "_i ();";
1618 return 0;
1621 // ======================================================
1623 Component_Op_Attr_Generator::Component_Op_Attr_Generator (
1624 be_visitor_scope * visitor)
1625 : visitor_ (visitor)
1630 Component_Op_Attr_Generator::emit (be_interface * /* derived_interface */,
1631 TAO_OutStream * /* os */,
1632 be_interface * base_interface)
1634 AST_Decl::NodeType nt = base_interface->node_type ();
1636 if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector)
1638 return 0;
1641 return visitor_->visit_scope (base_interface);