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

📄 componentcontainer_i.cpp

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

#include "ComponentContainer_i.h"
#include "Repository_i.h"
#include "InterfaceDef_i.h"
#include "ComponentDef_i.h"
#include "ValueDef_i.h"
#include "IFR_Service_Utils.h"
#include "ace/SString.h"

ACE_RCSID (IFRService, 
           ComponentContainer_i, 
           "ComponentContainer_i.cpp,v 1.10 2003/08/13 20:25:33 parsons Exp")
           
const char *TAO_ComponentContainer_i::tmp_name_holder_ = 0;

TAO_ComponentContainer_i::TAO_ComponentContainer_i (TAO_Repository_i *repo)
  : TAO_IRObject_i (repo),
    TAO_Container_i (repo)
{
}

TAO_ComponentContainer_i::~TAO_ComponentContainer_i (void)
{
}

CORBA::ComponentIR::ComponentDef_ptr 
TAO_ComponentContainer_i::create_component (
    const char *id,
    const char *name,
    const char *version,
    CORBA::ComponentIR::ComponentDef_ptr base_component,
    const CORBA::InterfaceDefSeq &supports_interfaces
    ACE_ENV_ARG_DECL
  )
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_IFR_WRITE_GUARD_RETURN (CORBA::ComponentIR::ComponentDef::_nil ());

  this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::ComponentIR::ComponentDef::_nil ());

  return this->create_component_i (id,
                                   name,
                                   version,
                                   base_component,
                                   supports_interfaces
                                   ACE_ENV_ARG_PARAMETER);
}

CORBA::ComponentIR::ComponentDef_ptr 
TAO_ComponentContainer_i::create_component_i (
    const char *id,
    const char *name,
    const char *version,
    CORBA::ComponentIR::ComponentDef_ptr base_component,
    const CORBA::InterfaceDefSeq &supports_interfaces
    ACE_ENV_ARG_DECL
  )
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_ComponentContainer_i::tmp_name_holder_ = name;
  ACE_Configuration_Section_Key new_key;
  ACE_TString path = 
    TAO_IFR_Service_Utils::create_common (
        this->def_kind (),
        CORBA::dk_Component,
        this->section_key_,
        new_key,
        this->repo_,
        id,
        name,
        &TAO_ComponentContainer_i::same_as_tmp_name,
        version,
        "defns"
        ACE_ENV_ARG_PARAMETER
      );
  ACE_CHECK_RETURN (CORBA::ComponentIR::ComponentDef::_nil ());

  if (! CORBA::is_nil (base_component))
    {
      const char *base_path = 
        TAO_IFR_Service_Utils::reference_to_path (base_component);
          
      // Get the servant's key into the temporary key holder, because
      // the name clash checker for base valuetypes is static, and has
      // no other way to know about a specific key.
      this->repo_->config ()->expand_path (
                                  this->repo_->root_key (),
                                  base_path,
                                  TAO_IFR_Service_Utils::tmp_key_,
                                  0
                                );
      TAO_IFR_Service_Utils::name_exists (&TAO_ComponentDef_i::name_clash,
                                          new_key,
                                          this->repo_,
                                          CORBA::dk_Component
                                          ACE_ENV_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::ComponentIR::ComponentDef::_nil ());
          
      // Store the id for this - that's what ComponentDescription takes.
      ACE_TString base_id;
      this->repo_->config ()->get_string_value (TAO_IFR_Service_Utils::tmp_key_,
                                                "id",
                                                base_id);
      this->repo_->config ()->set_string_value (new_key,
                                                "base_component",
                                                base_id);
    }

  CORBA::ULong count = supports_interfaces.length ();
  CORBA::ULong i = 0;

  if (count > 0)
    {
      ACE_Configuration_Section_Key supports_key;
      this->repo_->config ()->open_section (new_key,
                                            "supported",
                                            1,
                                            supports_key);

      this->repo_->config ()->set_integer_value (supports_key,
                                                 "count",
                                                 count);

      const char *supported_path = 0;
      char *stringified = 0;

      for (i = 0; i < count; ++i)
        {
          stringified = TAO_IFR_Service_Utils::int_to_string (i);
          supported_path = 
            TAO_IFR_Service_Utils::reference_to_path (
                supports_interfaces[i].in ()
              );
          this->repo_->config ()->set_string_value (supports_key,
                                                    stringified,
                                                    supported_path);
        }
    }

  // Create the object reference.
  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (CORBA::dk_Component,
                                          path.c_str (),
                                          this->repo_
                                          ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::ComponentIR::ComponentDef::_nil ());

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

