component_cs.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 308 行
CPP
308 行
//
// component_cs.cpp,v 1.14 2003/11/05 03:20:27 bala Exp
//
// ============================================================================
//
// = LIBRARY
// TAO IDL
//
// = FILENAME
// component_cs.cpp
//
// = DESCRIPTION
// Visitor generating code for Components in the client stub.
//
// = AUTHOR
// Jeff Parsons
//
// ============================================================================
ACE_RCSID (be_visitor_component,
component_cs,
"component_cs.cpp,v 1.14 2003/11/05 03:20:27 bala Exp")
// ******************************************************
// Component visitor for client stub
// ******************************************************
be_visitor_component_cs::be_visitor_component_cs (be_visitor_context *ctx)
: be_visitor_component (ctx)
{
}
be_visitor_component_cs::~be_visitor_component_cs (void)
{
}
int
be_visitor_component_cs::visit_component (be_component *node)
{
if (node->cli_stub_gen () || node->imported ())
{
return 0;
}
be_type *bt;
// Set the right type.
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
if (node->is_defined ())
{
*os << be_nl << be_nl
<< "// Traits specializations for " << node->name () << ".";
*os << be_nl << be_nl
<< "ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION " << be_nl
<< node->name () << "_ptr" << be_nl
<< "TAO::Objref_Traits<" << node->name () << ">::tao_duplicate ("
<< be_idt << be_idt_nl
<< node->name () << "_ptr p" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "return " << node->name () << "::_duplicate (p);" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION " << be_nl
<< "void" << be_nl
<< "TAO::Objref_Traits<" << node->name () << ">::tao_release ("
<< be_idt << be_idt_nl
<< node->name () << "_ptr p" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "CORBA::release (p);" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION " << be_nl
<< node->name () << "_ptr" << be_nl
<< "TAO::Objref_Traits<" << node->name () << ">::tao_nil (void)"
<< be_nl
<< "{" << be_idt_nl
<< "return " << node->name () << "::_nil ();" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION " << be_nl
<< "CORBA::Boolean" << be_nl
<< "TAO::Objref_Traits<" << node->name () << ">::tao_marshal ("
<< be_idt << be_idt_nl
<< node->name () << "_ptr p," << be_nl
<< "TAO_OutputCDR & cdr" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "return p->marshal (cdr);" << be_uidt_nl
<< "}";
}
// Generate the proxy broker factory function pointer definition.
*os << be_nl << be_nl
<< "// Function pointer for collocation factory initialization."
<< be_nl
<< "TAO::Collocation_Proxy_Broker * " << be_nl
<< "(*" << node->flat_client_enclosing_scope ()
<< node->base_proxy_broker_name ()
<< "_Factory_function_pointer) ("
<< be_idt << be_idt_nl
<< "CORBA::Object_ptr obj" << be_uidt_nl
<< ") = 0;" << be_uidt;
// Generate the destructor and default constructor.
*os << be_nl << be_nl
<< node->name () << "::~" << node->local_name ()
<< " (void)" << be_nl;
*os << "{}" << be_nl << be_nl;
*os << node->name () << "::" << node->local_name ()
<< " (int collocated)" << be_nl
<< "{" << be_idt_nl
<< "this->" << node->flat_name ()
<< "_setup_collocation (collocated);" << be_uidt_nl
<< be_uidt << "}" << be_nl << be_nl;
// Collocation setup method.
*os << "void" << be_nl
<< node->name () << "::" << node->flat_name ()
<< "_setup_collocation (int collocated)" << be_nl
<< "{" << be_idt_nl
<< "if (collocated)" << be_idt_nl
<< "this->the" << node->base_proxy_broker_name ()
<< "_ =" << be_idt_nl
<< "::" << node->flat_client_enclosing_scope ()
<< node->base_proxy_broker_name ()
<< "_Factory_function_pointer (this);"
<< be_uidt << be_uidt_nl;
AST_Component *base = node->base_component ();
if (base != 0)
{
*os << be_nl
<< "this->" << base->flat_name ()
<< "_setup_collocation" << " (collocated);";
}
*os << be_uidt_nl << "}" << be_nl << be_nl;
if (be_global->any_support ())
{
*os << "void " << be_nl
<< node->name ()
<< "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl
<< "{" << be_idt_nl
<< node->local_name () << " *_tao_tmp_pointer = ACE_static_cast ("
<< node->local_name () << " *, _tao_void_pointer);" << be_nl
<< "CORBA::release (_tao_tmp_pointer);" << be_uidt_nl
<< "}" << be_nl << be_nl;
}
// The _narrow method.
*os << node->full_name () << "_ptr" << be_nl << node->full_name ()
<< "::_narrow (" << be_idt << be_idt_nl
<< "CORBA::Object_ptr"
<< " _tao_objref" << be_nl
<< "ACE_ENV_ARG_DECL" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl;
*os << "return" << be_idt_nl
<< "TAO::Narrow_Utils<"
<< node->local_name () << ">::narrow (";
*os << be_idt << be_idt_nl
<< "_tao_objref," << be_nl
<< "\"" << node->repoID () << "\"," << be_nl
<< node->flat_client_enclosing_scope ()
<< node->base_proxy_broker_name ()
<< "_Factory_function_pointer" << be_nl
<< "ACE_ENV_ARG_PARAMETER" << be_uidt_nl
<< ");" << be_uidt << be_uidt << be_uidt_nl
<< "}" << be_nl << be_nl;
// The _duplicate method
*os << node->full_name () << "_ptr" << be_nl
<< node->full_name () << "::_duplicate ("
<< bt->nested_type_name (this->ctx_->scope ())
<< "_ptr obj)" << be_nl
<< "{" << be_idt_nl
<< "if (! CORBA::is_nil (obj))" << be_idt_nl
<< "{" << be_idt_nl
<< "obj->_add_ref ();" << be_uidt_nl
<< "}" << be_uidt_nl << be_nl
<< "return obj;" << be_uidt_nl
<< "}" << be_nl << be_nl;
// The is_a method.
*os << "CORBA::Boolean" << be_nl
<< node->full_name () << "::_is_a (" << be_idt << be_idt_nl
<< "const char *value" << be_nl
<< "ACE_ENV_ARG_DECL" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "if (" << be_idt << be_idt_nl;
AST_Component *ancestor = node;
while (ancestor != 0)
{
*os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl
<< "(char *)value," << be_nl
<< "\"" << ancestor->repoID () << "\"" << be_uidt_nl
<< ") ||" << be_uidt_nl;
ancestor = ancestor->base_component ();
}
*os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl
<< "(char *)value," << be_nl
<< "\"IDL:omg.org/Components/CCMObject:1.0\"" << be_uidt_nl
<< ")" << be_uidt << be_uidt_nl
<< " )" << be_nl
<< "{" << be_idt_nl
<< "return 1; // success using local knowledge" << be_uidt_nl
<< "}" << be_uidt_nl
<< "else" << be_idt_nl
<< "{" << be_idt_nl
<< "return this->Object::_is_a (" << be_idt << be_idt_nl
<< "value" << be_nl
<< "ACE_ENV_ARG_PARAMETER" << be_uidt_nl
<< ");" << be_uidt << be_uidt_nl
<< "}" << be_uidt << be_uidt_nl
<< "}" << be_nl << be_nl;
*os << "const char*" << be_nl
<< node->full_name ()
<< "::_interface_repository_id (void) const"
<< be_nl
<< "{" << be_idt_nl
<< "return \"" << node->repoID ()
<< "\";" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "CORBA::Boolean" << be_nl
<< node->name () << "::marshal (TAO_OutputCDR &cdr)" << be_nl
<< "{" << be_idt_nl
<< "return (cdr << this);" << be_uidt_nl
<< "}";
// Generate code for the elements of the component.
if (this->visit_scope (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_component_cs::"
"visit_component - "
"codegen for scope failed\n"),
-1);
}
be_visitor_context ctx (*this->ctx_);
// Smart Proxy classes.
if (be_global->gen_smart_proxies ())
{
ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS);
be_visitor_interface_smart_proxy_cs isp_visitor (&ctx);
if (node->accept (&isp_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_component_cs::"
"visit_component - "
"codegen for smart proxy classes failed\n"),
-1);
}
}
if (be_global->tc_support ())
{
ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE);
be_visitor_typecode_defn tc_visitor (&ctx);
if (node->accept (&tc_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_component_cs::"
"visit_component - "
"TypeCode definition failed\n"),
-1);
}
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?