📄 container_i.cpp
字号:
/* -*- C++ -*- */
// Container_i.cpp,v 1.11 2003/08/05 04:17:38 parsons Exp
#include "Repository_i.h"
#include "InterfaceDef_i.h"
#include "ValueDef_i.h"
#include "ExtValueDef_i.h"
#include "IFR_Service_Utils.h"
#include "IFR_Service_Utils_T.h"
#include "tao/IFR_Client/IFR_ComponentsC.h"
#include "ace/Auto_Ptr.h"
ACE_RCSID (IFRService,
Container_i,
"Container_i.cpp,v 1.11 2003/08/05 04:17:38 parsons Exp")
const char *TAO_Container_i::tmp_name_holder_ = 0;
TAO_Container_i::TAO_Container_i (
TAO_Repository_i *repo
)
: TAO_IRObject_i (repo)
{
}
TAO_Container_i::~TAO_Container_i (void)
{
}
void
TAO_Container_i::destroy (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_WRITE_GUARD;
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
this->destroy_i (ACE_ENV_SINGLE_ARG_PARAMETER);
}
void
TAO_Container_i::destroy_i (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
int index = 0;
int status;
ACE_TString section_name;
// Destroy and/or remove references.
ACE_Configuration_Section_Key refs_key;
status =
this->repo_->config ()->open_section (this->section_key_,
"refs",
0,
refs_key);
// This section may not have been created.
if (status == 0)
{
while (this->repo_->config ()->enumerate_sections (refs_key,
index++,
section_name)
== 0)
{
ACE_Configuration_Section_Key member_key;
this->repo_->config ()->open_section (refs_key,
section_name.c_str (),
0,
member_key);
ACE_TString path;
this->repo_->config ()->get_string_value (member_key,
"path",
path);
ACE_Configuration_Section_Key entry_key;
status =
this->repo_->config ()->expand_path (this->repo_->root_key (),
path,
entry_key,
0);
// This entry may already have been destroyed.
if (status == 0)
{
TAO_IDLType_i *impl =
TAO_IFR_Service_Utils::path_to_idltype (path,
this->repo_);
CORBA::DefinitionKind def_kind =
impl->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
switch (def_kind)
{
// These anonymous types were defined in IDL inside this
// struct and have no 'contained-in' info of their own,
// so they must be destroyed here.
case CORBA::dk_String:
case CORBA::dk_Wstring:
case CORBA::dk_Fixed:
case CORBA::dk_Array:
case CORBA::dk_Sequence:
impl->destroy_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
break;
default:
// No other types can be defined in this section of the struct.
break;
}
}
}
this->repo_->config ()->remove_section (this->section_key_,
"refs",
1);
}
ACE_TString id;
this->repo_->config ()->get_string_value (this->section_key_,
"id",
id);
ACE_TString my_path;
this->repo_->config ()->get_string_value (this->repo_->repo_ids_key (),
id.c_str (),
my_path);
// Destroy definitions.
ACE_Configuration_Section_Key defns_key;
status =
this->repo_->config ()->open_section (this->section_key_,
"defns",
0,
defns_key);
// This section may not have been created.
if (status == 0)
{
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);
u_int kind = 0;
this->repo_->config ()->get_integer_value (defn_key,
"def_kind",
kind);
CORBA::DefinitionKind def_kind =
ACE_static_cast (CORBA::DefinitionKind, kind);
TAO_Contained_i *impl = this->repo_->select_contained (def_kind);
impl->section_key (defn_key);
impl->destroy_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
}
this->repo_->config ()->remove_section (this->section_key_,
"defns",
1);
}
}
CORBA::Contained_ptr
TAO_Container_i::lookup (const char *search_name
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_READ_GUARD_RETURN (0);
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Contained::_nil ());
return this->lookup_i (search_name
ACE_ENV_ARG_PARAMETER);
}
CORBA::Contained_ptr
TAO_Container_i::lookup_i (const char *search_name
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_Configuration_Section_Key iter_key;
ACE_Configuration_Section_Key work_key;
ACE_TString work_string;
ACE_TString section_name;
int status = 0;
int index = 0;
int pos = 0;
int so_far_so_good = 0;
u_int kind = 0;
CORBA::DefinitionKind def_kind = CORBA::dk_none;
if (ACE_OS::strncmp (search_name, "::", 2) == 0)
{
// We were given an absolute scoped name.
work_string = search_name + 2;
iter_key = this->repo_->root_key ();
}
else
{
// We were given a relative scoped name.
work_string = search_name;
iter_key = this->section_key_;
}
while (1)
{
pos = work_string.find ("::");
so_far_so_good = 0;
ACE_Configuration_Section_Key defns_key;
status =
this->repo_->config ()->open_section (iter_key,
"defns",
0,
defns_key);
if (status == 0)
{
index = 0;
while (this->repo_->config ()->enumerate_sections (defns_key,
index++,
section_name)
== 0)
{
this->repo_->config ()->open_section (defns_key,
section_name.c_str (),
0,
work_key);
ACE_TString defn_name;
this->repo_->config ()->get_string_value (work_key,
"name",
defn_name);
if (defn_name == work_string.substr (0, pos))
{
iter_key = work_key;
so_far_so_good = 1;
break;
}
}
}
if (so_far_so_good)
{
if (pos != ACE_TString::npos)
{
work_string = work_string.substr (pos + 2);
continue;
}
else
{
break;
}
}
else
{
// Check for attributes and operations, but only if we
// are on the last segment of the scoped name.
if (pos == ACE_TString::npos)
{
this->repo_->config ()->get_integer_value (iter_key,
"def_kind",
kind);
def_kind = ACE_static_cast (CORBA::DefinitionKind, kind);
if (def_kind == CORBA::dk_Interface
|| def_kind == CORBA::dk_Value)
{
ACE_Configuration_Section_Key attrs_key;
status =
this->repo_->config ()->open_section (iter_key,
"attrs",
0,
attrs_key);
if (status == 0)
{
index = 0;
while (this->repo_->config ()->enumerate_sections (
attrs_key,
index++,
section_name
)
== 0)
{
this->repo_->config ()->open_section (
attrs_key,
section_name.c_str (),
0,
work_key
);
ACE_TString attr_name;
this->repo_->config ()->get_string_value (
work_key,
"name",
attr_name
);
// If we're here, working name has only one segment.
if (attr_name == work_string)
{
so_far_so_good = 1;
break;
}
}
}
if (so_far_so_good)
{
break;
}
else
{
ACE_Configuration_Section_Key ops_key;
status =
this->repo_->config ()->open_section (iter_key,
"ops",
0,
ops_key);
if (status == 0)
{
index = 0;
while (this->repo_->config ()->enumerate_sections (
ops_key,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -