// Remove the selected anemometer or the last if there is no selection void VariableView::removeVar() { int currCol = currentIndex().column(); int lastCol = varCount() - 1; if (currCol == -1) currCol = lastCol; static_cast<VariableModel *>(model())->removeColumns(currCol, 1, QModelIndex()); updateGeometries(); clearSelection(); }
// Add a new blank anemometer after the selected or after the first if there is // no selection void VariableView::addVar() { int currCol = currentIndex().column(); int lastCol = varCount(); if (currCol == -1) currCol = lastCol; else ++currCol; // cast the model(), but it's not stricly necessary because // model() already returns the setModel() assigned to the view instance VariableModel *concreteModel = static_cast<VariableModel *>(model()); concreteModel->insertColumns(currCol, 1, QModelIndex()); updateGeometries(); concreteModel->flush(); setCurrentIndex(concreteModel->index(0, currCol)); }
lsdouble SchedulingNativeFunction::call(const LSNativeContext& context) { vector<int> order(p.numJobs); if (context.count() < varCount()) return numeric_limits<double>::lowest(); for (int i = 0; i < p.numJobs; i++) { order[i] = static_cast<int>(context.getIntValue(i)); if (order[i] == Project::UNSCHEDULED) return numeric_limits<double>::lowest(); } SGSResult result = decode(order, context); lsdouble profit = static_cast<lsdouble>(p.calcProfit(result)); if (tr != nullptr) { if(profit > bks) bks = profit; tr->intervalTrace(static_cast<float>(bks)); } // TODO: result.numSchedulesGenerated return profit; }
/** * cgiInit * * Load the available CGI variables and create the PHP style _SERVER and _GET * dynamic variables. Both variables are created as associative arrays. **/ int cgiInit() { METHOD *pMethod; DATA *ptContent, *ptQuery, *ptArgs, *ptSERVER, *ptCBTREE, *ptGET, *ptPOST; char cProperty[MAX_BUF_SIZE], cValue[MAX_BUF_SIZE], cArgm[MAX_BUF_SIZE], *pcAllowed, *pcSrc, *pcArgm; int iArgCount, iSep, i; phResp = stdout; cgiEnvironment = newArray(NULL); // Setup a PHP style '$_SERVER' variable. if( (ptSERVER = newArray( "_SERVER" )) ) { for( i=0; cgiVarNames[i]; i++) { varNewProperty( cgiVarNames[i], getenv(cgiVarNames[i]), ptSERVER ); } varPush( cgiEnvironment, ptSERVER ); } /** * Setup a PHP style '$_CBTREE' variable. * * NOTE: On Apache HTTP servers any non CGI variables must be passed explicitly * using the 'SetEnv' or 'PassEnv' directive. For example in httpd.conf * add: * * PassEnv CBTREE_METHODS **/ if( (ptCBTREE = newArray( "_CBTREE" )) ) { for( i=0; cgiCbtreeNames[i]; i++) { varNewProperty( cgiCbtreeNames[i], getenv(cgiCbtreeNames[i]), ptCBTREE ); } varPush( cgiEnvironment, ptCBTREE ); } #ifdef _DEBUG varSet( cgiGetProperty("QUERY_STRING"), cDbgQS ); #endif switch( cgiGetMethodId() ) { case HTTP_V_DELETE: case HTTP_V_GET: if( (ptGET = newArray( "_GET" )) ) { if( (ptQuery = cgiGetProperty("QUERY_STRING")) ) { // Get the list of HTTP query arguments as a new array. ptArgs = varSplit( ptQuery, "&", false ); ptGET = newArray( "_GET" ); if( (iArgCount = varCount( ptArgs )) ) { for( i=0; i < iArgCount; i++ ) { if( (pcArgm = varGet(varGetByIndex( i, ptArgs ))) ) { // Decode special characters and treat each argument as a new property. pcSrc = decodeURI( pcArgm, cArgm, sizeof(cArgm)-1 ); iSep = strcspn( pcSrc, "=" ); strncpyz( cProperty, pcSrc, iSep ); pcSrc += pcSrc[iSep] ? iSep + 1: iSep; strcpy( cValue, pcSrc ); varNewProperty( cProperty, cValue, ptGET ); } } } destroy( ptArgs ); } varPush( cgiEnvironment, ptGET ); } break; case HTTP_V_POST: if( (ptPOST = newArray( "_POST" )) ) { // Read the content from stdin if( fgets(cArgm, sizeof(cArgm)-1, stdin) ) { ptContent = newString( "CONTENT", cArgm ); ptArgs = varSplit( ptContent, "&", false ); if( (iArgCount = varCount( ptArgs )) ) { for( i=0; i < iArgCount; i++ ) { if( (pcArgm = varGet(varGetByIndex( i, ptArgs ))) ) { // Decode special characters and treat each argument as a new property. pcSrc = decodeURI( pcArgm, cArgm, sizeof(cArgm)-1 ); iSep = strcspn( pcSrc, "=" ); strncpyz( cProperty, pcSrc, iSep ); pcSrc += pcSrc[iSep] ? iSep + 1: iSep; strcpy( cValue, pcSrc ); varNewProperty( cProperty, cValue, ptPOST ); } } } destroy( ptArgs ); } varPush( cgiEnvironment, ptPOST ); } break; } // Define which HTTP methods are allowed. if( ptCBTREE ) { pcAllowed = varGet(varGetProperty("CBTREE_METHODS", ptCBTREE)); snprintf( cProperty, sizeof(cProperty)-1,"GET,%s", (pcAllowed ? pcAllowed : "") ); pcArgm = strtok( cProperty, ", " ); while( pcArgm ) { strtrim( pcArgm, TRIM_M_WSP ); if( *pcArgm ) { if( (pMethod = _cgiGetMethodByName( pcArgm )) ) { pMethod->bAllowed = true; } } pcArgm = strtok( NULL, ", " ); } } return 1; }