当前位置: 首页>>代码示例>>C++>>正文


C++ Name::length方法代码示例

本文整理汇总了C++中cosnaming::Name::length方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::length方法的具体用法?C++ Name::length怎么用?C++ Name::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cosnaming::Name的用法示例。


在下文中一共展示了Name::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try {
    // Initialize orb
    CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );

    //Get reference to Root POA
    CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
    PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );

    // Activate POA Manager
    PortableServer::POAManager_var mgr = poa->the_POAManager();
    mgr->activate();


    // Find the Naming Service
    obj = orb->resolve_initial_references("NameService");
    CosNaming::NamingContext_var root =
      CosNaming::NamingContext::_narrow(obj.in());
    if (CORBA::is_nil(root.in())) {
      std::cerr << "Nil Naming Context reference" << std::endl;
      return 1;
    }

    // Bind the example Naming Context, if necessary
    CosNaming::Name name;
    name.length( 1 );
    name[0].id = CORBA::string_dup("example");
    try {
      obj = root->resolve(name);
    }
    catch(const CosNaming::NamingContext::NotFound&) {
      CosNaming::NamingContext_var dummy = root->bind_new_context(name);
    }

    // Bind the Messenger object
    name.length(2);
    name[1].id = CORBA::string_dup("Messenger");

    // Create an object
    PortableServer::Servant_var<Messenger_i> servant = new Messenger_i;
    PortableServer::ObjectId_var oid = poa->activate_object(servant.in());
    obj = poa->id_to_reference(oid.in());
    Messenger_var messenger = Messenger::_narrow(obj.in());
    root->rebind(name, messenger.in());

    std::cout << "Messenger object bound in Naming Service" << std::endl;

    // Accept requests
    orb->run();
    orb->destroy();
  }
  catch(const CORBA::Exception& ex) {
    std::cerr << "server: Caught a CORBA::Exception: " << ex << std::endl;
    return 1;
  }

  return 0;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:59,代码来源:MessengerServer.cpp

示例2: getModelLoader

ModelLoader_var hrp::getModelLoader(CosNaming::NamingContext_var cxt)
{
    CosNaming::Name ncName;
    ncName.length(1);
    ncName[0].id = CORBA::string_dup("ModelLoader");
    ncName[0].kind = CORBA::string_dup("");
    ModelLoader_var modelLoader = NULL;
    try {
        modelLoader = ModelLoader::_narrow(cxt->resolve(ncName));
        modelLoader->_non_existent();
    } catch(const CosNaming::NamingContext::NotFound &exc) {
        std::cerr << "ModelLoader not found: ";
        switch(exc.why) {
        case CosNaming::NamingContext::missing_node:
            std::cerr << "Missing Node" << std::endl;
        case CosNaming::NamingContext::not_context:
            std::cerr << "Not Context" << std::endl;
            break;
        case CosNaming::NamingContext::not_object:
            std::cerr << "Not Object" << std::endl;
            break;
        }
        modelLoader = ModelLoader::_nil();
    } catch(CosNaming::NamingContext::CannotProceed &exc) {
        std::cerr << "Resolve ModelLoader CannotProceed" << std::endl;
        modelLoader = ModelLoader::_nil();
    } catch(CosNaming::NamingContext::AlreadyBound &exc) {
        std::cerr << "Resolve ModelLoader InvalidName" << std::endl;
        modelLoader = ModelLoader::_nil();
    } catch(...){
        modelLoader = ModelLoader::_nil();
    }
    return modelLoader;
}
开发者ID:YoheiKakiuchi,项目名称:openhrp3-1,代码行数:34,代码来源:ModelLoaderUtil.cpp

示例3:

Web_Server::Iterator_Factory_ptr
get_iterator (CORBA::ORB_ptr o)
{
  CORBA::ORB_var orb = CORBA::ORB::_duplicate (o);

  // Get a reference to the Name Service.
  CORBA::Object_var obj =
    orb->resolve_initial_references ("NameService");

  // Narrow to a Naming Context
  CosNaming::NamingContext_var nc =
    CosNaming::NamingContext::_narrow (obj.in ());

  if (CORBA::is_nil (obj.in ()))
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("Nil reference to Name Service\n")));
      return Web_Server::Iterator_Factory::_nil ();
    }

  // Create a name.
  CosNaming::Name name;
  name.length (1);
  name[0].id = CORBA::string_dup ("Iterator_Factory");
  name[0].kind = CORBA::string_dup ("");

  obj = nc->resolve (name);

  Web_Server::Iterator_Factory_ptr factory =
    Web_Server::Iterator_Factory::_narrow (obj.in ());

  return factory;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:33,代码来源:client.cpp

示例4: isRegistered

bool CorbaNameService::isRegistered(const std::string& taskName)
{
    if(CORBA::is_nil(orb))
    {
       throw std::runtime_error("CorbaNameService::Error, called getTaskContext() without connection " );
    }

    CosNaming::Name serverName;
    serverName.length(2);
    serverName[0].id = CORBA::string_dup("TaskContexts");
    serverName[1].id = CORBA::string_dup( taskName.c_str() );

    try {
        // Get object reference
        CORBA::Object_var task_object = rootContext->resolve(serverName);
        if(CORBA::is_nil(task_object))
            return false;

        RTT::corba::CTaskContext_var mtask = RTT::corba::CTaskContext::_narrow (task_object.in ());
        if ( CORBA::is_nil( mtask ) ) {
            return false;
        }
        
        // force connect to object.
        //this needs to be done. If not, we may return a ghost task
        CORBA::String_var nm = mtask->getName(); 
    } catch (...)
    {
        return false;
    }
    
    return true;
}
开发者ID:rock-cpp,项目名称:orocos_cpp,代码行数:33,代码来源:CorbaNameService.cpp

示例5: getTaskContext

RTT::TaskContext* CorbaNameService::getTaskContext(const std::string& taskName)
{
    if(CORBA::is_nil(orb))
    {
        throw std::runtime_error("CorbaNameService::Error, called getTaskContext() without connection " );
    }

    CosNaming::Name serverName;
    serverName.length(2);
    serverName[0].id = CORBA::string_dup("TaskContexts");
    serverName[1].id = CORBA::string_dup( taskName.c_str() );

    // Get object reference
    CORBA::Object_var task_object = rootContext->resolve(serverName);
    CORBA::String_var s = orb->object_to_string(task_object);

    RTT::TaskContext *ret = nullptr;
        
    try
    {
        ret = RTT::corba::TaskContextProxy::Create(s.in(), true);;
    }
    catch (...)
    {
        std::cout << "Ghost " << taskName << std::endl;
    }
    
    return ret;
}
开发者ID:rock-cpp,项目名称:orocos_cpp,代码行数:29,代码来源:CorbaNameService.cpp

示例6: EventChannelFactory

void
ApplicationWindow::resolveFactory(QString const& _name)
{
  try {
    CosNaming::Name name;
    
    name.length(1);
    name[0].id = CORBA::string_dup(_name.latin1());
    CosNotifyChannelAdmin::EventChannelFactory_ptr factory =
      server_.resolveName<CosNotifyChannelAdmin::EventChannelFactory>(name);
    
    EventChannelFactory * f = 
      new EventChannelFactory(factory, listView_, this, _name);

    connect(timer_, SIGNAL(timeout()), f, SLOT(updateFactory()));
  }
  catch(CORBA::Exception& e) {
    std::ostringstream sstr;
    sstr << "CORBA exception: " << e << std::flush;

    QString error = sstr.str().c_str();
    QMessageBox::warning(this, 
			 "Resolve EventChannelFactory", 
			 "Error resolving factory " + _name + ".\n" + error);

  }
}
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:27,代码来源:ApplicationWindow.cpp

示例7: throw

CosNaming::Name* 
VOmniORBHelper::nsPathToObjectName(const char* program, const char* object,
				   int telescopenumber)
  throw(CORBA::SystemException)
{
  std::ostringstream program_stream;
  if(telescopenumber!=-1)
    program_stream << program << telescopenumber;
  else 
    program_stream << program;
  
  CosNaming::Name* name = new CosNaming::Name;
  name->length(3);
  
  (*name)[0].id   = CORBA::string_dup(m_project.c_str());
  (*name)[0].kind = CORBA::string_dup("");

  (*name)[1].id   = CORBA::string_dup(program_stream.str().c_str());
  (*name)[1].kind = CORBA::string_dup("Program");

  (*name)[2].id   = CORBA::string_dup(object);
  (*name)[2].kind = CORBA::string_dup("Object");

  return name;
}
开发者ID:sfegan,项目名称:astro_db_reslover,代码行数:25,代码来源:VOmniORBHelper.cpp

示例8: checkCorbaServer

X_ptr checkCorbaServer(std::string n, CosNaming::NamingContext_var &cxt)
{
  CosNaming::Name ncName;
  ncName.length(1);
  ncName[0].id = CORBA::string_dup(n.c_str());
  ncName[0].kind = CORBA::string_dup("");
  X_ptr srv = NULL;
  try {
    srv = X::_narrow(cxt->resolve(ncName));
  } catch(const CosNaming::NamingContext::NotFound &exc) {
    std::cerr << n << " not found: ";
    switch(exc.why) {
    case CosNaming::NamingContext::missing_node:
      std::cerr << "Missing Node" << std::endl;
    case CosNaming::NamingContext::not_context:
      std::cerr << "Not Context" << std::endl;
      break;
    case CosNaming::NamingContext::not_object:
      std::cerr << "Not Object" << std::endl;
      break;
    }
    return (X_ptr)NULL;
  } catch(CosNaming::NamingContext::CannotProceed &exc) {
    std::cerr << "Resolve " << n << " CannotProceed" << std::endl;
  } catch(CosNaming::NamingContext::AlreadyBound &exc) {
    std::cerr << "Resolve " << n << " InvalidName" << std::endl;
  }
  return srv;
}
开发者ID:olivier-stasse,项目名称:openhrp3-simulator-wo-rtm,代码行数:29,代码来源:simscheduler.cpp

示例9: getNameLength

  /*!
   * @if jp
   * @brief ネームコンポーネントの文字列表現時の文字長を取得する
   * @else
   * @brief Get string length of the name component's string representation
   * @endif
   */
  CORBA::ULong CorbaNaming::getNameLength(const CosNaming::Name& name)
  {
    CORBA::ULong slen = 0;
    
    for (CORBA::ULong i = 0; i < name.length(); ++i)
      {
	// Count string length of id(s)
	for (const char* id = name[i].id; *id; ++id)
	  {
	    // Escape character '/', '.', '\' will convert to "\/", "\.", "\\".
	    if (*id == '/' || *id == '.' || *id == '\\') slen++;
	    slen++;
	  }
	// If kind exists, space for '.' is counted
	if (((const char*)(name[i].id  ))[0] == '\0' || 
	    ((const char*)(name[i].kind))[0] != '\0')
	  {
	    slen++;
	  }
	// Count string length of kind(s)
	for (const char* kind = name[i].kind; *kind; kind++)
	  {
	    if (*kind == '/' || *kind == '.' || *kind == '\\') slen++;
	    slen++;
	  }
	// Space for '/' or '\0'
	slen++;
      }
    return slen;
  }
开发者ID:pansas,项目名称:OpenRTM-aist-portable,代码行数:37,代码来源:CorbaNaming.cpp

示例10: nameToString

  /*!
   * @if jp
   * @brief ネームコンポーネントの文字列表現を取得する
   * @else
   * @brief Get string representation of name component
   * @endif
   */
  void CorbaNaming::nameToString(const CosNaming::Name& name,
				 char* string_name,
				 CORBA::ULong slen)
  {
    char* s = string_name;
    for (CORBA::ULong i = 0; i < name.length(); ++i)
      {
	// Copy id to string_name
	for (const char* id = name[i].id; *id != '\0'; ++id)
	  {
	    if (*id == '/' || *id == '.' || *id == '\\') *s++ = '\\';
	    *s++ = *id;
	  }
	// '.' if there is a kind, or no id
	if (((const char*)(name[i].id  ))[0] == '\0' || 
	    ((const char*)(name[i].kind))[0] != '\0')
	  *s++ = '.';
	// Copy kind to string_name
	for (const char* kind = name[i].kind; *kind != '\0'; ++kind)
	  {
	    if (*kind == '/' || *kind == '.' || *kind == '\\')
	      *s++ = '\\';
	    *s++ = *kind;
	  }
	// The end of string_name will be overwritten by '\0'
	*s++ = '/';
      }
    string_name[slen-1] = '\0';
  }
开发者ID:pansas,项目名称:OpenRTM-aist-portable,代码行数:36,代码来源:CorbaNaming.cpp

示例11: OBJECT_NOT_EXIST

void
TAO_Hash_Naming_Context::bind_context (const CosNaming::Name &n,
                                       CosNaming::NamingContext_ptr nc)
{
  // Check to make sure this object didn't have <destroy> method
  // invoked on it.
  if (this->destroyed_)
    throw CORBA::OBJECT_NOT_EXIST ();

  // Do not allow binding of nil context reference.
  if (CORBA::is_nil (nc))
    throw CORBA::BAD_PARAM ();

  // Get the length of the name.
  CORBA::ULong const name_len = n.length ();

  // Check for invalid name.
  if (name_len == 0)
    throw CosNaming::NamingContext::InvalidName();

  // If we received compound name, resolve it to get the context in
  // which the binding should take place, then perform the binding on
  // target context.
  if (name_len > 1)
    {
      CosNaming::NamingContext_var context = this->get_context (n);

      CosNaming::Name simple_name;
      simple_name.length (1);
      simple_name[0] = n[name_len - 1];
      try
        {
          context->bind_context (simple_name, nc);
        }
      catch (const CORBA::SystemException&)
        {
          throw CosNaming::NamingContext::CannotProceed(
            context.in (), simple_name);
        }
    }
  // If we received a simple name, we need to bind it in this context.
  else
    {
      ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
                                this->lock_,
                                CORBA::INTERNAL ());

      // Try binding the name.
      int result = this->context_->bind (n[0].id,
                                        n[0].kind,
                                        nc,
                                        CosNaming::ncontext);
      if (result == 1)
        throw CosNaming::NamingContext::AlreadyBound();

      // Something went wrong with the internal structure
      else if (result == -1)
        throw CORBA::INTERNAL ();
    }
}
开发者ID:binary42,项目名称:OCI,代码行数:60,代码来源:Hash_Naming_Context.cpp

