interceptors_ss.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 1,050 行 · 第 1/3 页
CPP
1,050 行
//
// interceptors_ss.cpp,v 1.27 2003/05/09 05:30:24 parsons Exp
//
// ============================================================================
//
// = LIBRARY
// TAO IDL
//
// = FILENAME
// operation_interceptors_ss.cpp
//
// = DESCRIPTION
// Visitor generating code for Operation node in the server stubs.
//
// = AUTHOR
// Kirthika Parameswaran <kirthika@cs.wustl.edu>
// Ossama Othman <ossama@uci.edu>
//
// ============================================================================
ACE_RCSID (be_visitor_operation,
operation_interceptors_ss,
"interceptors_ss.cpp,v 1.27 2003/05/09 05:30:24 parsons Exp")
// ******************************************************
// primary visitor for "operation" in server header
// ******************************************************
be_visitor_operation_interceptors_ss::be_visitor_operation_interceptors_ss (
be_visitor_context *ctx
)
: be_visitor_operation (ctx)
{
}
be_visitor_operation_interceptors_ss::~be_visitor_operation_interceptors_ss (
void
)
{
}
int
be_visitor_operation_interceptors_ss::visit_operation (be_operation *node)
{
TAO_OutStream *os = this->ctx_->stream ();
if (this->generate_class_declaration (os, node) == -1)
{
return -1;
}
if (this->generate_class_definition (os, node) == -1)
{
return -1;
}
return 0;
}
int
be_visitor_operation_interceptors_ss::generate_class_declaration (
TAO_OutStream *os,
be_operation *node
)
{
be_type *bt = 0;
be_visitor_context ctx (*this->ctx_);
// save the node.
this->ctx_->node (node);
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
// Generate the ServerRequestInfo object per operation to
// be used by the interecptors.
*os << be_nl << be_nl
<< "class TAO_ServerRequestInfo_"<< node->flat_name ();
// We need the interface node in which this operation was defined. However,
// if this operation node was an attribute node in disguise, we get this
// information from the context and add a "_get"/"_set" to the flat
// name to get around the problem of overloaded methods which are
// generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
if (!this->void_return_type (bt))
{
*os << "_get";
}
else
{
*os << "_set";
}
}
*os << " : public TAO_ServerRequestInfo" << be_nl
<< "{" << be_nl
<< "public:" << be_idt_nl;
*os << "TAO_ServerRequestInfo_"<< node->flat_name ();
// We need the interface node in which this operation was defined. However,
// if this operation node was an attribute node in disguise, we get this
// information from the context and add a "_get"/"_set" to the flat
// name to get around the problem of overloaded methods which are
// generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
if (!this->void_return_type (bt))
{
*os << "_get";
}
else
{
*os << "_set";
}
}
*os << " (" << be_idt << be_idt_nl
<< "TAO_ServerRequest &_tao_server_request," << be_nl;
be_interface *intf;
intf = this->ctx_->attribute ()
? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ())
: be_interface::narrow_from_scope (node->defined_in ());
if (!intf)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_sh::"
"visit_operation - "
"bad interface scope\n"),
-1);
}
// Pass in the pointer to the Servant_Upcall.
*os << "TAO_Object_Adapter::Servant_Upcall *tao_servant_upcall," << be_nl;
// Get the right object implementation.
*os << intf->full_skel_name () << " *tao_impl";
// Generate the argument list with the appropriate mapping. For these
// we grab a visitor that generates the parameter listing.
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SH);
be_visitor_operation_interceptors_arglist oia_visitor (&ctx);
if (node->accept (&oia_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_interceptors_sh::"
"visit_operation - "
"codegen for argument list failed\n"),
-1);
}
*os << be_uidt_nl << ");" << be_uidt_nl << be_nl;
// Here I still need to generate the other methods + private args.
*os << "virtual Dynamic::ParameterList * arguments ("
<< be_idt << be_idt_nl
<< "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl
<< ")" << be_nl
<< "ACE_THROW_SPEC ((CORBA::SystemException));"
<< be_uidt_nl << be_nl;
*os << "virtual Dynamic::ExceptionList * exceptions ("
<< be_idt << be_idt_nl
<< "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl
<< ")" << be_nl
<< "ACE_THROW_SPEC ((CORBA::SystemException));"
<< be_uidt_nl << be_nl;
*os << "virtual CORBA::Any * result ("
<< be_idt << be_idt_nl
<< "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl
<< ")" << be_nl
<< "ACE_THROW_SPEC ((CORBA::SystemException));"
<< be_uidt_nl << be_nl;
*os << "virtual char * target_most_derived_interface ("
<< be_idt << be_idt_nl
<< "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl
<< ")" << be_nl
<< "ACE_THROW_SPEC ((CORBA::SystemException));"
<< be_uidt_nl << be_nl;
*os << "virtual CORBA::Boolean target_is_a (" << be_idt << be_idt_nl
<< "const char * id" << be_nl
<< "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl
<< ")" << be_nl
<< "ACE_THROW_SPEC ((CORBA::SystemException));"
<< be_uidt_nl;
// Store the result for later use.
// generate the return type.
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void since we cant have a private member to be of void type.
if (!this->void_return_type (bt))
{
*os << be_nl << "void result (";
ctx = *this->ctx_;
be_visitor_operation_rettype or_visitor (&ctx);
if (bt->accept (&or_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_cs::"
"visit_operation - "
"codegen for retval pre invoke failed\n"),
-1);
}
*os << " result);\n";
}
*os << be_uidt_nl << "private:" << be_idt_nl;
*os << "TAO_ServerRequestInfo_" << node->flat_name ();
// We need the interface node in which this operation was defined. However,
// if this operation node was an attribute node in disguise, we get this
// information from the context and add a "_get"/"_set" to the flat
// name to get around the problem of overloaded methods which are
// generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
if (!this->void_return_type (bt))
{
*os << "_get";
}
else
{
*os << "_set";
}
}
*os << " (" << be_idt << be_idt_nl
<< "const "<< "TAO_ServerRequestInfo_"<< node->flat_name ();
// We need the interface node in which this operation was defined. However,
// if this operation node was an attribute node in disguise, we get this
// information from the context and add a "_get"/"_set" to the flat
// name to get around the problem of overloaded methods which are
// generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
if (!this->void_return_type (bt))
{
*os << "_get";
}
else
{
*os << "_set";
}
}
*os << " &" << be_uidt_nl
<< ");" << be_uidt_nl << be_nl
<< "void operator= (" << be_idt << be_idt_nl
<< "const "
<< "TAO_ServerRequestInfo_"<< node->flat_name ();
// We need the interface node in which this operation was defined. However,
// if this operation node was an attribute node in disguise, we get this
// information from the context and add a "_get"/"_set" to the flat
// name to get around the problem of overloaded methods which are
// generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?