/*!
   * @if jp
   * @brief 与えられた NamingContext の Binding を取得する
   * @else
   * @brief Get Binding on the given NamingContext
   * @endif
   */
  void CorbaNaming::list(CosNaming::NamingContext_ptr name_cxt,
			 CORBA::ULong how_many,
			 CosNaming::BindingList_var& bl,
			 CosNaming::BindingIterator_var& bi)
  {
#ifndef ORB_IS_RTORB
    name_cxt->list(how_many, bl.out(), bi.out());
#else // ORB_IS_RTORB
    name_cxt->list(how_many, (CosNaming::BindingList_out)bl,
                   (CosNaming::BindingIterator_ptr)bi);
#endif // ORB_IS_RTORB

  }
  /*!
   * @if jp
   * @brief NamingContext を再帰的に下って非アクティブ化する
   * @else
   * @brief Destroy the naming context recursively
   * @endif
   */
  void CorbaNaming::destroyRecursive(CosNaming::NamingContext_ptr context)
    throw (SystemException, NotEmpty, NotFound, CannotProceed, InvalidName)
  {
    CosNaming::BindingList_var     bl;
    CosNaming::BindingIterator_var bi;
    CORBA::Boolean cont(true);
    
#ifndef ORB_IS_RTORB
    context->list(m_blLength, bl.out(), bi.out());
#else // ORB_IS_RTORB
    //    context->list(m_blLength, bl, bi);
    context->list(m_blLength, (CosNaming::BindingList_out)bl,
                  (CosNaming::BindingIterator_ptr)bi);
#endif // ORB_IS_RTORB
    
    while (cont)
      {
	CORBA::ULong len(bl->length());
	
	for (CORBA::ULong i = 0; i < len; ++i)
	  {
	    if (bl[i].binding_type == CosNaming::ncontext)
	      {	// If Object is context, destroy recursive.
		CosNaming::NamingContext_var next_context;
		next_context = CosNaming::NamingContext::
		  _narrow(context->resolve(bl[i].binding_name));
		
		// Recursive function call
		destroyRecursive(next_context); // +++ Recursive call +++
		context->unbind(bl[i].binding_name);
		next_context->destroy();
	      }
	    else if (bl[i].binding_type == CosNaming::nobject)
	      {	// If Object is object, unbind it.
		context->unbind(bl[i].binding_name);
	      }
	    else assert(0); // never comes here
	  }
	
	// no more binding -> do-while loop will be finished
	if (CORBA::is_nil(bi)) cont = false;
	else bi->next_n(m_blLength, bl);
      }
    
    if (!CORBA::is_nil(bi)) bi->destroy();
    return;
  }
Example #3
0
/*引数にTreeObjectを追加*/
void ListRecursive(CosNaming::NamingContext_ptr context,vector<OtherPort> &rtclist,vector<string> &name, TreeObject *to){
    CosNaming::BindingList_var     bl;
    CosNaming::BindingIterator_var bi;
    CORBA::Boolean cont(true);
    int m_blLength=100;
    context->list(m_blLength, bl, bi);
 
    while (cont){
        CORBA::ULong len(bl->length());
        for (CORBA::ULong i = 0; i < len; ++i){
 
            if (bl[i].binding_type == CosNaming::ncontext){
                CosNaming::NamingContext_var next_context;
                next_context = CosNaming::NamingContext::_narrow(context->resolve(bl[i].binding_name));
                vector<string> namebuff=name;
                name.push_back(string(bl[i].binding_name[0].id));
                //name.push_back("/");
				TreeObject *to2 = new TreeObject(string(bl[i].binding_name[0].id));
				to->to.push_back(to2);
                ListRecursive(next_context,rtclist,name,to2); 
                name=namebuff;
            }
            else if (bl[i].binding_type == CosNaming::nobject){
                if(rtclist.size()>m_blLength)
                    break;
                vector<string> namebuff=name;
                name.push_back(string(bl[i].binding_name[0].id));
/*
データポートの情報を取得するためのコードを追加
*/
				if(string(bl[i].binding_name[0].kind) == "rtc")
				{
					
					RTC::CorbaConsumer<RTC::RTObject> rto;
					rto.setObject(context->resolve(bl[i].binding_name));
					try
					{
						RTC::PortServiceList_var tp = rto._ptr()->get_ports();
					
						TreeObject *to2 = new TreeObject(string(bl[i].binding_name[0].id));
						to->to.push_back(to2);

						for(int k=0;k < tp->length();k++)
						{
							vector<string> namebuff2=name;
							string tname = tp[(CORBA::ULong)k]->get_port_profile()->name;
							PortService_var p = tp[(CORBA::ULong)k];
							vector<string> pn = coil::split(tname, ".");
							namebuff2.push_back(pn[1]);

							TreeObject *to3 = new TreeObject(string(pn[1]));
							to2->to.push_back(to3);

							rtclist.push_back(OtherPort(p, namebuff2));
						}
					}
					catch(...)
					{

					}

					
					

					//name=namebuff2;
				}
/*ここまで*/
				name=namebuff;
				
                //rtclist.push_back(name_buff);
            }
            else {
            }
        }
        if (CORBA::is_nil(bi)) {
            cont = 0;
        }
        else {
            bi->next_n(m_blLength, bl);
        }
    }
    return;
}