CORBA::ComponentIR::HomeDef_ptr 
TAO_ComponentContainer_i::create_home (
    const char *id,
    const char *name,
    const char *version,
    CORBA::ComponentIR::HomeDef_ptr base_home,
    CORBA::ComponentIR::ComponentDef_ptr managed_component,
    const CORBA::InterfaceDefSeq &supports_interfaces,
    CORBA::ValueDef_ptr primary_key
    ACE_ENV_ARG_DECL
  )
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_IFR_WRITE_GUARD_RETURN (CORBA::ComponentIR::HomeDef::_nil ());

  this->update_key (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::ComponentIR::HomeDef::_nil ());

  return this->create_home_i (id,
                              name,
                              version,
                              base_home,
                              managed_component,
                              supports_interfaces,
                              primary_key
                              ACE_ENV_ARG_PARAMETER);
}

CORBA::ComponentIR::HomeDef_ptr 
TAO_ComponentContainer_i::create_home_i (
    const char *id,
    const char *name,
    const char *version,
    CORBA::ComponentIR::HomeDef_ptr base_home,
    CORBA::ComponentIR::ComponentDef_ptr managed_component,
    const CORBA::InterfaceDefSeq &supports_interfaces,
    CORBA::ValueDef_ptr primary_key
    ACE_ENV_ARG_DECL
  )
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_ComponentContainer_i::tmp_name_holder_ = name;
  ACE_Configuration_Section_Key new_key;
  ACE_TString path = 
    TAO_IFR_Service_Utils::create_common (
        this->def_kind (),
        CORBA::dk_Home,
        this->section_key_,
        new_key,
        this->repo_,
        id,
        name,
        &TAO_ComponentContainer_i::same_as_tmp_name,
        version,
        "defns"
        ACE_ENV_ARG_PARAMETER
      );
  ACE_CHECK_RETURN (CORBA::ComponentIR::HomeDef::_nil ());

  char *base_path = 0;

  if (! CORBA::is_nil (base_home))
    {
      base_path = TAO_IFR_Service_Utils::reference_to_path (base_home);
      this->repo_->config ()->set_string_value (new_key,
                                                "base_home",
                                                base_path);
    }

  if (! CORBA::is_nil (managed_component))
    {
      base_path = 
        TAO_IFR_Service_Utils::reference_to_path (managed_component);
      this->repo_->config ()->set_string_value (new_key,
                                                "managed",
                                                base_path);
    }

  CORBA::ULong length = supports_interfaces.length ();
  CORBA::ULong i = 0;

  if (length > 0)
    {
      ACE_Configuration_Section_Key supports_key;
      this->repo_->config ()->open_section (new_key,
                                            "supported",
                                            1,
                                            supports_key);
      this->repo_->config ()->set_integer_value (supports_key,
                                                 "count",
                                                 length);

      char *supported_path = 0;
      char *stringified = 0;

      for (i = 0; i < length; ++i)
        {
          supported_path = 
            TAO_IFR_Service_Utils::reference_to_path (
                supports_interfaces[i].in ()
              );
          stringified = TAO_IFR_Service_Utils::int_to_string (i);
          this->repo_->config ()->set_string_value (supports_key,
                                                    stringified,
                                                    supported_path);
        }
    }

  if (! CORBA::is_nil (primary_key))
    {
      char *primary_key_path = 
        TAO_IFR_Service_Utils::reference_to_path (primary_key);
        this->repo_->config ()->set_string_value (new_key,
                                                  "primary_key",
                                                  primary_key_path);
    }

  // Create the object reference.
  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (CORBA::dk_Home,
                                          path.c_str (),
                                          this->repo_
                                          ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (CORBA::ComponentIR::HomeDef::_nil ());

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

⌨️ 快捷键说明

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