⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 repository_i.cpp

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// -*- C++ -*-
//
// Repository_i.cpp,v 1.7 2003/08/18 06:42:14 ossama Exp

#include "concrete_classes.h"
#include "Repository_i.h"
#include "IDLType_i.h"
#include "Options.h"
#include "IFR_Service_Utils.h"

#include "tao/ORB.h"
#include "tao/Object_KeyC.h"

#include "ace/Auto_Ptr.h"
#include "ace/Lock_Adapter_T.h"


ACE_RCSID (IFR_Service,
           Repository_i,
           "Repository_i.cpp,v 1.7 2003/08/18 06:42:14 ossama Exp")


TAO_Repository_i::TAO_Repository_i (CORBA::ORB_ptr orb,
                                    PortableServer::POA_ptr poa,
                                    ACE_Configuration *config)
  : TAO_IRObject_i (0),
    TAO_Container_i (0),
    orb_ (orb),
    root_poa_ (poa),
    config_ (config),
    extension_ (CORBA::string_dup ("TAO_IFR_name_extension")),
    lock_ (0)
{
}

TAO_Repository_i::~TAO_Repository_i (void)
{
  delete this->lock_;
}

CORBA::DefinitionKind
TAO_Repository_i::def_kind (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  return CORBA::dk_Repository;
}

void
TAO_Repository_i::destroy (ACE_ENV_SINGLE_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  ACE_THROW (CORBA::BAD_INV_ORDER (2, CORBA::COMPLETED_NO));
}

CORBA::Contained_ptr
TAO_Repository_i::lookup_id (const char *search_id
                             ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_IFR_READ_GUARD_RETURN (CORBA::Contained::_nil ());

  return this->lookup_id_i (search_id
                            ACE_ENV_ARG_PARAMETER);
}

CORBA::Contained_ptr
TAO_Repository_i::lookup_id_i (const char *search_id
                               ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  if (ACE_OS::strcmp (search_id, "IDL:omg.org/CORBA/Object:1.0") == 0
      || ACE_OS::strcmp (search_id, "IDL:omg.org/CORBA/ValueBase:1.0") == 0)
    {
      return CORBA::Contained::_nil ();
    }

  ACE_TString path;
  if (this->config_->get_string_value (this->repo_ids_key_,
                                       search_id,
                                       path)
       != 0)
    {
      return CORBA::Contained::_nil ();
    }

  ACE_Configuration_Section_Key key;
  this->config_->expand_path (this->root_key_,
                              path,
                              key);

  u_int kind = 0;
  this->config_->get_integer_value (key,
                                    "def_kind",
                                    kind);

  CORBA::DefinitionKind def_kind =
    ACE_static_cast (CORBA::DefinitionKind, kind);

  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (def_kind,
                                          path.c_str (),
                                          this->repo_
                                          ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::Contained::_nil ());

  return CORBA::Contained::_narrow (obj.in ()
                                   ACE_ENV_ARG_PARAMETER);
}

CORBA::TypeCode_ptr
TAO_Repository_i::get_canonical_typecode (CORBA::TypeCode_ptr tc
                                          ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_IFR_READ_GUARD_RETURN (CORBA::TypeCode::_nil ());

  return this->get_canonical_typecode_i (tc
                                         ACE_ENV_ARG_PARAMETER);
}

CORBA::TypeCode_ptr
TAO_Repository_i::get_canonical_typecode_i (CORBA::TypeCode_ptr tc
                                            ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::TCKind kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());

  switch (kind)
  {
    // For all the TCKinds not covered below, no change is needed.
    default:
      return CORBA::TypeCode::_duplicate (tc);
    case CORBA::tk_fixed:
      ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::TypeCode::_nil ());
    case CORBA::tk_array:
    {
      CORBA::ULong length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());

      CORBA::TypeCode_var ctype = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());

      CORBA::TypeCode_var canon_ctype =
        this->get_canonical_typecode_i (ctype.in ()
                                        ACE_ENV_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());

      return this->tc_factory ()->create_array_tc (length,
                                                   canon_ctype.in ()
                                                   ACE_ENV_ARG_PARAMETER);
    }
    case CORBA::tk_sequence:
    {
      CORBA::ULong length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());

      CORBA::TypeCode_var ctype = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());

      CORBA::TypeCode_var canon_ctype =
        this->get_canonical_typecode_i (ctype.in ()
                                        ACE_ENV_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());

      return this->tc_factory ()->create_sequence_tc (length,
                                                      canon_ctype.in ()
                                                      ACE_ENV_ARG_PARAMETER);
    }
    case CORBA::tk_alias:
    case CORBA::tk_objref:
    case CORBA::tk_struct:
    case CORBA::tk_union:
    case CORBA::tk_enum:
    case CORBA::tk_except:
    case CORBA::tk_value:
    case CORBA::tk_value_box:
    case CORBA::tk_native:
    case CORBA::tk_abstract_interface:
    case CORBA::tk_component:
    case CORBA::tk_home:
    {
      CORBA::String_var id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::TypeCode::_nil ());

      ACE_TString path;
      int status =
        this->config ()->get_string_value (this->repo_ids_key (),
                                           id.in (),
                                           path);

      // TODO - something in case the repo id is an empty string,
      //        or if it is not found in this repository
      if (status != 0)
        {
          return CORBA::TypeCode::_nil ();
        }

      ACE_Configuration_Section_Key key;
      this->config ()->expand_path (this->root_key (),
                                    path,
                                    key,
                                    0);

      // An ExceptionDef is not an IDLType.
      if (kind == CORBA::tk_except)
        {
          TAO_ExceptionDef_i impl (this->repo_);
          impl.section_key (key);
          return impl.type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
        }
      else
        {
          TAO_IDLType_i *impl =
            TAO_IFR_Service_Utils::path_to_idltype (path,
                                                    this);
          impl->section_key (key);
          return impl->type_i (ACE_ENV_SINGLE_ARG_PARAMETER);
        }
    }
  }
}