示例12: DBG

NotifyLogPlayer::~NotifyLogPlayer()
{
  DBG(cout << "Destructing NotifyLogPlayer." << endl);

  delete pPushSupplier;

  try {
    if (own_) {
      CosNaming::Name n;
      n.length(1);
      n[0].id = CORBA::string_dup("EventChannel");
      namingContext->unbind(n);
    }
    if (colocated_)
      initialNamingContext->unbind(channelFactoryName);

  }
  catch (const CORBA::Exception& e) {
    cerr << "Caught CORBA exception on unbind: " << e << endl;
    cerr << "Porbably the NameSevice went down while we run." << endl;
  }

  DBG(cout << "unbound objects from Name Sevice" << endl);

  if (colocated_)
    ec_->destroy();
}
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:27,代码来源:NotifyLogPlayer.cpp

示例13:

void
handle_sigint
( int signal )
{
	std::cout << "\nGot Crtl-C" << std::endl;
	std::cerr << "..... unbind in NameService" << std::endl;

	//
	// unbind in naming service
	//
    CORBA::Object_var obj;
	CosNaming::NamingContext_var nameService;
	char hostname[256];
	gethostname(hostname, 256);
	CosNaming::Name name;
    name.length(3);
    name[0].id = CORBA::string_dup("Qedo");
    name[0].kind = CORBA::string_dup("");
	name[1].id = CORBA::string_dup("ComponentInstallation");
    name[1].kind = CORBA::string_dup("");
	name[2].id = CORBA::string_dup(hostname);
    name[2].kind = CORBA::string_dup("");
    try
    {
        obj = orb->resolve_initial_references("NameService");
		nameService = CosNaming::NamingContext::_narrow(obj.in());
		nameService->unbind(name);
    }
	catch (const CORBA::Exception&)
	{
		std::cerr << "..... could not unbind" << std::endl;
	}
	
	exit(1);
}
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:35,代码来源:ci.cpp

示例14: name

void
Connection_Manager::add_to_receivers (CosNaming::BindingList &binding_list)
{
  for (CORBA::ULong i = 0;
       i < binding_list.length ();
       i++)
    {
      // Get the receiver name from the binding list.
      ACE_CString receiver_name =
        binding_list [i].binding_name [0].id.in ();

      CosNaming::Name name (1);
      name.length (1);
      name [0].id =
        CORBA::string_dup (receiver_name.c_str ());

      // Resolve the reference of the receiver from the receiver
      // context.
      CORBA::Object_var obj =
        this->receiver_context_->resolve (name);

      AVStreams::MMDevice_var receiver_device =
        AVStreams::MMDevice::_narrow (obj.in ());

      // Add this receiver to the receiver map.
      ACE_CString flowname =
        this->sender_name_ +
        "_" +
        receiver_name;
      this->receivers_.bind (flowname,
                             receiver_device);
    }
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:33,代码来源:Connection_Manager.cpp

示例15: catch

Speech::~Speech()
{
#ifdef DEBUG
  cout << "Destructing Speech." << endl;
#endif
  //  pConsumer->disconnect_push_consumer();

  try {
    CosNaming::Name n;
     
    n.length(1);
    n[0].id = CORBA::string_dup("Speech");
    namingContext->unbind(n);
    //    n[0].id = CORBA::string_dup("SpeechEC");
    //    namingContext->unbind(n);

#ifdef DEBUG
    cout << "Unbound objects from NamingSevice." << endl;
#endif
  }
  catch (const CORBA::Exception& e) {
    cerr << "Caught CORBA exception on unbind: " << e << endl;
    cerr << "Porbably the NameSevice went down while we ran." << endl;
  }
}
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:25,代码来源:DtlkSpeech.cpp


注:本文中的cosnaming::Name::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。