📄 interfacedef_i.cpp
字号:
CORBA::InterfaceDef::FullInterfaceDescription *
TAO_InterfaceDef_i::describe_interface_i (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
CORBA::InterfaceDef::FullInterfaceDescription *fifd = 0;
ACE_NEW_RETURN (fifd,
CORBA::InterfaceDef::FullInterfaceDescription,
0);
CORBA::InterfaceDef::FullInterfaceDescription_var retval = fifd;
ACE_TString holder;
this->repo_->config ()->get_string_value (this->section_key_,
"name",
holder);
fifd->name = holder.fast_rep ();
this->repo_->config ()->get_string_value (this->section_key_,
"id",
holder);
fifd->id = holder.fast_rep ();
this->repo_->config ()->get_string_value (this->section_key_,
"container_id",
holder);
fifd->defined_in = holder.fast_rep ();
this->repo_->config ()->get_string_value (this->section_key_,
"version",
holder);
fifd->version = holder.fast_rep ();
CORBA::ULong i = 0;
CORBA::ULong j = 0;
ACE_Unbounded_Queue<ACE_Configuration_Section_Key> key_queue;
// Operations
this->inherited_operations (key_queue);
ACE_Configuration_Section_Key ops_key, op_key;
int status =
this->repo_->config ()->open_section (this->section_key_,
"ops",
0,
ops_key);
CORBA::ULong count = 0;
if (status == 0)
{
this->repo_->config ()->get_integer_value (ops_key,
"count",
count);
for (j = 0; j < count; ++j)
{
char *stringified = TAO_IFR_Service_Utils::int_to_string (j);
status =
this->repo_->config ()->open_section (ops_key,
stringified,
0,
op_key);
if (status == 0)
{
key_queue.enqueue_tail (op_key);
}
}
}
CORBA::ULong size = ACE_static_cast (CORBA::ULong, key_queue.size ());
fifd->operations.length (size);
for (i = 0; i < size; ++i)
{
ACE_Configuration_Section_Key key;
key_queue.dequeue_head (key);
TAO_OperationDef_i op (this->repo_);
op.section_key (key);
op.make_description (fifd->operations[i]
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
}
// Attributes
this->inherited_attributes (key_queue);
ACE_Configuration_Section_Key attrs_key;
status =
this->repo_->config ()->open_section (this->section_key_,
"attrs",
0,
attrs_key);
count = 0;
if (status == 0)
{
this->repo_->config ()->get_integer_value (attrs_key,
"count",
count);
for (j = 0; j < count; ++j)
{
ACE_Configuration_Section_Key attr_key;
char *stringified = TAO_IFR_Service_Utils::int_to_string (j);
status =
this->repo_->config ()->open_section (attrs_key,
stringified,
0,
attr_key);
if (status == 0)
{
key_queue.enqueue_tail (attr_key);
}
}
}
size = ACE_static_cast (CORBA::ULong, key_queue.size ());
fifd->attributes.length (size);
for (i = 0; i < size; ++i)
{
ACE_Configuration_Section_Key key;
key_queue.dequeue_head (key);
TAO_AttributeDef_i attr (this->repo_);
attr.section_key (key);
attr.make_description (fifd->attributes[i]
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
}
CORBA::InterfaceDefSeq_var bases =
this->base_interfaces_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
CORBA::ULong length = bases->length ();
CORBA::RepositoryIdSeq repo_ids (length);
repo_ids.length (length);
PortableServer::ObjectId_var oid;
char *base_path = 0;
ACE_Configuration_Section_Key base_key;
for (i = 0; i < length; ++i)
{
base_path = TAO_IFR_Service_Utils::reference_to_path (bases[i]);
this->repo_->config ()->expand_path (this->repo_->root_key (),
base_path,
base_key,
0);
TAO_InterfaceDef_i impl (this->repo_);
impl.section_key (base_key);
repo_ids[i] = impl.id_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
}
fifd->base_interfaces = repo_ids;
fifd->type = this->type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
return retval._retn ();
}
CORBA::AttributeDef_ptr
TAO_InterfaceDef_i::create_attribute (
const char *id,
const char *name,
const char *version,
CORBA::IDLType_ptr type,
CORBA::AttributeMode mode
ACE_ENV_ARG_DECL
)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_WRITE_GUARD_RETURN (CORBA::AttributeDef::_nil ());
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::AttributeDef::_nil ());
return this->create_attribute_i (id,
name,
version,
type,
mode
ACE_ENV_ARG_PARAMETER);
}
CORBA::AttributeDef_ptr
TAO_InterfaceDef_i::create_attribute_i (
const char *id,
const char *name,
const char *version,
CORBA::IDLType_ptr type,
CORBA::AttributeMode mode
ACE_ENV_ARG_DECL
)
ACE_THROW_SPEC ((CORBA::SystemException))
{
// This will throw an exception if a name clash is found.
// create_common() will check for all other errors.
this->check_inherited (name,
CORBA::dk_Attribute
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::AttributeDef::_nil ());
TAO_Container_i::tmp_name_holder_ = name;
ACE_Configuration_Section_Key new_key;
// Common to all IR objects created in CORBA::Container.
ACE_TString path =
TAO_IFR_Service_Utils::create_common (CORBA::dk_Interface,
CORBA::dk_Attribute,
this->section_key_,
new_key,
this->repo_,
id,
name,
&TAO_Container_i::same_as_tmp_name,
version,
"attrs"
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::AttributeDef::_nil ());
// Store the path to the attribute's type definition.
char *type_path = TAO_IFR_Service_Utils::reference_to_path (type);
this->repo_->config ()->set_string_value (new_key,
"type_path",
type_path);
// Store the attribute's mode.
this->repo_->config ()->set_integer_value (new_key,
"mode",
mode);
// Create the object reference.
CORBA::Object_var obj =
TAO_IFR_Service_Utils::create_objref (CORBA::dk_Attribute,
path.c_str (),
this->repo_
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::AttributeDef::_nil ());
CORBA::AttributeDef_var retval =
CORBA::AttributeDef::_narrow (obj.in ()
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::AttributeDef::_nil ());
return retval._retn ();
}
CORBA::OperationDef_ptr
TAO_InterfaceDef_i::create_operation (const char *id,
const char *name,
const char *version,
CORBA::IDLType_ptr result,
CORBA::OperationMode mode,
const CORBA::ParDescriptionSeq ¶ms,
const CORBA::ExceptionDefSeq &exceptions,
const CORBA::ContextIdSeq &contexts
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_WRITE_GUARD_RETURN (CORBA::OperationDef::_nil ());
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::OperationDef::_nil ());
return this->create_operation_i (id,
name,
version,
result,
mode,
params,
exceptions,
contexts
ACE_ENV_ARG_PARAMETER);
}
CORBA::OperationDef_ptr
TAO_InterfaceDef_i::create_operation_i (const char *id,
const char *name,
const char *version,
CORBA::IDLType_ptr result,
CORBA::OperationMode mode,
const CORBA::ParDescriptionSeq ¶ms,
const CORBA::ExceptionDefSeq &exceptions,
const CORBA::ContextIdSeq &contexts
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
// This will throw an exception if a name clash is found.
// create_common() will check for all other errors.
this->check_inherited (name,
CORBA::dk_Operation
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::OperationDef::_nil ());
TAO_Container_i::tmp_name_holder_ = name;
ACE_Configuration_Section_Key new_key;
// Common to all IR objects created in CORBA::Container.
ACE_TString path =
TAO_IFR_Service_Utils::create_common (CORBA::dk_Interface,
CORBA::dk_Operation,
this->section_key_,
new_key,
this->repo_,
id,
name,
&TAO_Container_i::same_as_tmp_name,
version,
"ops"
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::OperationDef::_nil ());
// Get the TypeCode for the return type.
ACE_TString result_path (TAO_IFR_Service_Utils::reference_to_path (result));
TAO_IDLType_i *result_impl =
TAO_IFR_Service_Utils::path_to_idltype (result_path,
this->repo_);
CORBA::TypeCode_var rettype =
result_impl->type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::OperationDef::_nil ());
CORBA::TCKind kind = rettype->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::OperationDef::_nil ());
// Oneway operations cannot have a non-void return type.
if (mode == CORBA::OP_ONEWAY && kind != CORBA::tk_void)
{
ACE_THROW_RETURN (CORBA::BAD_PARAM (31,
CORBA::COMPLETED_NO),
CORBA::OperationDef::_nil ());
}
this->repo_->config ()->set_string_value (new_key,
"result",
result_path);
// Store the operation mode.
this->repo_->config ()->set_integer_value (new_key,
"mode",
mode);
CORBA::ULong i = 0;
// Store the operation's parameter info.
CORBA::ULong length = params.length ();
if (length > 0)
{
ACE_Configuration_Section_Key params_key;
this->repo_->config ()->open_section (new_key,
"params",
1,
params_key);
this->repo_->config ()->set_integer_value (params_key,
"count",
length);
char *type_path = 0;
for (i = 0; i < length; ++i)
{
// Oneway operations cannot have INOUT or OUT parameters.
if (mode == CORBA::OP_ONEWAY && params[i].mode != CORBA::PARAM_IN)
{
ACE_THROW_RETURN (CORBA::BAD_PARAM (31,
CORBA::COMPLETED_NO),
CORBA::OperationDef::_nil ());
}
ACE_Configuration_Section_Key param_key;
char *stringified = TAO_IFR_Service_Utils::int_to_string (i);
this->repo_->config ()->open_section (params_key,
stringified,
1,
param_key);
this->repo_->config ()->set_string_value (param_key,
"name",
params[i].name.in ());
type_path =
TAO_IFR_Service_Utils::reference_to_path (
params[i].type_def.in ()
);
this->repo_->config ()->set_string_value (param_key,
"type_path",
type_path);
this->repo_->config ()->set_integer_value (param_key,
"mode",
params[i].mode);
}
}
// Store the operation's exception info.
length = exceptions.length ();
if (length > 0)
{
// Oneway operations cannot throw any user exceptions.
if (mode == CORBA::OP_ONEWAY)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -