void ConfigurationChecker::set_banner(Directory & container, Formatter object, const char * type, int id) { Directory * node; char buffer[32]; banner = string(" ") + object.str() + " : "; sprintf(buffer, "id = %d", id); node = container.findChild(OBJECTTREE, type, NULL)->getFirstChild(); while(node != 0 && node->toInteger() != id) node = node->getNext(); if( node != 0 ) { banner += node->getKey() + " (" + buffer + ") "; node = node->findChild("position"); if(node != 0) banner += string("at ") + node->toString(); } else banner += buffer; if(VerboseMessage::getVerbose()) { cout << banner << endl; banner.erase(); } }
//ID値のアサインメント // (他の場所からも使うのでここに移動) int Common::assignID(Directory & container, const char * category, const char * top, enum tagAssignmentOrder order) { Directory * node = 0; Directory * scope = 0; Directory * work = 0; set<int> idpool; map<int, Directory *> sorter; map<int, Directory *>::iterator p_sorter; int i; //下準備 node = container.findChild(top,category,NULL); if(node == 0) return 0; for(i=1;i< (signed int) node->size() + 32; i++) idpool.insert(i); //割付順の決定と,割当済みIDの削除 i = 0; scope = node->getFirstChild(); while(scope != 0) { if( *scope == Directory::INTEGER ) idpool.erase(*scope); else { //重複名称の存在チェック work = container.openChild("/","identifier",scope->getKey().c_str(),NULL); if( *work == Directory::INTEGER) { VerboseMessage("Assigning the same ID (%) since the name (%[%]) is duplicated\n","ID番号(%)を異種同名のオブジェクト(%[%])に割り当てます.\n") << work->toInteger() << scope->getKey() << category; idpool.erase(*scope = work->toInteger()); } else { //割当方法に従って割当候補に追加 switch(order) { case ALPHABETIC: sorter[i++] = scope; break; case REVERSE_ALPHABETIC: sorter[i--] = scope; break; case FCFS: default: sorter[scope->openChild("#order")->toInteger()] = scope; break; case REVERSE_FCFS: sorter[-scope->openChild("#order")->toInteger()] = scope; break; } } } scope = scope->getNext(); } //ID割当 p_sorter = sorter.begin(); while(p_sorter != sorter.end()) { scope = (*p_sorter).second; if( !(*scope == Directory::INTEGER) ) { i = *(idpool.begin()); idpool.erase(idpool.begin()); work = container.openChild("/","identifier",scope->getKey().c_str(),NULL); *work = i; *scope = i; } ++ p_sorter; } //割当表作成 if(node->size() != 0 && VerboseMessage::getVerbose()) { VerboseMessage("Object ID assignment list [%]\n","オブジェクトID割付表 [%]\n") << category; sorter.clear(); scope = node->getFirstChild(); while(scope != 0) { sorter[scope->toInteger()] = scope; scope = scope->getNext(); } p_sorter = sorter.begin(); while(p_sorter != sorter.end()) { VerboseMessage(" % : %\n") << setw(3) << (*p_sorter).first << (*p_sorter).second->getKey(); ++ p_sorter; } } //妥当性の判定 if((signed)node->size()+1 != *(idpool.begin())) ExceptionMessage("Discontinuous % ID assignment occured","不連続なオブジェクトID(%)") << category << throwException; return node->size(); }