void setId(Util::Reference<Obj> obj,const Util::StringIdentifier & id){ if(!id.empty()) // remove a obj possibly previously registered with the id removeId( id ); if(obj.isNotNull()) // remove the obj's old id removeId( obj.get() ); if(obj.isNotNull()&&!id.empty()){ // register the obj using the new id map_objToId.emplace(obj.get(),id); map_idToObj.emplace(id, std::move(obj)); } }
void Account::setName(const QString& name) { if (findAccount() == this) { removeId(); } m_name = name; insertId(); changed(); }
Account::~Account() { //kDebug(planDbg())<<m_name; if (findAccount() == this) { removeId(); // only remove myself (I may be just a working copy) } if (m_list) m_list->accountDeleted(this); while (!m_accountList.isEmpty()) delete m_accountList.takeFirst(); while (!m_costPlaces.isEmpty()) delete m_costPlaces.takeFirst(); }
// SK // ---------------------------------------------------------------------------- // Remove a client from the list // ---------------------------------------------------------------------------- // EXPORT_C void CMPXClientList::RemoveClient(TInt aIndex) { // USER panic 130, if aIndex is negative or is greater than the number of // objects currently in the array. CClientId* id( iClients[aIndex] ); iClients.Remove(aIndex); //set primary client to NULL if primary client is removed if (iPrimaryClient != NULL) { if (aIndex == Find(*iPrimaryClient)) { iPrimaryClient = NULL; } } CClientId removeId( id->iPid ); if ( iClients.Find( &removeId, iIdentity ) == KErrNotFound ) // // There's no other client from the same process, so // remove it from the process list // { TInt i=iClientProcesses.Find(id->iPid); if (KErrNotFound != i) { if (iObserver) { TProcessId pid(id->iPid); FindProcessIdForTsp(id->iMode, pid); iObserver->HandleClientChange(pid, MMPXClientlistObserver::ERemove); } iClientProcesses.Remove(i); } } delete id; }
void runClient(int sockfd, const char* server, unsigned port) { char input[BUFFER_SIZE]; char output = CLI_EXIT_MSG; char* idStr = NULL; char* data = NULL; unsigned id = 0; unsigned countId = 0; int numDigits = 0; fd_set fds; if(sockfd == -1) return; FD_ZERO(&fds); printf(WELCOME_MSG, server, port); while(1) { FD_SET(sockfd, &fds); fgets(input, BUFFER_SIZE, stdin); if(strncasecmp("help", input, strlen("help")) == 0) { printf(HELP_MSG); } else if(strlen(input) > 6) { input[6] = '\0'; /* All commands should have a space here */ idStr = input+7; id = atoi(idStr); countId = id; /* Count number of char's for id */ numDigits = 0; while(countId) { /* In base 10 */ countId /= 10; numDigits++; } data = idStr + numDigits + 1; /* If needed */ /* Determine what we want to do */ if(strncasecmp(input, "insert", strlen("insert")) == 0) { output = CLI_INS_MSG; } else if(strncasecmp(input, "remove", strlen("remove")) == 0) { output = CLI_REM_MSG; } else if(strncasecmp(input, "lookup", strlen("lookup")) == 0) { output = CLI_FIND_MSG; } select(sockfd+1, NULL, &fds, NULL, NULL); sendData(sockfd, &output, sizeof(output)); switch(output) { default: /* Do nothing */ break; case CLI_INS_MSG: insertId(sockfd, id, data); break; case CLI_REM_MSG: removeId(sockfd, id); break; case CLI_FIND_MSG: /* Need to actually display this information if valid */ lookupId(sockfd, id); break; } } else if(strncasecmp("exit", input, strlen("exit")) == 0) { output = CLI_EXIT_MSG; sendData(sockfd, &output, sizeof(output)); break; } else { fprintf(stderr, "Unknown command\n"); } } }