📄 contained_i.cpp
字号:
/* -*- C++ -*- */
// Contained_i.cpp,v 1.3 2003/03/12 16:17:45 parsons Exp
#include "concrete_classes.h"
#include "Repository_i.h"
#include "IFR_Service_Utils.h"
#include "ace/Auto_Ptr.h"
ACE_RCSID (IFRService,
Contained_i,
"Contained_i.cpp,v 1.3 2003/03/12 16:17:45 parsons Exp")
const char *TAO_Contained_i::tmp_name_holder_ = 0;
TAO_Contained_i::TAO_Contained_i (
TAO_Repository_i *repo
)
: TAO_IRObject_i (repo)
{
}
TAO_Contained_i::~TAO_Contained_i (void)
{
}
void
TAO_Contained_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_Contained_i::destroy_i (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_TString id;
this->repo_->config ()->get_string_value (this->section_key_,
"id",
id);
// We'll get the last segment of this below.
ACE_TString path;
this->repo_->config ()->get_string_value (this->repo_->repo_ids_key (),
id.c_str (),
path);
// Remove the repo id.
this->repo_->config ()->remove_value (this->repo_->repo_ids_key (),
id.c_str ());
// Remove the database entry.
ACE_TString container_id;
ACE_Configuration_Section_Key parent_key;
this->repo_->config ()->get_string_value (this->section_key_,
"container_id",
container_id);
if (container_id == "")
{
parent_key = this->repo_->root_key ();
}
else
{
ACE_TString parent_path;
this->repo_->config ()->get_string_value (this->repo_->repo_ids_key (),
container_id.c_str (),
parent_path);
this->repo_->config ()->expand_path (this->repo_->root_key (),
parent_path,
parent_key,
0);
}
ACE_Configuration_Section_Key defns_key;
this->repo_->config ()->open_section (parent_key,
"defns",
0,
defns_key);
ACE_TString last_seg = path.substr (path.rfind ('\\') + 1);
this->repo_->config ()->remove_section (defns_key,
last_seg.c_str (),
1);
}
char *
TAO_Contained_i::id (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_READ_GUARD_RETURN (0);
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
return this->id_i (ACE_ENV_SINGLE_ARG_PARAMETER);
}
char *
TAO_Contained_i::id_i (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_TString retval;
this->repo_->config ()->get_string_value (this->section_key_,
"id",
retval);
return CORBA::string_dup (retval.c_str ());
}
void
TAO_Contained_i::id (const char *id
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_WRITE_GUARD;
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
this->id_i (id
ACE_ENV_ARG_PARAMETER);
}
void
TAO_Contained_i::id_i (const char *id
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_TString tmp;
if (this->repo_->config ()->get_string_value (
this->repo_->repo_ids_key (),
id,
tmp
)
== 0)
{
// Repository id already exists.
ACE_THROW (CORBA::BAD_PARAM (2, CORBA::COMPLETED_NO));
}
// Get the old id.
ACE_TString old_id;
this->repo_->config ()->get_string_value (this->section_key_,
"id",
old_id);
ACE_TString path;
// Fetch our path.
this->repo_->config ()->get_string_value (this->repo_->repo_ids_key (),
old_id.c_str (),
path);
// Remove the old id.
this->repo_->config ()->remove_value (this->repo_->repo_ids_key (),
old_id.c_str ());
// Save our path under the new id.
this->repo_->config ()->set_string_value (this->repo_->repo_ids_key (),
id,
path);
// Store the new id locally as well.
this->repo_->config ()->set_string_value (this->section_key_,
"id",
id);
}
char *
TAO_Contained_i::name (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_READ_GUARD_RETURN (0);
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
return this->name_i (ACE_ENV_SINGLE_ARG_PARAMETER);
}
char *
TAO_Contained_i::name_i (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_TString retval;
this->repo_->config ()->get_string_value (this->section_key_,
"name",
retval);
return CORBA::string_dup (retval.c_str ());
}
char *
TAO_Contained_i::version (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_READ_GUARD_RETURN (0);
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
return this->version_i (ACE_ENV_SINGLE_ARG_PARAMETER);
}
char *
TAO_Contained_i::version_i (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_TString retval;
this->repo_->config ()->get_string_value (this->section_key_,
"version",
retval);
return CORBA::string_dup (retval.c_str ());
}
void
TAO_Contained_i::name (const char *name
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_WRITE_GUARD;
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
this->name_i (name
ACE_ENV_ARG_PARAMETER);
}
void
TAO_Contained_i::name_i (const char *name
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
// Check if name already exists in this container.
CORBA::Boolean exists = this->name_exists (name
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
if (exists)
{
ACE_THROW (CORBA::BAD_PARAM (3, CORBA::COMPLETED_NO));
}
// Reset the local name.
this->repo_->config ()->set_string_value (this->section_key_,
"name",
name);
// Update the absolute name.
ACE_TString absolute_name;
this->repo_->config ()->get_string_value (this->section_key_,
"absolute_name",
absolute_name);
absolute_name = absolute_name.substr (0, absolute_name.rfind (':') + 1);
absolute_name += name;
this->repo_->config ()->set_string_value (this->section_key_,
"absolute_name",
absolute_name);
this->contents_name_update (absolute_name,
this->section_key_);
}
void
TAO_Contained_i::version (const char *version
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_WRITE_GUARD;
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
this->version_i (version
ACE_ENV_ARG_PARAMETER);
}
void
TAO_Contained_i::version_i (const char *version
ACE_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
this->repo_->config ()->set_string_value (this->section_key_,
"version",
version);
}
CORBA::Container_ptr
TAO_Contained_i::defined_in (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_READ_GUARD_RETURN (CORBA::Container::_nil ());
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Container::_nil ());
return this->defined_in_i (ACE_ENV_SINGLE_ARG_PARAMETER);
}
CORBA::Container_ptr
TAO_Contained_i::defined_in_i (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_TString container_id;
this->repo_->config ()->get_string_value (this->section_key_,
"container_id",
container_id);
if (container_id == "")
{
// The repository itself is our container.
return this->repo_->repo_objref ();
}
ACE_TString container_path;
this->repo_->config ()->get_string_value (this->repo_->repo_ids_key (),
container_id.c_str (),
container_path);
CORBA::Object_var obj =
TAO_IFR_Service_Utils::path_to_ir_object (container_path,
this->repo_
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Container::_nil ());
CORBA::Container_var retval = CORBA::Container::_narrow (obj.in ()
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Container::_nil ());
return retval._retn ();
}
char *
TAO_Contained_i::absolute_name (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_READ_GUARD_RETURN (0);
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
return this->absolute_name_i (ACE_ENV_SINGLE_ARG_PARAMETER);
}
char *
TAO_Contained_i::absolute_name_i (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_TString absolute_name;
this->repo_->config ()->get_string_value (this->section_key_,
"absolute_name",
absolute_name);
return CORBA::string_dup (absolute_name.c_str ());
}
CORBA::Repository_ptr
TAO_Contained_i::containing_repository (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
return this->repo_->repo_objref ();
}
void
TAO_Contained_i::move (CORBA::Container_ptr new_container,
const char *new_name,
const char *new_version
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_IFR_WRITE_GUARD;
this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
this->move_i (new_container,
new_name,
new_version,
1
ACE_ENV_ARG_PARAMETER);
}
CORBA::Boolean
TAO_Contained_i::name_exists (const char *name
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_TString container_id;
this->repo_->config ()->get_string_value (this->section_key_,
"container_id",
container_id);
if (container_id == "")
{
TAO_Contained_i::tmp_name_holder_ = name;
ACE_Configuration_Section_Key root_key = this->repo_->root_key ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -