📄 ifr_service_utils.cpp
字号:
path += '\\';
path += section_name;
// Store our path under our global repo id for fast lookup.
config->set_string_value (repo->repo_ids_key (),
id,
path);
return path;
}
void
TAO_IFR_Service_Utils::set_exceptions (
ACE_Configuration *config,
ACE_Configuration_Section_Key &key,
const char *sub_section,
const CORBA::ExceptionDefSeq &exceptions
)
{
CORBA::ULong length = exceptions.length ();
if (length == 0)
{
return;
}
// Create new subsection because we are either creating a new entry
// or are calling from a mutator which has already removed the old one.
ACE_Configuration_Section_Key excepts_key;
config->open_section (key,
sub_section,
1,
excepts_key);
config->set_integer_value (excepts_key,
"count",
length);
char *type_path = 0;
for (CORBA::ULong i = 0; i < length; ++i)
{
type_path =
TAO_IFR_Service_Utils::reference_to_path (exceptions[i].in ());
char *stringified = TAO_IFR_Service_Utils::int_to_string (i);
config->set_string_value (excepts_key,
stringified,
type_path);
}
}
CORBA::TypeCode_ptr
TAO_IFR_Service_Utils::gen_valuetype_tc_r (
ACE_Configuration_Section_Key &key,
TAO_Repository_i *repo
ACE_ENV_ARG_DECL
)
{
ACE_TString name;
repo->config ()->get_string_value (key,
"name",
name);
ACE_TString id;
repo->config ()->get_string_value (key,
"id",
id);
CORBA::ValueModifier tm = CORBA::VM_NONE;
CORBA::ULong is_it = 0;
repo->config ()->get_integer_value (key,
"is_abstract",
is_it);
if (is_it)
{
tm = CORBA::VM_ABSTRACT;
}
else
{
repo->config ()->get_integer_value (key,
"is_custom",
is_it);
if (is_it)
{
tm = CORBA::VM_CUSTOM;
}
else
{
repo->config ()->get_integer_value (key,
"is_truncatable",
is_it);
if (is_it)
{
tm = CORBA::VM_TRUNCATABLE;
}
}
}
ACE_TString base_id;
int status =
repo->config ()->get_string_value (key,
"base_value",
base_id);
CORBA::TypeCode_var base_tc = CORBA::TypeCode::_nil ();
if (status == 0)
{
ACE_TString base_path;
repo->config ()->get_string_value (repo->repo_ids_key (),
base_id.fast_rep (),
base_path);
ACE_Configuration_Section_Key base_key;
repo->config ()->expand_path (repo->root_key (),
base_path,
base_key,
0);
base_tc =
TAO_IFR_Service_Utils::gen_valuetype_tc_r (base_key,
repo
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
}
CORBA::ValueMemberSeq vm_seq;
vm_seq.length (0);
// this->fill_vm_seq (vm_seq
// ACE_ENV_ARG_PARAMETER);
// ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());
return
repo->tc_factory ()->create_value_tc (id.c_str (),
name.c_str (),
tm,
base_tc.in (),
vm_seq
ACE_ENV_ARG_PARAMETER);
}
void
TAO_IFR_Service_Utils::fill_valuemember_seq (
CORBA::ValueMemberSeq &vm_seq,
ACE_Configuration_Section_Key &key,
TAO_Repository_i *repo
ACE_ENV_ARG_DECL
)
{
ACE_Configuration_Section_Key members_key;
int status =
repo->config ()->open_section (key,
"members",
0,
members_key);
if (status != 0)
{
vm_seq.length (0);
return;
}
CORBA::ULong count = 0;
repo->config ()->get_integer_value (members_key,
"count",
count);
vm_seq.length (count);
char *stringified = 0;
ACE_Configuration_Section_Key member_key, type_key;
ACE_TString holder;
CORBA::ULong access = 0;
for (CORBA::ULong i = 0; i < count; ++i)
{
stringified = TAO_IFR_Service_Utils::int_to_string (i);
repo->config ()->open_section (members_key,
stringified,
0,
member_key);
repo->config ()->get_string_value (member_key,
"name",
holder);
vm_seq[i].name = holder.fast_rep ();
repo->config ()->get_string_value (member_key,
"id",
holder);
vm_seq[i].id = holder.fast_rep ();
repo->config ()->get_string_value (key,
"id",
holder);
vm_seq[i].defined_in = holder.fast_rep ();
repo->config ()->get_string_value (member_key,
"version",
holder);
vm_seq[i].version = holder.fast_rep ();
repo->config ()->get_string_value (repo->repo_ids_key (),
vm_seq[i].id.in (),
holder);
TAO_IDLType_i *impl =
TAO_IFR_Service_Utils::path_to_idltype (holder,
repo);
vm_seq[i].type = impl->type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
repo->config ()->get_integer_value (member_key,
"access",
access);
vm_seq[i].access = ACE_static_cast (CORBA::Visibility,
access);
}
}
char *
TAO_IFR_Service_Utils::reference_to_path (CORBA::IRObject_ptr obj)
{
PortableServer::ObjectId object_id;
TAO::ObjectKey object_key =
obj->_stubobj ()->profile_in_use ()->object_key ();
int status = TAO_POA::parse_ir_object_key (object_key,
object_id);
if (status != 0)
{
ACE_DEBUG ((LM_DEBUG,
"reference_to_path - parse_ir_object_key failed\n"));
return 0;
}
return TAO_IFR_Service_Utils::oid_to_string (object_id);
}
CORBA::DefinitionKind
TAO_IFR_Service_Utils::path_to_def_kind (ACE_TString &path,
TAO_Repository_i *repo)
{
int status =
repo->config ()->expand_path (repo->root_key (),
path,
TAO_IFR_Service_Utils::tmp_key_,
0);
if (status != 0)
{
ACE_DEBUG ((LM_DEBUG,
"path_to_def_kind - bad path: '%s'\n",
path.c_str ()));
return CORBA::dk_none;
}
u_int kind = 0;
repo->config ()->get_integer_value (TAO_IFR_Service_Utils::tmp_key_,
"def_kind",
kind);
return ACE_static_cast (CORBA::DefinitionKind,
kind);
}
CORBA::DefinitionKind
TAO_IFR_Service_Utils::reference_to_def_kind (CORBA::IRObject_ptr obj,
TAO_Repository_i *repo)
{
ACE_TString path (TAO_IFR_Service_Utils::reference_to_path (obj));
return TAO_IFR_Service_Utils::path_to_def_kind (path, repo);
}
TAO_IDLType_i *
TAO_IFR_Service_Utils::path_to_idltype (ACE_TString &path,
TAO_Repository_i *repo)
{
CORBA::DefinitionKind def_kind =
TAO_IFR_Service_Utils::path_to_def_kind (path, repo);
TAO_IDLType_i *retval = repo->select_idltype (def_kind);
if (retval == 0)
{
ACE_DEBUG ((LM_DEBUG,
"path_to_idltype - not an IDLType: '%s'\n",
path.c_str ()));
return 0;
}
retval->section_key (TAO_IFR_Service_Utils::tmp_key_);
return retval;
}
TAO_Contained_i *
TAO_IFR_Service_Utils::path_to_contained (ACE_TString &path,
TAO_Repository_i *repo)
{
CORBA::DefinitionKind def_kind =
TAO_IFR_Service_Utils::path_to_def_kind (path, repo);
TAO_Contained_i *retval = repo->select_contained (def_kind);
if (retval == 0)
{
ACE_DEBUG ((LM_DEBUG,
"path_to_contained - not a contained type: '%s'\n",
path.c_str ()));
return 0;
}
retval->section_key (TAO_IFR_Service_Utils::tmp_key_);
return retval;
}
TAO_Container_i *
TAO_IFR_Service_Utils::path_to_container (ACE_TString &path,
TAO_Repository_i *repo)
{
CORBA::DefinitionKind def_kind =
TAO_IFR_Service_Utils::path_to_def_kind (path, repo);
TAO_Container_i *retval = repo->select_container (def_kind);
if (retval != 0)
{
retval->section_key (TAO_IFR_Service_Utils::tmp_key_);
}
return retval;
}
CORBA::Object_ptr
TAO_IFR_Service_Utils::path_to_ir_object (ACE_TString &path,
TAO_Repository_i *repo
ACE_ENV_ARG_DECL)
{
CORBA::DefinitionKind def_kind =
TAO_IFR_Service_Utils::path_to_def_kind (path, repo);
return TAO_IFR_Service_Utils::create_objref (def_kind,
path.c_str (),
repo
ACE_ENV_ARG_PARAMETER);
}
CORBA::Object_ptr
TAO_IFR_Service_Utils::create_objref (CORBA::DefinitionKind def_kind,
const char *obj_id,
TAO_Repository_i *repo
ACE_ENV_ARG_DECL)
{
ACE_TString repo_id ("IDL:omg.org/");
switch (def_kind)
{
case CORBA::dk_Attribute:
repo_id += "CORBA/ExtAttributeDef:";
break;
case CORBA::dk_Constant:
repo_id += "CORBA/ConstantDef:";
break;
case CORBA::dk_Exception:
repo_id += "CORBA/ExceptionDef:";
break;
case CORBA::dk_Interface:
repo_id += "CORBA/ExtInterfaceDef:";
break;
case CORBA::dk_AbstractInterface:
repo_id += "CORBA/ExtAbstractInterfaceDef:";
break;
case CORBA::dk_LocalInterface:
repo_id += "CORBA/ExtLocalInterfaceDef:";
break;
case CORBA::dk_Module:
repo_id += "CORBA/ComponentIR/ModuleDef:";
break;
case CORBA::dk_Operation:
repo_id += "CORBA/OperationDef:";
break;
case CORBA::dk_Typedef:
repo_id += "CORBA/TypedefDef:";
break;
case CORBA::dk_Alias:
repo_id += "CORBA/AliasDef:";
break;
case CORBA::dk_Struct:
repo_id += "CORBA/StructDef:";
break;
case CORBA::dk_Union:
repo_id += "CORBA/UnionDef:";
break;
case CORBA::dk_Enum:
repo_id += "CORBA/EnumDef:";
break;
case CORBA::dk_Primitive:
repo_id += "CORBA/PrimitiveDef:";
break;
case CORBA::dk_String:
repo_id += "CORBA/StringDef:";
break;
case CORBA::dk_Sequence:
repo_id += "CORBA/SequenceDef:";
break;
case CORBA::dk_Array:
repo_id += "CORBA/ArrayDef:";
break;
case CORBA::dk_Wstring:
repo_id += "CORBA/WstringDef:";
break;
case CORBA::dk_Fixed:
repo_id += "CORBA/FixedDef:";
break;
case CORBA::dk_Value:
repo_id += "CORBA/ExtValueDef:";
break;
case CORBA::dk_ValueBox:
repo_id += "CORBA/ValueBoxDef:";
break;
case CORBA::dk_ValueMember:
repo_id += "CORBA/ValueMemberDef:";
break;
case CORBA::dk_Native:
repo_id += "CORBA/NativeDef:";
break;
case CORBA::dk_Component:
repo_id += "CORBA/ComponentIR/ComponentDef:";
break;
case CORBA::dk_Home:
repo_id += "CORBA/ComponentIR/HomeDef:";
break;
case CORBA::dk_Factory:
repo_id += "CORBA/ComponentIR/FactoryDef:";
break;
case CORBA::dk_Finder:
repo_id += "CORBA/ComponentIR/FinderDef:";
break;
case CORBA::dk_Event:
repo_id += "CORBA/ComponentIR/EventDef:";
break;
case CORBA::dk_Emits:
repo_id += "CORBA/ComponentIR/EmitsDef:";
break;
case CORBA::dk_Publishes:
repo_id += "CORBA/ComponentIR/PublishesDef:";
break;
case CORBA::dk_Consumes:
repo_id += "CORBA/ComponentIR/ConsumesDef:";
break;
case CORBA::dk_Provides:
repo_id += "CORBA/ComponentIR/ProvidesDef:";
break;
case CORBA::dk_Uses:
repo_id += "CORBA/ComponentIR/UsesDef:";
break;
default:
ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (),
CORBA::Object::_nil ());
}
repo_id += "1.0";
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId (obj_id);
PortableServer::POA_ptr poa = repo->select_poa (def_kind);
return poa->create_reference_with_id (oid.in (),
repo_id.c_str ()
ACE_ENV_ARG_PARAMETER);
}
char *
TAO_IFR_Service_Utils::oid_to_string (PortableServer::ObjectId &oid)
{
static char oid_string[2 * 1024];
CORBA::ULong length = oid.length ();
// Copy the data.
ACE_OS::memcpy (oid_string,
oid.get_buffer (),
length);
// Null terminate the string.
oid_string[length] = '\0';
return oid_string;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -