📄 contained_i.cpp
字号:
TAO_IFR_Service_Utils::name_exists (&TAO_Contained_i::same_as_tmp_name,
root_key,
this->repo_,
CORBA::dk_Repository
ACE_ENV_ARG_PARAMETER);
return 0;
}
ACE_TString container_path;
this->repo_->config ()->get_string_value (this->repo_->repo_ids_key (),
container_id.c_str (),
container_path);
ACE_Configuration_Section_Key container_key;
this->repo_->config ()->expand_path (this->repo_->root_key (),
container_path,
container_key,
0);
ACE_Configuration_Section_Key defns_key;
this->repo_->config ()->open_section (container_key,
"defns",
0,
defns_key);
ACE_TString section_name;
int index = 0;
while (this->repo_->config ()->enumerate_sections (defns_key,
index++,
section_name)
== 0)
{
ACE_Configuration_Section_Key defn_key;
this->repo_->config ()->open_section (defns_key,
section_name.c_str (),
0,
defn_key);
ACE_TString defn_name;
this->repo_->config ()->get_string_value (defn_key,
"name",
defn_name);
if (defn_name == name)
{
return 1;
}
}
return 0;
}
void
TAO_Contained_i::contents_name_update (ACE_TString stem,
ACE_Configuration_Section_Key key)
{
ACE_Configuration_Section_Key defns_key;
if (this->repo_->config ()->open_section (key,
"defns",
0,
defns_key)
!= 0)
{
return;
}
int index = 0;
ACE_TString sub_section;
while (this->repo_->config ()->enumerate_sections (defns_key,
index++,
sub_section)
== 0)
{
ACE_Configuration_Section_Key defn_key;
this->repo_->config ()->open_section (defns_key,
sub_section.c_str (),
0,
defn_key);
ACE_TString name;
this->repo_->config ()->get_string_value (defn_key,
"name",
name);
ACE_TString absolute_name = stem + "::" + name;
this->repo_->config ()->set_string_value (defn_key,
"absolute_name",
absolute_name);
this->contents_name_update (absolute_name,
defn_key);
}
}
int
TAO_Contained_i::same_as_tmp_name (const char *name)
{
return ACE_OS::strcmp (TAO_Contained_i::tmp_name_holder_, name) == 0;
}
void
TAO_Contained_i::move_i (CORBA::Container_ptr new_container,
const char *new_name,
const char *new_version,
CORBA::Boolean cleanup
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
CORBA::Repository_var my_repo = this->repo_->repo_objref ();
CORBA::DefinitionKind container_dk =
TAO_IFR_Service_Utils::reference_to_def_kind (new_container,
this->repo_);
ACE_Configuration_Section_Key container_key;
TAO_Container_i *container_impl = 0;
TAO_Contained_i *contained_impl = 0;
// Check that we're not trying to move to a different repository,
// and set the container impl, used in each switch case below.
if (container_dk == CORBA::dk_Repository)
{
if (my_repo.in () != new_container)
{
ACE_THROW (CORBA::BAD_PARAM (4,
CORBA::COMPLETED_NO));
}
container_key = this->repo_->root_key ();
container_impl = this->repo_;
}
else
{
// The only case where a container is not also a contained is
// CORBA::Repository, which is covered by the other IF branch, so
// we're ok here.
ACE_TString container_path (
TAO_IFR_Service_Utils::reference_to_path (new_container)
);
contained_impl =
TAO_IFR_Service_Utils::path_to_contained (container_path,
this->repo_);
CORBA::Repository_var your_repo =
contained_impl->containing_repository (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
if (my_repo.in () != your_repo.in ())
{
ACE_THROW (CORBA::BAD_PARAM (4, CORBA::COMPLETED_NO));
}
this->repo_->config ()->expand_path (this->repo_->root_key (),
container_path,
container_key,
0);
container_impl =
TAO_IFR_Service_Utils::path_to_container (container_path,
this->repo_);
}
CORBA::DefinitionKind my_dk = this->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
CORBA::String_var id = this->id_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
// If an exception is thrown, this must be restored.
ACE_TString my_path;
this->repo_->config ()->get_string_value (this->repo_->repo_ids_key (),
id.in (),
my_path);
// Remove the repo id, because the create_* function call will add it
// again with a different path value.
this->repo_->config ()->remove_value (this->repo_->repo_ids_key (),
id.in ());
// Used for cleanup at the end of this function.
ACE_Configuration_Section_Key old_section_key = this->section_key_;
CORBA::String_var container_id =
contained_impl->id_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
ACE_TString new_id (container_id.in ());
new_id =
new_id.substr (0, new_id.rfind (':')) + "/" + new_name + ":" + new_version;
ACE_TRY
{
// Call the appropriate create function.
switch (my_dk)
{
case CORBA::dk_Enum:
{
TAO_EnumDef_i impl (this->repo_);
impl.section_key (this->section_key_);
CORBA::EnumMemberSeq_var members =
impl.members_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
if (container_dk == CORBA::dk_Struct
|| container_dk == CORBA::dk_Union
|| container_dk == CORBA::dk_Exception)
{
this->move_pre_process (new_container,
my_path.c_str (),
new_name
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
CORBA::EnumDef_var new_defn =
container_impl->create_enum_i (new_id.c_str (),
new_name,
new_version,
members.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
break;
}
case CORBA::dk_Alias:
{
TAO_AliasDef_i impl (this->repo_);
impl.section_key (this->section_key_);
CORBA::IDLType_var otype =
impl.original_type_def_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
container_impl->create_alias_i (new_id.c_str (),
new_name,
new_version,
otype.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
break;
}
case CORBA::dk_Native:
{
container_impl->create_native_i (new_id.c_str (),
new_name,
new_version
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
break;
}
case CORBA::dk_ValueBox:
{
TAO_ValueBoxDef_i impl (this->repo_);
impl.section_key (this->section_key_);
CORBA::IDLType_var otype =
impl.original_type_def_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
container_impl->create_value_box_i (new_id.c_str (),
new_name,
new_version,
otype.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
break;
}
case CORBA::dk_Struct:
{
TAO_StructDef_i impl (this->repo_);
impl.section_key (this->section_key_);
CORBA::StructMemberSeq_var members =
impl.members_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
if (container_dk == CORBA::dk_Struct
|| container_dk == CORBA::dk_Union
|| container_dk == CORBA::dk_Exception)
{
this->move_pre_process (new_container,
my_path.c_str (),
new_name
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
CORBA::StructDef_var new_defn =
container_impl->create_struct_i (new_id.c_str (),
new_name,
new_version,
members.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->move_contents (new_defn.in ()
ACE_ENV_ARG_PARAMETER);
break;
}
case CORBA::dk_Union:
{
TAO_UnionDef_i impl (this->repo_);
impl.section_key (this->section_key_);
CORBA::IDLType_var disc_type =
impl.discriminator_type_def_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::UnionMemberSeq_var members =
impl.members_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
if (container_dk == CORBA::dk_Struct
|| container_dk == CORBA::dk_Union
|| container_dk == CORBA::dk_Exception)
{
this->move_pre_process (new_container,
my_path.c_str (),
new_name
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
CORBA::UnionDef_var new_defn =
container_impl->create_union_i (new_id.c_str (),
new_name,
new_version,
disc_type.in (),
members.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->move_contents (new_defn.in ()
ACE_ENV_ARG_PARAMETER);
break;
}
case CORBA::dk_Module:
{
CORBA::ModuleDef_var new_defn =
container_impl->create_module_i (new_id.c_str (),
new_name,
new_version
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->move_contents (new_defn.in ()
ACE_ENV_ARG_PARAMETER);
break;
}
case CORBA::dk_Exception:
{
TAO_ExceptionDef_i impl (this->repo_);
impl.section_key (this->section_key_);
CORBA::StructMemberSeq_var members =
impl.members_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::ExceptionDef_var new_defn =
container_impl->create_exception_i (new_id.c_str (),
new_name,
new_version,
members.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->move_contents (new_defn.in ()
ACE_ENV_ARG_PARAMETER);
break;
}
case CORBA::dk_Interface:
{
TAO_InterfaceDef_i impl (this->repo_);
impl.section_key (this->section_key_);
CORBA::InterfaceDefSeq_var bases =
impl.base_interfaces_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::InterfaceDef_var new_defn =
container_impl->create_interface_i (new_id.c_str (),
new_name,
new_version,
bases.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->move_contents (new_defn.in ()
ACE_ENV_ARG_PARAMETER);
break;
}
case CORBA::dk_Constant:
{
TAO_ConstantDef_i impl (this->repo_);
impl.section_key (this->section_key_);
CORBA::IDLType_var type_def =
impl.type_def_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -