int ClusterHop(SNarray snA, Charge one, int * totalX){ printf("Hopping to cluster\n"); //flag is 0 if charge moves and 1 if charge stays put int flag = 0; //initially, the flag is set as 0 - can hop, 1 is can not hop //flag is used to determine if charges can hop to sites outside //of the cluster. int flag1 = 0; //flag2 accounts for availability within the cluster. int flag2 = 0; int rv; int ID, NewID; long double sum=0.0; double pvalHigh; double pval; int i, j, k; int i1, j1, k1; double position2; double position; double time; long double sum2=0.0; SiteNode sn; ID=getIndex(snA, getCx(one), getCy(one), getCz(one)); NewID=ID; //Check to see if there are sites adjacent to the cluster that are //open rv = OccAllNeiCluster(snA, getCx(one), getCy(one), getCz(one)); if (rv==1){ //there is no possibility for hopping outside the cluster as all the neighbouring sites //around the first charge position are all occuppied and the cluster //does not sit next to an electrode printf("Hopping outside Cluster Not permitted\n"); flag1 = 1; } rv = OccAllCluster( snA, getCx(one), getCy(one), getCz(one)); if(rv==1) { //This means hopping within the cluster is not permitted printf("Hopping Within Cluster Not permitted\n"); flag2 = 1; //But hopping outside may be allowed; if(flag1!=1){ getNeighClusterPvalHigh( snA, getCx(one), getCy(one), getCz(one), &pvalHigh, &sum); //pval=pvalHigh*2; sn = getSN(snA, getCx(one), getCy(one), getCz(one)); setp(sn, 0, 0.0, 4); //Don't add to sum because hopping within cluster is not allowed //Can't stay where it is. hopping within the cluster is not allowed //so pval for the cluster is 0.0 } //what happens if can't hop on or off? }else{ double pvalLow; //Hopping within the cluster is allowed must account for this in the sum getClusterPvalLow( snA, getCx(one), getCy(one), getCz(one), &pvalLow, &sum2); assert(pvalLow>0.000000000000000000000000000000000000000000000000000000000000000000000000000000000001); if (flag1!=1){ //Grabbing the fastest hop rate off the cluster getNeighClusterPvalHigh( snA, getCx(one), getCy(one), getCz(one), &pvalHigh, &sum); assert(pvalHigh>0.000000000000000000000000000000000000000000000000000000000000000000000000000000000001); sn = getSN(snA, getCx(one), getCy(one), getCz(one)); time=getTimeCluster( (ClusterLL) getList(sn)); assert(time<1/pvalHigh); //if(pvalLow<pvalHigh*2){ // pval=pvalLow; setp(sn, 0, , 4); //}else{ // pval=pvalHigh*2; // setp(sn, 0, pval, 4); //} }else {
void ManagerArbre::modify(const Arbre & node) { Arbre nodeBdd(node.id()); get(nodeBdd); int idParentBdd = nodeBdd.parent(); int numBdd = nodeBdd.num(); if(node.parent()) { if(nodeBdd.parent() == node.parent()) { int max = fonctionAgrega<int>(bdd::Agrega::Max,Arbre::Num,Arbre::Parent,node.parent()); int num = node.num(); if(num < 0 || num > max) num = max; if(numBdd != num) { nodeBdd.setNum(-numBdd); ManagerSqlArbre::modify(nodeBdd); if(std::abs(numBdd - num) == 1) { Arbre nodeSuivant(num,node.parent()); getUnique(nodeSuivant); nodeSuivant.setNum(numBdd); ManagerSqlArbre::modify(nodeSuivant); } else if(num < numBdd) { ListPtr<Arbre> nodes(getList(Arbre::Parent,node.parent(),Arbre::Num,num,Arbre::Num,numBdd, Arbre::Num,bdd::Condition::Egal,bdd::Condition::SupEgal,bdd::Condition::Inf,false)); for(ListPtr<Arbre>::iterator i = nodes.begin(); i != nodes.end(); ++i) { (*i).setNum((*i).num() + 1); ManagerSqlArbre::modify((*i)); } } else { ListPtr<Arbre> nodes(getList(Arbre::Parent,node.parent(),Arbre::Num,numBdd,Arbre::Num,num, Arbre::Num,bdd::Condition::Egal,bdd::Condition::Sup,bdd::Condition::InfEgal)); for(ListPtr<Arbre>::iterator i = nodes.begin(); i != nodes.end(); ++i) { (*i).setNum((*i).num() - 1); ManagerSqlArbre::modify((*i)); } } nodeBdd.setNum(num); } } else { nodeBdd.setParent(node.parent()); Arbre parent(nodeBdd.parent()); get(parent); if(parent.feuille()) { parent.setFeuille(false); ManagerSqlArbre::modify(parent); nodeBdd.setNum(0); } else { int max = fonctionAgrega<int>(bdd::Agrega::Max,Arbre::Num,Arbre::Parent,node.parent()); if(node.num() < 0 || node.num() > max) nodeBdd.setNum(max + 1); else { ListPtr<Arbre> nodes(getList(Arbre::Parent,node.parent(),Arbre::Num,node.num(), Arbre::Num,bdd::Condition::Egal,bdd::Condition::SupEgal,false)); for(ListPtr<Arbre>::iterator i = nodes.begin(); i != nodes.end(); ++i) { (*i).setNum((*i).num() + 1); ManagerSqlArbre::modify((*i)); } nodeBdd.setNum(node.num()); } } } ManagerSqlArbre::modify(nodeBdd); } else { nodeBdd.setParent(0); nodeBdd.setNum(0); ManagerSqlArbre::modify(nodeBdd); } if(idParentBdd != 0 && idParentBdd != nodeBdd.parent()) { if(exists(Arbre::Parent,idParentBdd)) { ListPtr<Arbre> nodes(getList(Arbre::Parent,idParentBdd,Arbre::Num,numBdd,Arbre::Num,bdd::Condition::Egal,bdd::Condition::Sup)); for(ListPtr<Arbre>::iterator i = nodes.begin(); i != nodes.end(); ++i) { (*i).setNum((*i).num() - 1); ManagerSqlArbre::modify((*i)); } } else { Arbre parent(idParentBdd); get(parent); parent.setFeuille(true); ManagerSqlArbre::modify(parent); } } }
int MessageListScript::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = MessageList::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QColor*>(_v) = criColor(); break; case 1: *reinterpret_cast< QColor*>(_v) = attColor(); break; case 2: *reinterpret_cast< QColor*>(_v) = normColor(); break; case 3: *reinterpret_cast< QColor*>(_v) = backColor(); break; case 4: *reinterpret_cast< vtlmeta::types::NamedList*>(_v) = getList(); break; case 5: *reinterpret_cast< QString*>(_v) = sourcerName(); break; case 6: *reinterpret_cast< QString*>(_v) = toolTip(); break; case 7: *reinterpret_cast< VISIBLE*>(_v) = getVisible(); break; case 8: *reinterpret_cast< bool*>(_v) = useMask(); break; case 9: *reinterpret_cast< QString*>(_v) = globalListName(); break; case 10: *reinterpret_cast< QFont*>(_v) = font(); break; case 11: *reinterpret_cast< QRect*>(_v) = geometry(); break; case 12: *reinterpret_cast< Shape*>(_v) = frameShape(); break; case 13: *reinterpret_cast< Shadow*>(_v) = frameShadow(); break; case 14: *reinterpret_cast< int*>(_v) = lineWidth(); break; case 15: *reinterpret_cast< int*>(_v) = midLineWidth(); break; case 16: *reinterpret_cast< int*>(_v) = margin(); break; case 17: *reinterpret_cast< vtlmeta::types::NamedList*>(_v) = getFuncList(); break; } _id -= 18; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setCriColor(*reinterpret_cast< QColor*>(_v)); break; case 1: setAttColor(*reinterpret_cast< QColor*>(_v)); break; case 2: setNormColor(*reinterpret_cast< QColor*>(_v)); break; case 3: setBackColor(*reinterpret_cast< QColor*>(_v)); break; case 4: setList(*reinterpret_cast< vtlmeta::types::NamedList*>(_v)); break; case 5: setSourcerName(*reinterpret_cast< QString*>(_v)); break; case 6: setToolTip(*reinterpret_cast< QString*>(_v)); break; case 7: setVisible(*reinterpret_cast< VISIBLE*>(_v)); break; case 8: setUseMask(*reinterpret_cast< bool*>(_v)); break; case 9: setGlobalListName(*reinterpret_cast< QString*>(_v)); break; case 10: setFont(*reinterpret_cast< QFont*>(_v)); break; case 11: setGeometry(*reinterpret_cast< QRect*>(_v)); break; case 12: setFrameShape(*reinterpret_cast< Shape*>(_v)); break; case 13: setFrameShadow(*reinterpret_cast< Shadow*>(_v)); break; case 14: setLineWidth(*reinterpret_cast< int*>(_v)); break; case 15: setMidLineWidth(*reinterpret_cast< int*>(_v)); break; case 16: setMargin(*reinterpret_cast< int*>(_v)); break; case 17: setFuncList(*reinterpret_cast< vtlmeta::types::NamedList*>(_v)); break; } _id -= 18; } else if (_c == QMetaObject::ResetProperty) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 18; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 18; } #endif // QT_NO_PROPERTIES return _id; }
void detach2() { getList().at(0); // OK }
CDECL void IDXL_Get_list(IDXL_Side_t s,int partnerNo,int *list) { getList(s,partnerNo,list,0); }
void ChoiceTable::TreeList(int input_vertex, int reference_vertex, TreeGraphPtr T1, TreeGraphPtr T2, MatchRecordList& sequence){ if ((!T1->isNull())&&(!T2->isNull())) { ChoiceList* L=getList(input_vertex,reference_vertex); int tree_choice=L->front(); switch(tree_choice) { case 1: { TreeList(Lat(L,1),reference_vertex,T1,T2,sequence); } break; case 2: { TreeList(input_vertex,Lat(L,1),T1,T2,sequence); } break; case 3: { sequence.push_back(MatchRecord(input_vertex,reference_vertex)); ForestList(input_vertex,reference_vertex,T1,T2,sequence); } break; case 4: { int size = Lat(L,1); int nbChoices = L->size(); /* Fred temptative of fix: The actual list of id of matched elements seems to be the n last value of the choice list. */ int input_vertex; for (int i=0;i<size;i++){ input_vertex = Lat(L,nbChoices-size+i); sequence.push_back(MatchRecord(input_vertex,reference_vertex)); } // question : is input_vertex to continue the fist or the last of the list. I choose the first input_vertex = Lat(L,nbChoices-size); ForestList(input_vertex,reference_vertex,T1,T2,sequence); } break; case 5: { int size = Lat(L,1); int nbChoices = L->size(); /* Fred temptative of fix: The actual list of id of matched elements seems to be the n last value of the choice list. */ int reference_vertex; for (int i=0;i<size;i++){ reference_vertex = Lat(L,nbChoices-size+i); sequence.push_back(MatchRecord(input_vertex,reference_vertex)); } // question : is reference_vertex to continue the fist or the last of the list. I choose the first reference_vertex = Lat(L,nbChoices-size); ForestList(input_vertex,reference_vertex,T1,T2,sequence); } break; default : break; } } }
const char * UResPoly::print(const char * preString, char * buff, int buffCnt) { // print status for resource (short 1-3 lines of text followed by a line feed (\n) // getList(preString, buff, buffCnt); return buff; }
vector<Computer> ComputerData::getList(string sortOrder) { QSqlQuery query(base); getList(query, sortOrder); return list; }
/** * Funçao irá adicionar notação para colisão de pecas entre peças do vetor * DESCRIÇÃO: * Função irá criar vetores auxiliares correspondentes a coleção. Através do looping será feito * busca por jogadas iguais e com o uso de vetor de índices serão avaliadas sempre as jogadas mais * baixas de cada lista, para que não haja perda de análise, ou seja, o índice irá avançar sempre * que ela foi menor ou igual em relação as jogadas de outras peças. * * PARAMETROS: * OBJETO ** const collection - vetor de objetos * int size - tamanho do vetor * * * RETORNO: * VOID */ void _conflict (OBJETO ** const collection, int size) { if(collection != NULL && size > 0) { char** piecesList[size]; int indexList [size]; int count[size]; //pegas as listas de movimentos possíveis de cada peça int i; for(i = 0; i < size; i++) { piecesList[i] = getList (collection[i]); indexList[i] = 0; count[i] = getNList (collection[i]); } int cmd_size = INT_MAX; int ini = 0, end = ini; CONFLICT cmd[size]; //fazer busca-comparação até que todos os índices de vetores cheguem ao fim while(ini < cmd_size) { cmd_size = 0; //compor vetor com jogadas do mesmo tipo de peça com os menores valores for(i = 0; i < size; i++) { if(indexList[i] < count[i]) { cmd[cmd_size].play = &(piecesList[i][indexList[i]]); cmd[cmd_size].obj = collection[i]; cmd[cmd_size].order = i; cmd_size++; } } //ordenar segundo crierio de desempate proposto (coluna e linha) qsort(cmd, cmd_size, sizeof(CONFLICT), &sortPlayConflict); //achar indice da lista a ser avançada, sendo sempre a jogada de menor valor (segundo critério de desempate) for(i = 0; i < cmd_size && indexList[cmd[i].order] >= count[cmd[i].order]; i++); //verificar se todas as jogadas ja' não foram verificadas if(i >= cmd_size) break; ini = i; end = ini; char *typeCmd = *(cmd[ini].play); //caso jogadas anteriormente iguais cair na comparação já terão sido distinguidos por notação e serão diferentes while(end < cmd_size && !strcmp(typeCmd, *(cmd[end].play))) { //avançar com os índices com os menores valores de desempate indexList[cmd[end++].order]++; } addConflictNotation (cmd, ini, end - 1); }//while least < size }//if collection != NULL size > 0 }
bool LayerMapGds::parseLayTypeString(wxString exp, word tdtLay) { wxString lay_exp, type_exp; if (!separateQuickLists(exp, lay_exp, type_exp)) return false; WordList llst; // get the listed layers getList( lay_exp , llst); if (NULL != _alist) {// GDS to TDT conversion // ... for every listed layer for ( WordList::const_iterator CL = llst.begin(); CL != llst.end(); CL++ ) { // if the layer is listed among the GDS used layers if ( _alist->end() != _alist->find(*CL) ) { if (wxT('*') == type_exp) { // for all data types // get all GDS data types for the current layer and copy them // to the map for ( WordList::const_iterator CT = (*_alist)[*CL].begin(); CT != (*_alist)[*CL].end(); CT++) _theMap[*CL].insert(std::make_pair(*CT, tdtLay)); } else {// for particular (listed) data type WordList dtlst; getList( type_exp , dtlst); for ( WordList::const_iterator CT = dtlst.begin(); CT != dtlst.end(); CT++) _theMap[*CL].insert(std::make_pair(*CT, tdtLay)); } } // else ignore the mapped GDS layer } } else {// TDT to GDS conversion if (1 < llst.size()) { wxString wxmsg; wxmsg << wxT("Can't export to multiple layers. Expression \"") << lay_exp << wxT("\"") << wxT(" is coerced to a single layer ") << llst.front(); std::string msg(wxmsg.mb_str(wxConvUTF8)); tell_log(console::MT_ERROR,msg); } if (wxT('*') == type_exp) { // for all data types - same as data type = 0 _theMap[tdtLay].insert(std::make_pair(0, llst.front())); } else {// for particular (listed) data type WordList dtlst; getList( type_exp , dtlst); if (1 < dtlst.size()) { wxString wxmsg; wxmsg << wxT("Can't export to multiple types. Expression \"") << type_exp << wxT("\"") << wxT(" for layer ") << tdtLay << wxT(" is coerced to a single data type ") << dtlst.front(); std::string msg(wxmsg.mb_str(wxConvUTF8)); tell_log(console::MT_ERROR,msg); } _theMap[tdtLay].insert(std::make_pair(dtlst.front(), llst.front())); } } return true; }
std::list<Variant> ProtoMessage::getList(const int32_t& key) { std::list<Variant> result; getList(result, key); return result; }
void BackendsListWidget::resetOrder() { originalOrder = getList(); }
bool BackendsListWidget::changed() { return originalOrder != getList(); }
/** * Adds a variadic log-message to the message-list for the current thread. * * This function is thread-safe. * * @retval 0 Success * @retval EAGAIN Failure due to the buffer being too small for the * message. The buffer has been expanded and the client * should call this function again. * @retval EINVAL There are insufficient arguments. Error message logged. * @retval EILSEQ A wide-character code that doesn't correspond to a * valid character has been detected. Error message logged. * @retval ENOMEM Out-of-memory. Error message logged. * @retval EOVERFLOW The length of the message is greater than {INT_MAX}. * Error message logged. */ int nplVadd( const char* const fmt, /**< The message format or NULL for no message */ va_list args) /**< The arguments referenced by the format. */ { int status = 0; /* default success */ if (NULL != fmt) { List* list = getList(); if (NULL != list) { Message* msg = (NULL == list->last) ? list->first : list->last->next; status = 0; if (msg == NULL) { msg = (Message*)malloc(sizeof(Message)); if (msg == NULL) { status = errno; lock(); serror("nplVadd(): malloc(%lu) failure", (unsigned long)sizeof(Message)); unlock(); } else { char* string = (char*)malloc(DEFAULT_STRING_SIZE); if (NULL == string) { status = errno; lock(); serror("nplVadd(): malloc(%lu) failure", (unsigned long)DEFAULT_STRING_SIZE); unlock(); } else { msg->string = string; msg->size = DEFAULT_STRING_SIZE; msg->next = NULL; if (NULL == list->first) list->first = msg; /* very first message */ } } } if (0 == status) { int nbytes = vsnprintf(msg->string, msg->size, fmt, args); if (0 > nbytes) { status = errno; lock(); serror("nplVadd(): vsnprintf() failure"); unlock(); } else if (msg->size <= nbytes) { /* The buffer is too small for the message */ size_t size = nbytes + 1; char* string = (char*)malloc(size); if (NULL == string) { status = errno; lock(); serror("nplVadd(): malloc(%lu) failure", (unsigned long)size); unlock(); } else { free(msg->string); msg->string = string; msg->size = size; status = EAGAIN; } } else { if (NULL != list->last) list->last->next = msg; list->last = msg; } } /* have a message structure */ } /* message-list isn't NULL */ } /* arguments aren't NULL */ return status; }
void FormSetup::showEvent(QShowEvent*) { f1.ui.opcjeButton->setChecked(true); getList(); }
void Server::createParam(const std::string & ns, tinyxml2::XMLHandle & tmp_handle) { std::string name = ns + "/" + tmp_handle.ToElement()->Name(); std::string type = tmp_handle.ToElement()->Attribute("type"); if (type.compare("int") == 0) { double dou; getDouble(*tmp_handle.FirstChildElement("default").ToElement(), dou); std_msgs::Int64 val; val.data = dou; params_[name] = boost::shared_ptr<std_msgs::Int64>( new std_msgs::Int64(val)); } else if (type.compare("double") == 0) { double dou; getDouble(*tmp_handle.FirstChildElement("default").ToElement(), dou); std_msgs::Float64 val; val.data = dou; params_[name] = boost::shared_ptr<std_msgs::Float64>( new std_msgs::Float64(val)); } else if (type.compare("vector") == 0) { exotica::Vector vec; getStdVector(*tmp_handle.FirstChildElement("default").ToElement(), vec.data); params_[name] = boost::shared_ptr<exotica::Vector>( new exotica::Vector(vec)); } else if (type.compare("bool") == 0) { bool val; getBool(*tmp_handle.FirstChildElement("default").ToElement(), val); std_msgs::Bool ros_bool; ros_bool.data = val; params_[name] = boost::shared_ptr<std_msgs::Bool>( new std_msgs::Bool(ros_bool)); } else if (type.compare("boollist") == 0) { exotica::BoolList boollist; std::vector<bool> vec; getBoolVector(*tmp_handle.FirstChildElement("default").ToElement(), vec); boollist.data.resize(vec.size()); for (int i = 0; i < vec.size(); i++) boollist.data[i] = vec[i]; params_[name] = boost::shared_ptr<exotica::BoolList>( new exotica::BoolList(boollist)); } else if (type.compare("string") == 0) { std::string str = tmp_handle.FirstChildElement("default").ToElement()->GetText(); if (str.size() == 0) { throw_pretty("Invalid string!"); } std_msgs::String ros_s; ros_s.data = tmp_handle.FirstChildElement("default").ToElement()->GetText(); params_[name] = boost::shared_ptr<std_msgs::String>( new std_msgs::String(ros_s)); } else if (type.compare("stringlist") == 0) { exotica::StringList list; getList(*tmp_handle.FirstChildElement("default").ToElement(), list.strings); params_[name] = boost::shared_ptr<exotica::StringList>( new exotica::StringList(list)); } else { throw_pretty("Unknown type!"); } INFO("Register new paramter "<<name) }
int main ( int argc, char * argv[ ] ) { int sock, nuSock; // This will be our sockets int nbytes; // Number of bytes we receive in our message int code; // Error code for Select char buffer[ MAXBUFSIZE ]; // A buffer to store our received message char msg[ MAXBUFSIZE ]; // A Message to return Repository repo; // The registration list fd_set fds; struct timeval timeout; int count = 0; // // Make sure port is given on command line // if ( argc != 2 ) { printf( "USAGE: <port>\n" ); exit( EXIT_FAILURE ); } // // Initialize all the things! // repo.total = 0; maxPrint( &repo ); sock = createSocket( atoi( argv[1] ) ); timeout.tv_sec = 2; timeout.tv_usec = 0; FD_ZERO( &fds ); FD_SET( sock, &fds ); nuSock = acceptConnection( sock ); ERROR( nuSock < 0 ); FD_SET( nuSock, &fds ); // // Enter command loop // for ( ; ; ) { /* if ( ( code = select( sizeof( fds )*8, &fds, NULL, NULL, &timeout ) ) < 0 ) { ERROR( code < 0 ); } else if ( code == 0 ) { printf( "$ Timeout [%i]\r", count = ++count % 100 ); ERROR( count ); } else { count = 0; if ( FD_ISSET( sock, &fds ) ) { // Loop through all the conenctions Available while ( ( nuSock = acceptConnection( sock ) ) > 0 ); FD_SET( nuSock, &fds ); } */ ERROR( nuSock < 0 ); bzero( buffer, MAXBUFSIZE ); nbytes = read( nuSock, buffer, MAXBUFSIZE ); ERROR( nbytes < 0 ); printf( "[%s] %s\n", repo.cxn[whoisthis( &repo, nuSock )].name, buffer ); switch ( parseCmd ( buffer ) ) { case CONNECT: { nbytes = write( nuSock, buffer, MAXBUFSIZE ); ERROR( nbytes < 0 ); switch( registerClient( &repo, nuSock ) ) { case SUCCESS: getList ( &repo, nuSock ); printf( "> Success in registering '%s'\n", repo.cxn[repo.total-1].name ); break; case FAILURE: printf( "> Error in registration\n" ); break; } break; } case GET: sendMaster( &repo, nuSock ); break; case EXIT: { switch( removeClient( &repo, nuSock ) ) { case SUCCESS: printf( "> Client has been removed.\n" ); break; case FAILURE: printf( "> Error removing client.\n" ); break; } break; } default: sprintf( msg, "Invalid command: '%s'", buffer); nbytes = write( nuSock, msg, MAXBUFSIZE ); ERROR( nbytes < 0 ); break; } } close( nuSock ); close( sock ); return EXIT_SUCCESS; } // main( )
/** * {@inheritDoc} */ void remove(ListPerson* element) { if (element == NULL) { cout << "The given element is null " << endl; } ListPerson* rootElement = getList(); // if element is the first one of the list check for follower. // if it has a follower delete element and set pointer to follower, otherwise set pointer = NULL if (element == rootElement) { ListPerson* nextOne = NULL; if (element->next != NULL) { nextOne = element->next; } Person* personToDelete = element->data; outputPerson(personToDelete); delete[] personToDelete->firstname; delete[] personToDelete->name; delete personToDelete; personToDelete = NULL; element->next = NULL; delete element; // There is no need and no chance to delete sex, deparment and birth because there is no extra memory allocated for. // These elements just exist whithin the person struct and should be freed automatically when deleting the person. if (nextOne != NULL) { rootElement = NULL; personList = nextOne; } else { rootElement = NULL; personList = NULL; // important, if the list is empty set the base pointer to null. } } else { // if it is not the first element, search in the list for matches. // Remember the predecessor bool done = false; ListPerson* currentElement = rootElement; while (!done) { ListPerson* predecessor = currentElement; currentElement = currentElement->next; if (element == currentElement) { // delete element and attach follwing element to predecessor. predecessor->next = currentElement->next; Person* personToDelete = currentElement->data; outputPerson(personToDelete); delete[] personToDelete->firstname; delete[] personToDelete->name; delete personToDelete; personToDelete = NULL; currentElement->next = NULL; delete element; delete currentElement; currentElement = NULL; // link current element pointer to null done = true; } else { if (currentElement->next == NULL) { // end when the end of the list has been reached. done = true; } } } } }
bool LH_HWiNFOData::getData(float& value, QString& text, QString& units) { #ifdef Q_WS_WIN const char* mapname = HWiNFO_SENSORS_MAP_FILE_NAME; float resultVal = true; // Create file mapping HANDLE filemap = OpenFileMappingA(FILE_MAP_READ, FALSE, mapname); // Get pointer if(filemap != NULL) { _HWiNFO_SENSORS_SHARED_MEM* hwinfoMemory = (_HWiNFO_SENSORS_SHARED_MEM*)MapViewOfFile(filemap, FILE_MAP_READ, 0, 0, sizeof(_HWiNFO_SENSORS_SHARED_MEM)); if (hwinfoMemory) { if(hwinfoMemory->header.dwVersion!=3) { qWarning() << "LH_Monitoring: HWiNFO version is incompatible."; return false; } if (ui_->count(mon_type) == 0) loadTypesList(hwinfoMemory); if(ui_->value(mon_type)!=-1) { if (ui_->value(mon_type) != listedType_) { listedType_ = ui_->value(mon_type); listedGroup_ = -1; loadGroupsList(hwinfoMemory); } if(ui_->value(mon_group)!=-1) { int max = -1; HWiNFO_SENSORS_READING_LIST *list = getList(hwinfoMemory->Sensors[sensor_indexes_.value(ui_->value(mon_group))], max); if (ui_->value(mon_group) != listedGroup_) { listedGroup_ = ui_->value(mon_group); loadItemsList(list, max); } getSelectedValue(list, value, text, units); } else resultVal = false; } else resultVal = false; UnmapViewOfFile(hwinfoMemory); } else resultVal = false; CloseHandle(filemap); } else resultVal = false; return resultVal; #else Q_UNUSED(value); Q_UNUSED(text); Q_UNUSED(units); return false; #endif }
int xml_main(int argc, char **argv) { char *serversoft = getenv ("SERVER_SOFTWARE"); LOG_SERVER_SOFT; LOG_NODE_NAME; char c = '0'; char p[] = "/dev/in"; int fd; int iOptindexer = 1; int bIndexerReady = 0; if (Mode != single_operation) bIndexerReady = checkIndexer(); else bIndexerReady = 1; int bDeleteFromIndex = 0; int bTemplateIndex = 0; int bSaveXML = 0; int i = 0; char deviceoutputname[250]; sprintf (deviceoutputname, "%s", DEV_OUTPUT_NAME); for ( i = 0; i < argc; i++) { if ((strncmp(argv[i], "--savexml", strlen (argv[i]))) == 0) bSaveXML = 1; if ((strncmp(argv[i], "--delete", strlen (argv[i]))) == 0) bDeleteFromIndex = 1; if ((strncmp(argv[i], "--template", strlen (argv[i]))) == 0) bTemplateIndex = 1; } if (bSaveXML == 1) sprintf (deviceoutputname, "/dev/output"); else if (bIndexerReady != 1) { printf ("***Error indexer not ready\n"); return 1; } if (Mode == single_operation) sprintf (deviceoutputname, "%s", XML_SINGLE_MODE_OUTPUT_FILE); else if(bDeleteFromIndex == 0) LOG_ZVM ("***ZVMLog", "incoming channels dir", "s", p, 1); LOG_ZVM ("***ZVMLog", "output channel name", "s", deviceoutputname, 1); fd = open (deviceoutputname, O_WRONLY | O_CREAT | O_TRUNC, S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR); if (fd <= 0) { printf ("*** ZVM. Error open %s deivce\n", DEV_OUTPUT_NAME); return 1; } struct field_list fl = getList ("/dev/input"); LOG_ZVM ("***ZVMLog", "doc count", "d", docID, 1); createxmlpipe (fd, fl); if (bDeleteFromIndex == 0 && bTemplateIndex == 0) { LOG_ZVM ("***ZVMLog", "incoming channels dir", "s", deviceoutputname, 1); int doccount = 0; if (Mode == single_operation) doccount = getdatafromchannel (fd, EXTRACTOR_SINGLE_MODE_OUTPUT_FILE, docID, fl); else mylistdir_xmlpipe (fd, p, fl); } else if ((bDeleteFromIndex == 1 && bTemplateIndex == 0)) { LOG_ZVM ("***ZVMLog", "incoming channels dir", "s", p, 1); SendDelete (fd, fl); } else if ((bDeleteFromIndex == 0 && bTemplateIndex == 1)) { /* LOG_ZVM ("***ZVMLog", "incoming channels dir", "s", p, 1); SendDelete (fd); */ } closexmlpipe (fd); close (fd); printf ("*** ZVM xmlpipe - OK\n"); return 0; }
void detach1() { getList().first(); // Warning }
const GFFList &GFFStruct::getList(const Common::UString &field) const { uint32 size; return getList(field, size); }
static CMPIEnumeration* mbReferences( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char *resultClass, const char *role , const char **properties, CMPIStatus *rc) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbReferences()"); mb = CM_BROKER; // ATTN-CAKG-P2-20020726: The following condition does not correctly // distinguish instanceNames from classNames in every case // The instanceName of a singleton instance of a keyless class has no // key bindings if (!SCMO_ObjectPath(cop)->getKeyBindingCount()) { CMSetStatus(rc, CMPI_RC_ERR_FAILED); PEG_METHOD_EXIT(); return 0; } CMPIFlags flgs = ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; CIMPropertyList props = getList(properties); SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; try { scmoObjPath->getCIMObjectPath(qop); // For compatibility with previous implementations have empty ns qop.setNameSpace(CIMNamespaceName()); CIMResponseData resData = CM_CIMOM(mb)->references( *CM_Context(ctx), scmoObjPath->getNameSpace(), qop, resultClass ? CIMName(resultClass) : CIMName(), role ? String(role) : String::EMPTY, CM_IncludeQualifiers(flgs), CM_ClassOrigin(flgs), props); CMSetStatus(rc,CMPI_RC_OK); // Add the namespace from the input parameters when neccessary resData.completeNamespace(scmoObjPath); Array<SCMOInstance>* aObj = new Array<SCMOInstance>(resData.getSCMO()); CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>( new CMPI_Object(new CMPI_ObjEnumeration(aObj))); PEG_METHOD_EXIT(); return cmpiEnum; } HandlerCatchSetStatus(rc, NULL); // Code flow should never get here. }
void Settings::append(const QString& key, const QStringList& values) { QStringList l = getList(key, QStringList()); l.append(values); set(key, l); }
FDECL void FTN_NAME(IDXL_GET_LIST,idxl_get_list) (int *s,int *p,int *list) { getList(*s,*p-1,list,1); }
void glDisable( GLenum cap ) { CHECK_NULL(g_state); #ifndef DISABLE_LISTS if (g_state->withinNewEndListBlock && g_state->displayListCallDepth == 0) { gfx_command comm; comm.type = gfx_command::DISABLE; comm.enum1 = cap; getList(g_state->currentDisplayList)->commands.push_back(comm); } CHECK_COMPILE_AND_EXECUTE(g_state); #endif CHECK_WITHIN_BEGIN_END(); switch(cap) { case (GL_TEXTURE_2D): { g_state->enableTexture2D = GL_FALSE; } break; case (GL_DEPTH_TEST): { g_state->enableDepthTest = GL_FALSE; } break; case (GL_BLEND): { g_state->enableBlend = GL_FALSE; } break; case (GL_SCISSOR_TEST): { g_state->enableScissorTest = GL_FALSE; } break; case (GL_LIGHTING): { g_state->enableLighting = GL_FALSE; } break; case (GL_LIGHT0): case (GL_LIGHT1): case (GL_LIGHT2): case (GL_LIGHT3): case (GL_LIGHT4): case (GL_LIGHT5): case (GL_LIGHT6): case (GL_LIGHT7): { g_state->enableLight[GL_LIGHT0 - cap] = GL_FALSE; } break; case (GL_ALPHA_TEST): { g_state->enableAlphaTest = GL_FALSE; } break; case (GL_STENCIL_TEST): { g_state->enableStencilTest = GL_FALSE; } break; #ifndef DISABLE_ERRORS default: { setError(GL_INVALID_ENUM); return; } #endif } }
/** * Returns the index of the most recently saved savegame. This will always be * the file at the first index, since the list is sorted by date/time */ int NewestSavedGame() { int numFiles = getList(); return (numFiles == 0) ? -1 : 0; }
void FormSetup::lpB() { Func.loadPlugins(); getList(); }
///0:成功;-1:失败 int UnistorHandler4Recv::recvMessage() { int ret = 0; bool bUnpack=false; ///<是否unpack了消息报 do{ if (!m_recvMsgData){///一个空包 ret = UNISTOR_ERR_ERROR; strcpy(m_tss->m_szBuf2K, "msg is empty."); break; } if (!m_bAuth){ if (!m_tss->m_pReader->unpack(m_recvMsgData->rd_ptr(), m_recvMsgData->length(), false)){ ret = UNISTOR_ERR_ERROR; strcpy(m_tss->m_szBuf2K, m_tss->m_pReader->getErrMsg()); break; } if (!checkAuth(m_tss)){ ret = UNISTOR_ERR_ERROR; break; } bUnpack = true; } if ((m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_ADD)|| (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_SET) || (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_UPDATE)|| (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_INC)|| (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_IMPORT)|| (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_DEL)) {///如果是写请求 if (m_pApp->getRecvWriteHandler()->isCanWrite()){ if (m_pApp->getWriteTheadPool()->getQueuedMsgNum() > m_pApp->getConfig().getCommon().m_uiMaxWriteQueueNum){ ret = UNISTOR_ERR_TOO_MANY_WRITE; CwxCommon::snprintf(m_tss->m_szBuf2K, 2047, "Too many message in write queue, max:%u", m_pApp->getConfig().getCommon().m_uiMaxWriteQueueNum); break; } if (!bUnpack){ if (!m_tss->m_pReader->unpack(m_recvMsgData->rd_ptr(), m_recvMsgData->length(), false)){ ret = UNISTOR_ERR_ERROR; strcpy(m_tss->m_szBuf2K, m_tss->m_pReader->getErrMsg()); break; } } if (UNISTOR_ERR_SUCCESS != (ret = relayWriteThread())) break; return 0; }else if (UnistorHandler4Trans::m_bCanTrans){///转发给master if (m_pApp->getTaskBoard().getTaskNum() > m_pApp->getConfig().getCommon().m_uiMaxMasterTranMsgNum){ ret = UNISTOR_ERR_TOO_MANY_TRANS; CwxCommon::snprintf(m_tss->m_szBuf2K, 2047, "Too many message for trans to master, max:%u", m_pApp->getConfig().getCommon().m_uiMaxMasterTranMsgNum); }else{ relayTransThread(m_recvMsgData); m_recvMsgData = NULL; return 0; } }else{ ret = UNISTOR_ERR_NO_MASTER; strcpy(m_tss->m_szBuf2K, "No master."); break; } }else{ if (UnistorPoco::isFromMaster(m_header.getAttr())){ if (m_tss->isMasterIdc()){///是master idc if (!m_tss->isMaster()){///自己不是master if (UnistorHandler4Trans::m_bCanTrans){ relayTransThread(m_recvMsgData); m_recvMsgData = NULL; return 0; } ret = UNISTOR_ERR_NO_MASTER; strcpy(m_tss->m_szBuf2K, "No master."); break; } ///若自己是master,则查询数据 }else{ ret = UNISTOR_ERR_NO_MASTER; strcpy(m_tss->m_szBuf2K, "No master."); break; } } if (!bUnpack){ if (!m_tss->m_pReader->unpack(m_recvMsgData->rd_ptr(), m_recvMsgData->length(), false)){ ret = UNISTOR_ERR_ERROR; strcpy(m_tss->m_szBuf2K, m_tss->m_pReader->getErrMsg()); break; } } if (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_GET){ ret = getKv(m_tss); if (UNISTOR_ERR_SUCCESS == ret) return 0;///已经回复 }else if (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_GETS){ ret = getKvs(m_tss); if (UNISTOR_ERR_SUCCESS == ret) return 0;///已经回复 }else if (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_LIST){ ret = getList(m_tss); if (UNISTOR_ERR_SUCCESS == ret) return 0;///已经回复 }else if (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_EXIST){ ret = existKv(m_tss); if (UNISTOR_ERR_SUCCESS == ret) return 0;///已经回复 }else if (m_header.getMsgType() == UnistorPoco::MSG_TYPE_RECV_AUTH){ ret = UNISTOR_ERR_SUCCESS; }else{ ret = UNISTOR_ERR_ERROR; CwxCommon::snprintf(m_tss->m_szBuf2K, 2047, "Invalid msg type:%d", m_header.getMsgType()); return -1; ///无效消息类型,直接关闭连接 } } }while(0); CwxMsgBlock* msg = packReplyMsg(m_tss, m_header.getTaskId(), m_header.getMsgType()+1, ret, 0, 0, m_tss->m_szBuf2K); if (!msg) return -1; ///关闭连接 return reply(msg, false); }
ListIterator<FlashCard> DividedFlashCardList :: cut_front(ListIterator<FlashCard> it, List<FlashCard> & other, const CardList & cl) { return other.prepend_to(it, getList(cl)); }