2 //=============================================================================
6 * Visitor generating code for facets in the exec impl source.
10 //=============================================================================
12 #include "component.h"
14 be_visitor_facet_exs::be_visitor_facet_exs (
15 be_visitor_context
*ctx
)
16 : be_visitor_component_scope (ctx
),
18 comment_start_border_ ("/**"),
19 comment_end_border_ (" */")
23 be_visitor_facet_exs::~be_visitor_facet_exs ()
28 be_visitor_facet_exs::visit_operation (be_operation
*node
)
30 AST_Decl::NodeType nt
=
31 ScopeAsDecl (node
->defined_in ())->node_type ();
33 // Components have implied IDL operations added to the AST, but
34 // we are interested only in supported interface operations.
35 if (nt
== AST_Decl::NT_component
|| nt
== AST_Decl::NT_connector
)
40 be_visitor_operation_exs
v (this->ctx_
);
41 v
.scope (this->op_scope_
);
42 return v
.visit_operation (node
);
46 be_visitor_facet_exs::visit_attribute (be_attribute
*node
)
48 AST_Decl::NodeType nt
= this->node_
->node_type ();
50 // Executor attribute code generated for porttype attributes
51 // always in connectors and only for mirrorports in components.
52 if (this->in_ext_port_
&& nt
== AST_Decl::NT_component
)
58 dynamic_cast<be_decl
*> (ScopeAsDecl (node
->defined_in ()));
60 nt
= attr_scope
->node_type ();
62 // Components have implied IDL operations added to the AST, but
63 // we are interested only in supported interface operations.
64 if (nt
== AST_Decl::NT_component
|| nt
== AST_Decl::NT_connector
)
69 be_visitor_attribute
v (this->ctx_
);
70 v
.op_scope (this->op_scope_
);
71 return v
.visit_attribute (node
);
75 be_visitor_facet_exs::visit_provides (be_provides
*node
)
77 be_type
*impl
= node
->provides_type ();
79 ACE_CString
lname_str (this->ctx_
->port_prefix ());
80 lname_str
+= node
->original_local_name ()->get_string ();
81 const char *lname
= lname_str
.c_str ();
84 << comment_start_border_
<< be_nl
85 << " * Facet Executor Implementation Class: "
86 << lname
<< "_exec_i" << be_nl
87 << comment_end_border_
;
89 AST_Decl
*c_scope
= ScopeAsDecl (this->node_
->defined_in ());
90 bool is_global
= (c_scope
->node_type () == AST_Decl::NT_root
);
91 const char *smart_scope
= (is_global
? "" : "::");
94 << lname
<< "_exec_i::" << lname
95 << "_exec_i (" << be_idt
<< be_idt
<< be_idt_nl
96 << smart_scope
<< c_scope
->full_name () << "::CCM_"
97 << this->node_
->local_name () << "_Context_ptr ctx)"
98 << be_uidt
<< be_uidt_nl
99 << ": ciao_context_ (" << be_idt
<< be_idt_nl
100 << smart_scope
<< c_scope
->full_name ()
101 << "::CCM_" << this->node_
->local_name ()
102 << "_Context::_duplicate (ctx))"
103 << be_uidt
<< be_uidt
<< be_uidt_nl
108 << lname
<< "_exec_i::~" << lname
109 << "_exec_i ()" << be_nl
113 this->op_scope_
= node
;
115 if (impl
->node_type () == AST_Decl::NT_interface
)
118 dynamic_cast<be_interface
*> (impl
);
121 << "// Operations from ::" << intf
->full_name ();
123 /// The overload of traverse_inheritance_graph() used here
124 /// doesn't automatically prime the queues.
125 intf
->get_insert_queue ().reset ();
126 intf
->get_del_queue ().reset ();
127 intf
->get_insert_queue ().enqueue_tail (intf
);
129 Component_Exec_Op_Attr_Generator
op_attr_gen (this);
132 intf
->traverse_inheritance_graph (op_attr_gen
,
139 ACE_ERROR_RETURN ((LM_ERROR
,
140 ACE_TEXT ("be_visitor_facet_exs::")
141 ACE_TEXT ("visit_provides - ")
142 ACE_TEXT ("traverse_inheritance_graph() ")
143 ACE_TEXT ("failed\n")),