예제 #1
0
Texture::Texture(int width, int height, GLuint target, int flag)
  : target(target)
{
  extractParams(flag);
  genTexture();
  glTexImage2D(target, 0, internalFormat, width, height, 0, format, type, NULL);
  texParameter(GL_TEXTURE_MAG_FILTER, magFilter);
  texParameter(GL_TEXTURE_MIN_FILTER, minFilter);
}
예제 #2
0
Texture::Texture(const char *filename, GLuint target, int flag)
  : name(filename), target(target)
{
  flag |= UNSIGNED_BYTE|RGB; //RGB avoid an exception in extractParams
  extractParams(flag);
  genTexture();

  if(target == TEXTURE_CUBE_MAP)
    loadCubemap(flag);
  else if(target == TEXTURE_2D)
    loadTexture2D(name, target, flag);

  texParameter(GL_TEXTURE_MAG_FILTER, magFilter);
  texParameter(GL_TEXTURE_MIN_FILTER, minFilter);
}
예제 #3
0
void sectionLoader(istream& stream, int numElems, Game& g, void (*whatToDo)(Game& g, Base*))
{
	vector<string> params;			// params holder
	
	ClassRegistry<Base> factory = ClassRegistry<Base>::get();
	for (int i=0; i< numElems; i++)
	{
		extractParams(stream, params);

		Base* base = factory.createClass(params[0]);
		base->configure(params);

		whatToDo(g, base);					// i.e. the step that can vary
	}

}
예제 #4
0
// main body of the engine
int main(int argc, char** argv)
{
  /*  if (argc < 4) {
      cerr << "usage: resque [predicate] [shape_idx 1] [shape_idx 2] [distance]" <<endl;
      return 1;
      } */
  init();
  int c = 0 ;
  if (!extractParams(argc,argv)) {
    std::cerr <<"ERROR: query parameter extraction error." << std::endl << "Please see documentations, or contact author." << std::endl;
    usage();
    return 1;
  }

  switch (stop.join_cardinality){
    case 1:
    case 2:
      c = mJoinQuery();
      // std::cerr <<"ERROR: input data parsing error." << std::endl << "Please see documentations, or contact author." << std::endl;
      break;

    default:
      std::cerr <<"ERROR: join cardinality does not match engine capacity." << std::endl ;
      return 1;
      break;
  }
  if (c >= 0 )
    std::cerr <<"Query Load: [" << c << "]" <<std::endl;
  else 
  {
    std::cerr <<"Error: ill formatted data. Terminating ....... " << std::endl;
    return 1;
  }
  freeObjects();
  
  cout.flush();
  cerr.flush();
  return 0;
}
예제 #5
0
bool QueryHolder::runQuery(IDataSource::DatasourceMode mode)
{
    m_mode = mode;
    QSqlDatabase db = QSqlDatabase::database(m_connectionName);
    if (!db.isValid()) {
        setLastError(QObject::tr("Invalid connection! %1").arg(m_connectionName));
        return false;
    }

    if (!m_prepared){
        extractParams();
        if (!m_prepared) return false;
    }

    if (!m_query){
        m_query = new QSqlQuery(db);
        m_query->prepare(m_preparedSQL);
    }

    fillParams(m_query);
    m_query->exec();

    QSqlQueryModel *model = new QSqlQueryModel;
    model->setQuery(*m_query);

    while (model->canFetchMore())
        model->fetchMore();

    if (model->lastError().isValid()){
        if (m_dataSource)
           m_dataSource.clear();
        setLastError(model->lastError().text());
        delete model;
        return false;
    } else setLastError("");

    setDatasource(IDataSource::Ptr(new ModelToDataSource(model,true)));
    return true;
}
예제 #6
0
QueryHolder::QueryHolder(QString queryText, QString connectionName, DataSourceManager *dataManager)
    : m_query(0), m_queryText(queryText), m_connectionName(connectionName),
      m_mode(IDataSource::RENDER_MODE), m_dataManager(dataManager), m_prepared(true)
{
    extractParams();
}
예제 #7
0
bool Resume::operator()(const std::string &params)
{
    if (ui->currentChangeset) {
        std::ostringstream ostr;
        ostr << "Error: You are already in the changeset " << *(ui->currentChangeset) << "!";
        ui->io->reportError(ostr.str());
        return false;
    }

    if (!params.empty()) {
        
        std::vector<std::string> paramsList = extractParams(params);
        if (paramsList.size() != 1) {
            ui->io->reportError("Invalid number of parameters entered!");
            return false;
        }

        boost::optional<Db::TemporaryChangesetId> tmpId;
        try {
            tmpId = Db::TemporaryChangesetId::fromString(paramsList[0]);
        } catch (std::runtime_error &e) {
            std::ostringstream ss;
            ss << "Invalid parameters: " << e.what();
            ui->io->reportError(ss.str());
            return false;
        }
        try {
            ui->m_dbInteraction->resumeChangeset(*tmpId);
            ui->currentChangeset = *tmpId;
            std::ostringstream ostr;
            ostr << "Changeset " << *(ui->currentChangeset) << " resumed.";
            ui->io->printMessage(ostr.str());
        } catch (Db::ChangesetRangeError &e) {
            std::ostringstream ostr;
            ostr << "Error while resuming changeset: " << e.what();
            ui->io->reportError(ostr.str());
            return false;
        } catch (Db::ChangesetLockingError &e) {
            std::ostringstream ostr;
            ostr << "Error while resuming changeset: " << e.what();
            return false;
        } catch (Db::ServerError &e) {
            std::ostringstream ostr;
            ostr << "Error while resuming changeset: " << e.what();
            ui->io->reportError(ostr.str());
            return false;
        }
        return true;
    }

    if (ui->nonInteractiveMode || ui->forceNonInteractive) {
        ui->io->reportError("You have to specify changeset ID as a parameter for resume in non-interactive mode.");
        return false;
    }
    
    // Print list of pending changesets, so user can choose one
    std::vector<Db::PendingChangeset> pendingChangesets = ui->m_dbInteraction->allPendingChangesets();
    int choice = ui->io->chooseChangeset(pendingChangesets);

    if (choice >= 0) {
        // Some changeset was choosen
        ui->m_dbInteraction->resumeChangeset(pendingChangesets[choice].revision);
        ui->currentChangeset = pendingChangesets[choice].revision;
        std::ostringstream ostr;
        ostr << "Changeset " << *(ui->currentChangeset) << " resumed.";
        ui->io->printMessage(ostr.str());
    }
    return true;
}
예제 #8
0
파일: casalime.c 프로젝트: lime-rt/lime
/*....................................................................*/
int
main(int argc, char *argv[]){
  errType err=init_local_err();
  PyObject *pCurrentModel,*pLimePars,*pModule;
  const int maxLenName=100;
  char userModuleNameNoSuffix[maxLenName+1];
  int modelI=-1,nPars,nImgPars,nImages,status=0;
  char message[STR_LEN_1];
  const char *headerModuleName="limepar_classes";
  inputPars par;
  image *img = NULL;
  parTemplateType *parTemplates=NULL,*imgParTemplates=NULL;

  if (argc < 2){
    printf("Usage: casalime <name of file with pickled pars object>\n");
exit(1);
  }

  /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  Py_Initialize();

  /* pCurrentModel should be a modellib_classes._Model instance, pLimePars should be a limepar_classes.ModelParameters instance. */
  _readParsObjWrapper(argv[1], &pCurrentModel, userModuleNameNoSuffix, maxLenName, &copyTemp, &pLimePars);

  /* Do some initialization */
  setDefaultFuncStuffs(); /* in ml_funcs */
  silent = 0;//********** pass it as argument?
  defaultFuncFlags = 0;

  if(pCurrentModel==Py_None){
    currentModelI = MODEL_None;
  }else{
    err = getModelI(pCurrentModel, &modelI); /* in ml_aux.c */
    if(err.status!=0){
      Py_DECREF(pCurrentModel);
      Py_DECREF(pLimePars);
pyerror(err.message);
    }

    currentModelI = modelI; /* global var. */

    /* Set some global arrays defined in the header of ml_models.c */
    err = extractParams(pCurrentModel); /* in ml_aux.c */
    if(err.status!=0){
      Py_DECREF(pCurrentModel);
      Py_DECREF(pLimePars);
pyerror(err.message);
    }

    /* Set some global arrays defined in the header of ml_funcs.c */
    err = extractFuncs(pCurrentModel); /* in ml_aux.c */
    if(err.status!=0){
      Py_DECREF(pCurrentModel);
      Py_DECREF(pLimePars);
pyerror(err.message);
    }
  }

  Py_DECREF(pCurrentModel);

  status = finalizeModelConfig(currentModelI); /* in ml_models.c */
  if(status!=0){
    Py_DECREF(pLimePars);
    sprintf(message, "finalizeModelConfig() returned status value %d", status);
pyerror(message);
  }

  /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  /* Construct the 'macro' list argument:
  */
  err = setMacros(); /* in py_utils.c */
  if(err.status){
    Py_DECREF(pLimePars);
    unsetMacros(); /* in py_utils.c */
pyerror(err.message);
  }

  /* Set up any user-supplied result functions: */
  if(strlen(userModuleNameNoSuffix)>0){
    err = getModuleFromName(userModuleNameNoSuffix, &pModule); /* in py_utils.c */
    if(err.status!=0){ /* Don't need to decref pModule. */
      Py_DECREF(pLimePars);
pyerror(err.message);
    }

    /* Sets up global objects defined in the header of py_utils.c */
    setUpUserPythonFuncs(pModule); /* in py_utils.c */

    Py_DECREF(pModule);
  }

  /* Now get the lists of attribute names from the 2 classes in limepar_classes.py:
  */
  err = getParTemplatesWrapper(headerModuleName, &parTemplates, &nPars\
    , &imgParTemplates, &nImgPars); /* in py_utils.c */
  if(err.status!=0){
    Py_DECREF(pLimePars);
pyerror(err.message);
  }

  err = mallocInputParStrs(&par);
  if(err.status){
    unsetMacros();
    Py_DECREF(pLimePars);
pyerror(err.message);
  }

  /* Finally, unpack the LIME parameter values, following the templates: */
  err = readParImg(pLimePars, parTemplates, nPars, imgParTemplates\
    , nImgPars, &par, &img, &nImages, pywarning); /* in py_utils.c */

  if(err.status){
    Py_DECREF(pLimePars);
pyerror(err.message);
  }

  Py_DECREF(pLimePars);
  free(imgParTemplates);
  free(parTemplates);

  /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  /* Now call the main bit of LIME:
  */
  status = run(par, img, nImages);

  /* Python-object clean up before status check and possible exit.
  */
  decrefAllUserFuncs(); /* in py_utils.c */
  free(modelDblPars); /* global in header of ml_models.c */
  free(modelIntPars); /* global in header of ml_models.c */
//************* why not the str pars??
  freeFuncsPars(); /* in ml_funcs.c */

  if(status){
    sprintf(message, "Function run() returned with status %d", status);
pyerror(message);
  }

  Py_Finalize();

  return 0;
}