CORBA::PrimitiveDef_ptr
TAO_Repository_i::get_primitive (CORBA::PrimitiveKind kind
                                 ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  ACE_TString obj_id ("pkinds\\");

  obj_id += this->pkind_to_string (kind);

  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (CORBA::dk_Primitive,
                                          obj_id.c_str (),
                                          this->repo_
                                          ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::PrimitiveDef::_nil ());

  return CORBA::PrimitiveDef::_narrow (obj.in ()
                                      ACE_ENV_ARG_PARAMETER);
}

CORBA::StringDef_ptr
TAO_Repository_i::create_string (CORBA::ULong bound
                                 ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_IFR_WRITE_GUARD_RETURN (CORBA::StringDef::_nil ());

  return this->create_string_i (bound
                                ACE_ENV_ARG_PARAMETER);
}

CORBA::StringDef_ptr
TAO_Repository_i::create_string_i (CORBA::ULong bound
                                   ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  u_int count = 0;
  this->config_->get_integer_value (this->strings_key_,
                                    "count",
                                    count);

  char *name = TAO_IFR_Service_Utils::int_to_string (count++);
  this->config_->set_integer_value (this->strings_key_,
                                    "count",
                                    count);

  // Make new database entry.
  ACE_Configuration_Section_Key new_key;
  this->config_->open_section (this->strings_key_,
                               name,
                               1,
                               new_key);

  this->config_->set_integer_value (new_key,
                                    "bound",
                                    bound);

  this->config_->set_integer_value (new_key,
                                    "def_kind",
                                    CORBA::dk_String);

  this->config_->set_string_value (new_key,
                                   "name",
                                   name);

  // Create the object reference.
  ACE_TString obj_id ("strings\\");
  obj_id += name;

  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (CORBA::dk_String,
                                          obj_id.c_str (),
                                          this->repo_
                                          ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::StringDef::_nil ());

  return CORBA::StringDef::_narrow (obj.in ()
                                   ACE_ENV_ARG_PARAMETER);
}

CORBA::WstringDef_ptr
TAO_Repository_i::create_wstring (CORBA::ULong bound
                                  ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_IFR_WRITE_GUARD_RETURN (CORBA::WstringDef::_nil ());

  return this->create_wstring_i (bound
                                 ACE_ENV_ARG_PARAMETER);
}

CORBA::WstringDef_ptr
TAO_Repository_i::create_wstring_i (CORBA::ULong bound
                                    ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  u_int count = 0;
  this->config_->get_integer_value (this->wstrings_key_,
                                    "count",
                                    count);

  char *name = TAO_IFR_Service_Utils::int_to_string (count++);
  this->config_->set_integer_value (this->wstrings_key_,
                                    "count",
                                    count);

  // Make new database entry.
  ACE_Configuration_Section_Key new_key;
  this->config_->open_section (this->wstrings_key_,
                               name,
                               1,
                               new_key);

  this->config_->set_integer_value (new_key,
                                    "bound",
                                    bound);

  this->config_->set_integer_value (new_key,
                                    "def_kind",
                                    CORBA::dk_Wstring);

  this->config_->set_string_value (new_key,
                                   "name",
                                   name);

  // Create the object reference.
  ACE_TString obj_id ("wstrings\\");
  obj_id += name;

  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (CORBA::dk_Wstring,
                                               obj_id.c_str (),
                                               this->repo_
                                               ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::WstringDef::_nil ());

  return CORBA::WstringDef::_narrow (obj.in ()
                                    ACE_ENV_ARG_PARAMETER);
}

CORBA::SequenceDef_ptr
TAO_Repository_i::create_sequence (CORBA::ULong bound,
                                   CORBA::IDLType_ptr element_type
                                   ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_IFR_WRITE_GUARD_RETURN (CORBA::SequenceDef::_nil ());

  return this->create_sequence_i (bound,
                                  element_type
                                  ACE_ENV_ARG_PARAMETER);
}

CORBA::SequenceDef_ptr
TAO_Repository_i::create_sequence_i (CORBA::ULong bound,
                                     CORBA::IDLType_ptr element_type
                                     ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  u_int count = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -