void Node::setName( const std::string& theName ) { if ( !isNameValid( theName ) ) { return; } name = theName; }
ConsoleVariable* ConsoleDataManager::AddCVar(const std::string& name, const std::string& value, ConsoleVarFunc varFunc, const std::string& help) { // check name first if (!isNameValid(name)) return NULL; // create new console variable ConsoleVariable* cvar = new ConsoleVariable(name, ConsoleValue(value), varFunc, help); // register console variable size_t index = addCVar(cvar); m_cvarMap[name] = index; return cvar; }
//! add console command ConsoleCommand* ConsoleDataManager::AddCCmd(const std::string& name, ConsoleCmdFunc cmdFunc, const std::string& help) { // check name first if (!isNameValid(name)) return NULL; // create new console command ConsoleCommand* ccmd = new ConsoleCommand(name, cmdFunc, help); // register console command size_t index = addCCmd(ccmd); m_ccmdMap[name] = index; return ccmd; }
void CShareEditDialog::saveShare() { QString name = ui->name->text().simplified(); QString ip = ui->ip->text(); ip.replace (QRegExp("^0*([1-9]?[0-9])"), "\\1"); ip.replace (QRegExp("\\.0*([1-9]?[0-9])"), ".\\1"); if(!isIPValid(ip)) { #ifndef QT_TEST CYesDialog d; d.setTitle(tr("Invalid IP")); d.setText(tr("IP address must consist of four numbers from range 0-255.")); d.exec(); #endif ui->ip->setFocus(); return; } if(name.isEmpty()){ #ifndef QT_TEST CYesDialog d; d.setTitle(tr("Invalid name")); d.setText(tr("Resource must have name")); d.exec(); #endif ui->name->setFocus(); return; } else if(!isNameValid(share_, name)) return; SShare::Type shareType = SShare::Type(ui->sharetype->itemData(ui->sharetype->currentIndex()).toInt()); if(!isFolderNameValid(ui->dir->text())) return; if(!share_) share_ = QSharedPointer<SShare>(new SShare); share_->name = name; share_->ip = ip; share_->path = ui->dir->text(); share_->username = ui->login->text(); share_->password = ui->password->text(); share_->type = shareType; this->accept(); }
void SyntaxEditorWindow::saveAs() { QString newSyntaxName = syntaxName; bool ok; while (true) { newSyntaxName = QInputDialog::getText(0, tr("New syntax name"), tr("Enter new syntax name"), QLineEdit::Normal, newSyntaxName, &ok); if (!ok) return; if (newSyntaxName.isEmpty()) continue; if (newSyntaxName == syntaxName && !syntaxList->isGlobal(newSyntaxName)) break; emit isNameValid(syntaxName, ok); if (!ok) continue; if (!syntaxList->contains(newSyntaxName)) break; if (syntaxList->isGlobal(newSyntaxName)) { MessageBox::msg(tr("Syntax %1 already exists and cannot be modified").arg(newSyntaxName), true, "Warning"); continue; } else { if (MessageBox::ask(tr("Overwrite %1 syntax?").arg(newSyntaxName))) break; } } syntaxList->updateSyntax(newSyntaxName, editor->toPlainText()); emit updated(newSyntaxName); emit syntaxAdded(newSyntaxName); close(); }
/** * This is the version used by the parser. Acts as a blocking, * serial-like interface to a potentially multithread, multinode call. * Returns the new Id index upon success, otherwise returns Id(). * The data of the new Element is not necessarily allocated at this point, * that can be deferred till the global Instantiate or Reset calls. * Idea is that the model should be fully defined before load balancing. * */ Id Shell::doCreate( string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy, unsigned int preferredNode ) { #ifdef ENABLE_LOGGER clock_t t = clock(); #endif const Cinfo* c = Cinfo::find( type ); if ( !isNameValid( name ) ) { stringstream ss; ss << "Shell::doCreate: bad character in name'" << name << "'. No Element created"; warning( ss.str() ); return Id(); } if ( c ) { if ( c->banCreation() ) { stringstream ss; ss << "Shell::doCreate: Cannot create an object of class '" << type << "' because it is an abstract base class or a FieldElement.\n"; warning( ss.str() ); return Id(); } Element* pa = parent.element(); if ( !pa ) { stringstream ss; ss << "Shell::doCreate: Parent Element'" << parent << "' not found. No Element created"; warning( ss.str() ); return Id(); } if ( Neutral::child( parent.eref(), name ) != Id() ) { stringstream ss; ss << "Shell::doCreate: Object with same name already present: '" << parent.path() << "/" << name << "'. No Element created"; warning( ss.str() ); return Id(); } // Get the new Id ahead of time and pass to all nodes. Id ret = Id::nextId(); NodeBalance nb( numData, nodePolicy, preferredNode ); // Get the parent MsgIndex ahead of time and pass to all nodes. unsigned int parentMsgIndex = OneToAllMsg::numMsg(); SetGet6< string, ObjId, Id, string, NodeBalance, unsigned int >::set( ObjId(), // Apply command to Shell "create", // Function to call. type, // class of new object parent, // Parent ret, // id of new object name, // name of new object nb, // Node balance configuration parentMsgIndex // Message index of child-parent msg. ); // innerCreate( type, parent, ret, name, numData, isGlobal ); #ifdef ENABLE_LOGGER logger.creationTime.push_back((float(clock() - t)/CLOCKS_PER_SEC)); #endif return ret; } else { stringstream ss; ss << "Shell::doCreate: Class '" << type << "' not known. No Element created"; warning( ss.str() ); } #ifdef ENABLE_LOGGER logger.creationTime.push_back((float(clock() - t)/CLOCKS_PER_SEC)); #endif return Id(); }