NamingContextHelper::ObjectInfoList NamingContextHelper::getObjectList(std::vector<ObjectPath>& pathList) { ObjectInfoList objects; if(checkOrUpdateNamingContext()){ CORBA::Object_var obj = findObjectSub(pathList); if(isObjectAlive(obj)){ CosNaming::NamingContext_var new_context = CosNaming::NamingContext::_narrow(obj); CosNaming::BindingList_var bList; CosNaming::BindingIterator_var bIter; const CORBA::ULong batchSize = 100; new_context->list(batchSize, bList, bIter); appendBindingList(bList, pathList, objects); if(!CORBA::is_nil(bIter) && isObjectAlive(bIter)){ while (bIter->next_n(batchSize, bList)) { appendBindingList(bList, pathList, objects); } } } } return objects; }
void Connection_Manager::find_receivers (void) { CosNaming::BindingIterator_var iterator; CosNaming::BindingList_var binding_list; const CORBA::ULong chunk = 100; // Get the list of receivers registered for this sender. this->receiver_context_->list (chunk, binding_list, iterator); // Add the receivers found in the bindinglist to the <receivers>. this->add_to_receivers (binding_list); if (!CORBA::is_nil (iterator.in ())) { CORBA::Boolean more = 1; // Check to see if there are more receivers listed. while (more) { more = iterator->next_n (chunk, binding_list); this->add_to_receivers (binding_list); } } }
/*! * @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; }
NamingContextHelper::ObjectInfoList NamingContextHelper::getObjectList() { ObjectInfoList objects; if(checkOrUpdateNamingContext()){ CosNaming::BindingList_var bList; CosNaming::BindingIterator_var bIter; const CORBA::ULong batchSize = 100; namingContext->list(batchSize, bList, bIter); appendBindingList(bList, objects); if(!CORBA::is_nil(bIter) && isObjectAlive(bIter)){ while(bIter->next_n(batchSize, bList)){ appendBindingList(bList, objects); } } } return objects; }
void CNamingTreeCtrl::ListContext(HTREEITEM hItem) { CWaitCursor Waiter; try { // Get the items object and make sure we have a context CNamingObject* pObject = GetTreeObject(hItem); CosNaming::NamingContext_var Context = pObject->NamingContext(); if(CORBA::is_nil(Context)) { return; } // List the contexts entries CosNaming::BindingList_var bl; CosNaming::BindingIterator_var bi; Context->list(LISTQUANTUM, bl, bi); ListBindingList(hItem, Context, bl); if(!CORBA::is_nil(bi)) { while(bl->length()) { CString Text; Text.Format(ACE_TEXT ("This context contains more than %d entries, list the next %d?"), LISTQUANTUM, LISTQUANTUM); if(MessageBox(Text, ACE_TEXT ("Question"), MB_YESNO) == IDNO) { return; } bi->next_n(LISTQUANTUM, bl); ListBindingList(hItem, Context, bl); } bi->destroy(); } } catch(CORBA::Exception& ex) { MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex._rep_id()), ACE_TEXT ("CORBA::Exception")); } }
int Iterator_Test::execute (TAO_Naming_Client &root_context) { try { // Instantiate four dummy objects. My_Test_Object *impl = new My_Test_Object; Test_Object_var obj = impl->_this (); impl->_remove_ref (); // Bind objects to the naming context. CosNaming::Name name1; name1.length (1); name1[0].id = CORBA::string_dup ("foo1"); CosNaming::Name name2; name2.length (1); name2[0].id = CORBA::string_dup ("foo2"); CosNaming::Name name3; name3.length (1); name3[0].id = CORBA::string_dup ("foo3"); CosNaming::Name name4; name4.length (1); name4[0].id = CORBA::string_dup ("foo4"); root_context->bind (name1, obj.in ()); root_context->bind (name2, obj.in ()); root_context->bind (name3, obj.in ()); root_context->bind (name4, obj.in ()); // List the content of the Naming Context. CosNaming::BindingIterator_var iter; CosNaming::BindingList_var bindings_list; root_context->list (1, bindings_list.out (), iter.out ()); if (CORBA::is_nil (iter.in ()) || bindings_list->length () != 1 || bindings_list[0u].binding_type != CosNaming::nobject) ACE_ERROR_RETURN ((LM_ERROR, "CosNaming::list does not function properly\n"), -1); ACE_DEBUG ((LM_DEBUG, "First binding: %s\n", bindings_list[0u].binding_name[0u].id.in ())); // Invoke operations on the iterator. CosNaming::Binding_var binding; iter->next_one (binding.out ()); if (binding->binding_type != CosNaming::nobject) ACE_ERROR_RETURN ((LM_ERROR, "CosNaming::next_one does not function properly\n"), -1); ACE_DEBUG ((LM_DEBUG, "Second binding: %s\n", binding->binding_name[0].id.in ())); iter->next_n (2, bindings_list.out ()); if (bindings_list->length () != 2 || bindings_list[0u].binding_type != CosNaming::nobject || bindings_list[1u].binding_type != CosNaming::nobject) ACE_ERROR_RETURN ((LM_ERROR, "CosNaming::BindingIterator does not function properly\n"), -1); ACE_DEBUG ((LM_DEBUG, "Third binding: %s\n" "Fourth binding: %s\n", bindings_list[0u].binding_name[0].id.in (), bindings_list[1u].binding_name[0].id.in ())); // We already iterated over all the bindings, so the following // should return false. CORBA::Boolean result = iter->next_one (binding.out ()); if (result) ACE_ERROR_RETURN ((LM_ERROR, "CosNaming::BindingIterator does not function properly\n"), -1); iter->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "Unexpected exception in Iterator test"); return -1; } return 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; }