コード例 #1
0
ファイル: main.cpp プロジェクト: Vanuan/iviLink
bool RemoveComment(const QString& path, const QString& text, int from, int to, bool& skip, bool& modify)
{
    bool commentprinted(false);
    QString comment=text.mid(from, to-from);
    if(inList(alert_copyrights, comment))
    {
        reportFile(path);
        log->write("**** COMMENT **********************************\n");
        log->write("\n\n   ALERT!!!! FORBIDDEN LICENSE DETECTED!!!! \n\n");
        log->write(comment.toAscii());
        commentprinted=true;
    }
    bool flag=inList(gray_copyrights, comment);
    if(!flag)return false;
    bool comment_must_be_removed(inList(reject_copyrights, comment));
    bool comment_must_be_saved(inList(skip_copyrights, comment));
    skip|=comment_must_be_saved;
    modify|=comment_must_be_removed;
    if(infomode && log){
        if(!commentprinted && !onlyalerts)
        {
            reportFile(path);

            log->write("**** COMMENT **********************************\n");
            log->write(comment.toAscii());
            log->write("\n**** ");
        }
        if(comment_must_be_removed)log->write("[REJECT] ");
        if(comment_must_be_saved)log->write("[KEEP] ");
        log->write("\n**********************************************\n");
    }
    if(comment_must_be_removed && !comment_must_be_saved)return true;
    return false;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: babenkoav78/iviLink
void storeFile(const QString& orig, const QString& path, const QStringList& lines, bool skip, bool modify, bool bashcomment=false)
{

    if(skip && modify)
    {
        reportFile(path);
        if(log)
            log->write("PROBLEM: file contains both our and third-party copyrights");
    }
    if(infomode)
        return;


    QString outpath=path;
    if(testmode)
        outpath+=".test";

    QFile ofile(outpath);
    if(ofile.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        if(!skip)
        {
            if(!copyright_header.isEmpty())
            {
                QStringList lines=copyright_header.split('\n');
                QStringListIterator iter(lines);
                if(!bashcomment)
                    ofile.write("/* \n");
                while(iter.hasNext())
                {
                    if(bashcomment)
                        ofile.write("# ");
                    else
                        ofile.write(" * ");
                    ofile.write(iter.next().toAscii());
                    ofile.write("\n");
                }
                if(!bashcomment)
                    ofile.write(" */ \n");
            }
            QStringListIterator iter(lines);
            while(iter.hasNext())
            {
                ofile.write(iter.next().toAscii());
            }
        }
        else
            ofile.write(orig.toAscii());
    }
    else if(log)
    {
        reportFile(path);
        log->write("WRITE ERROR: ");
        log->write(ofile.errorString().toAscii());
        log->write("\n");
    }
}
コード例 #3
0
int Classifier::generateReport(ConfusionMatrix& confusionMat, int wrong, int total, string repPath,
                               int resNum, ClassifResults& clRes, int wrongStrict)
{
    // Open file to store report
    ofstream reportFile(repPath.c_str());
    if (!reportFile.is_open())
    {
       fprintf(stderr, "Cannot open file %s to store report", repPath.c_str());
       return 1;
    }

    // Store confusion matrix as HTML table
    reportFile << confusionMatrixToHTML(confusionMat) << "\n<br>\n";
    

    // Store correctness (only the best)
    int correctStrict = total - wrongStrict;
    reportFile << "Correctness " <<  "(only the best): " 
               << correctStrict << "/" << total << " = ";
    reportFile << "<strong>" << correctStrict / (double) total << "</strong>" << "<br><br>\n\n";

    // Store correctness
    int correct = total - wrong;
    reportFile << "Correctness " <<  "(in <strong>" << resNum << "</strong> best): " 
               << correct << "/" << total << " = ";
    reportFile << "<strong>" << correct / (double) total << "</strong>" << "<br><br>\n\n";

    // Store classification results
    reportFile << classifResultsToHTML(clRes, resNum);

    reportFile.close();

    // Everything went ok
    return 0;
}
コード例 #4
0
void KrakenClassifyTask::run() {
    QFile reportFile(settings.classificationUrl);
    if (!reportFile.open(QIODevice::ReadOnly)) {
        setError(tr("Cannot open classification report: %1").arg(settings.classificationUrl));
    } else {
        QByteArray line;

        while ((line = reportFile.readLine()).size() != 0) {
            if (line.startsWith("C\t") || line.startsWith("U\t")) {
                QList<QByteArray> row = line.split('\t');
                if (row.size() >= 5) {
                    QString objID = row[1];
                    QByteArray &assStr = row[2];
                    algoLog.trace(QString("Found Kraken classification: %1=%2").arg(objID).arg(QString(assStr)));

                    bool ok = true;
                    LocalWorkflow::TaxID assID = assStr.toUInt(&ok);
                    if (ok) {
                        if (parsedReport.contains(objID)) {
                            QString msg = tr("Duplicate sequence name '%1' have been detected in the classification output.").arg(objID);
                            algoLog.info(msg);
                        } else {
                            parsedReport.insert(objID, assID);
                        }
                        continue;
                    }
                }
            }
            setError(tr("Broken Kraken report : %1").arg(settings.classificationUrl));
            break;
        }
        reportFile.close();
    }
}
コード例 #5
0
ファイル: ftpclient.c プロジェクト: mathlover777/NetworksLab
void callClient(const char *fileInx){
  
  no_writen = 0;
  num_blks = 0;
  num_last_blk = 0;
  // gets(fileIn);
  strcpy(fileIn,fileInx);
  len = strlen(fileIn);
  printf("\nAttempting Download {%s}\n",fileIn);
  // DEBUG printf("\nLen = %d\n",len);
  while(setupConnection()==-1);
  reportFile();
  openfile();
  getBlockInfo();
  beginread();
  readpartial();
  // shutdown (sockid,2);
  // system("sudo cutter 127.0.0.1");
  /*FILE TRANSFER ENDS. CLIENT TERMINATES AFTER  CLOSING ALL ITS FILES
  AND SOCKETS*/ 
  fclose(fp);
  DEBUG printf("client: FILE TRANSFER COMPLETE\n");
  close(sockid);
  return;
}
コード例 #6
0
int main( int argc, char** argv ) {
    QApplication app( argc, argv );

    // Create a report
    KDReports::Report report;

    // open a DB connection to an in-memory database
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");
    if( !db.open() ) {
        QMessageBox::critical(0, QObject::tr("Cannot open database"),
                              QObject::tr("Cannot create connection to the requested database. Your Qt is probably lacking the QSQLITE driver. Please check your Qt installation." ), QMessageBox::Cancel );
        return false;
    }

    // fill the DB with some test data
    QSqlQuery query;
    query.exec("create table airlines (id int primary key, "
               "name varchar(20), homecountry varchar(2))");
    query.exec("insert into airlines values(1, 'Lufthansa', 'DE')");
    query.exec("insert into airlines values(2, 'SAS', 'SE')");
    query.exec("insert into airlines values(3, 'United', 'US')");
    query.exec("insert into airlines values(4, 'KLM', 'NL')");
    query.exec("insert into airlines values(5, 'Aeroflot', 'RU')");

    // Create a QSqlTableModel, connect to the previously created database, fill
    // the db with some data.
    QSqlTableModel tableModel( 0, db );
    tableModel.setTable( "airlines" );
    tableModel.select();
    tableModel.removeColumn( 0 );
    tableModel.setHeaderData( 0, Qt::Horizontal, QObject::tr("Name") );
    tableModel.setHeaderData( 1, Qt::Horizontal, QObject::tr("Home country") );
    QFont font = app.font();
    font.setBold( true );
    tableModel.setHeaderData( 0, Qt::Horizontal, font, Qt::FontRole );
    tableModel.setHeaderData( 1, Qt::Horizontal, font, Qt::FontRole );

    // associate the model and load the XML file
    report.associateModel( "airlines", &tableModel );
    QFile reportFile( ":/Database.xml" );
    if( !reportFile.open( QIODevice::ReadOnly ) ) {
        QMessageBox::warning( 0, QObject::tr( "Warning" ), QObject::tr( "Could not open report description file 'Database.xml'. Please start this program from the DatabaseXML directory." ) );
        return -1;
    }

    KDReports::ErrorDetails details;
    if( !report.loadFromXML( &reportFile, &details ) ) {
        QMessageBox::warning( 0, QObject::tr( "Warning" ), QObject::tr( "Could not parse report description file:\n%1" ).arg(details.message()) );
        reportFile.close();
        return -2;
    }

    // To show a print preview:
    KDReports::PreviewDialog preview( &report );
    return preview.exec();

    //return app.exec();
}
コード例 #7
0
void ResultsParser::processOneFile(const std::string& reportFilePath)
{
    std::ifstream reportFile(reportFilePath, std::ios::in);
    std::string line;

    while(std::getline(reportFile, line))
    {
        if(std::count(line.begin(), line.end(), '-') == REPORTS_DELIMITER_SIZE)
            parseOneSampleFile(reportFile);
    }

    reportFile.close();
}
コード例 #8
0
void WorkflowRunFromCMDLineBase::run() {
    CMDLineRegistry *cmdLineRegistry = AppContext::getCMDLineRegistry();
    SAFE_POINT(NULL != cmdLineRegistry, "CMDLineRegistry is NULL", );
    CHECK(NULL != workflowRunTask, );

    const QString reportFilePath = cmdLineRegistry->getParameterValue(CmdlineTaskRunner::REPORT_FILE_ARG);
    CHECK(!reportFilePath.isEmpty(), );

    QFile reportFile(reportFilePath);
    const bool opened = reportFile.open(QIODevice::WriteOnly);
    CHECK_EXT(opened, setError(L10N::errorOpeningFileWrite(reportFilePath)), );

    reportFile.write(workflowRunTask->generateReport().toLocal8Bit());
}
コード例 #9
0
bool NPushReportSpeed::save_to_dir(QString &dirName)
{

    QString reportFilename = (dirName + FSC_FSYS_SLASH) + "Speed.xml";
    QFile reportFile(reportFilename);

    reportFile.open(QFile::WriteOnly | QFile::Text);

    QXmlStreamWriter xml;

    xml.setDevice(&reportFile);
    xml.setAutoFormatting(true);

    xml.writeStartDocument();

    dataAccessMutex.lock();


    xml.writeStartElement("SpeedReport");

    xml.writeStartElement("stats");

    xml.writeAttribute("max", QString::number(Speed_max));
    xml.writeAttribute("avg", QString::number(Speed_avg));

    xml.writeEndElement();//stats

    xml.writeStartElement("graph");

    SelfShrinkingList::iterator it;
    for(it = graphPoints.begin(); it != graphPoints.end() ; ++it)
    {
        xml.writeStartElement("point");
        xml.writeAttribute("val", QString::number(*it));
        xml.writeEndElement();
    }

    xml.writeEndElement();//graph

    xml.writeEndElement();//SpeedReport
    dataAccessMutex.unlock();

    xml.writeEndDocument();

    reportFile.close();

    qDebug() << "Speed -> Ended";
    return true;
}
コード例 #10
0
ファイル: InThread.cpp プロジェクト: DarkDemiurg/KDReports
 virtual void run() {
     KDReports::Report report;
     report.associateTextValue( "title_element", "Price list example" );
     report.associateImageValue( "image_system", QImage( ":/system.png" ) );
     QFile reportFile( ":/PriceList.xml" );
     if( !reportFile.open( QIODevice::ReadOnly ) ) {
         Q_ASSERT( false );
     }
     KDReports::ErrorDetails details;
     if( !report.loadFromXML( &reportFile, &details ) ) {
         qWarning( "ERROR: %s", qPrintable( details.message() ) );
     }
     report.exportToImage( QSize(800, 600), "xml.png", "PNG" ); // deleted by main() below
     report.exportToFile( "xml.pdf" ); // deleted by main() below
 }
コード例 #11
0
void ReportProblemDialog::SendReport()
{
	if (checkFields())
	{
		QApplication::setOverrideCursor(Qt::WaitCursor);
		QtJson::JsonObject postData;
		postData["name"] = nameEdit->text();
		postData["email"] = emailEdit->text();
		
		if (sendOSInfoCheckBox->isChecked())
		{
			QProcess dxDiagProcess;
			QStringList arguments;
			QString reportFileName = QString("dxdiagReport.%1.txt").arg(QApplication::applicationPid());
			QString dxDiagReportFilePath = StaticHelpers::CombinePathes(QDesktopServices::storageLocation(QDesktopServices::TempLocation), reportFileName);
			arguments << "/whql:on" << QString("/t%1").arg(dxDiagReportFilePath);
			dxDiagProcess.start("dxdiag.exe", arguments);
			dxDiagProcess.waitForFinished();
			QFile reportFile(dxDiagReportFilePath);
			if (reportFile.open(QIODevice::ReadOnly))
			{
				QString reportData = QString::fromLocal8Bit(reportFile.readAll());
				postData["problem"] = problemDescriptionEdit->toPlainText().append("\n").append(reportData);
				reportFile.close();
				QFile::remove(dxDiagReportFilePath);
			}
			else
			{
				QApplication::restoreOverrideCursor();
				CustomMessageBox::critical(this, "Windows Info creation failed", "Failed to create DxDaig Report.\nError: " + reportFile.errorString());
				return;
			}
		}
		else
		{
			postData["problem"] = problemDescriptionEdit->toPlainText();
		}
		

		QByteArray data = QtJson::serialize(postData);
		qDebug() << "Sending JSON:" << QString(data);
		QNetworkRequest request(QUrl("http://integration.cutetorrent.info/report.php"));
		request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
		m_pNetManager->post(request, data);
		
		
	}
}
コード例 #12
0
int main( int argc, char** argv ) {
    QApplication app( argc, argv );

    // Create a report
    KDReports::Report report;

    // Set the content of a text field - this shows how xml files can be used as templates for reports,
    // not only as complete (generated) reports.
    report.associateTextValue( "title_element", "Price list example" );
    report.associateTextValue( "company_address", "Klarälvdalens Datakonsult AB\n"
"Rysktorp\n"
"SE-68392 Hagfors\n"
"Sweden" );
    // Note how id="table1_title" is used twice in the xml, both places get the right value
    report.associateTextValue( "table1_title", "Network Peripherals" );
    report.associateTextValue( "table2_title", "Printer Cartridges" );

    report.associateImageValue( "image_system", QPixmap( ":/system.png" ) );

    // Create two table models which will be used by one table element each.
    TableModel table1;
    table1.setDataHasVerticalHeaders( false );
    table1.loadFromCSV( ":/table1" );
    report.associateModel( QLatin1String( "table1" ), &table1 );
    TableModel table2;
    table2.setDataHasVerticalHeaders( false );
    table2.loadFromCSV( ":/table2" );
    report.associateModel( QLatin1String( "table2" ), &table2 );

    QFile reportFile( ":/PriceList.xml" );
    if( !reportFile.open( QIODevice::ReadOnly ) ) {
        QMessageBox::warning( 0, QObject::tr( "Warning" ), QObject::tr( "Could not open report description file 'PriceList.xml'. Please start this program from the PriceListXML directory." ) );
        return -1;
    }

    KDReports::ErrorDetails details;
    if( !report.loadFromXML( &reportFile, &details ) ) {
        QMessageBox::warning( 0, QObject::tr( "Warning" ), QObject::tr( "Could not parse report description file:\n%1" ).arg(details.message()) );
        reportFile.close();
        return -2;
    }

    // To show a print preview:
    KDReports::PreviewDialog preview( &report );
    return preview.exec();

    //return app.exec();
}
コード例 #13
0
ファイル: ftpclient.c プロジェクト: mathlover777/NetworksLab
void callClient(const char *fileInx){
  
  no_writen = 0;
  num_blks = 0;
  num_last_blk = 0;
  // gets(fileIn);
  strcpy(fileIn,fileInx);
  len = strlen(fileIn);
  printf("\nAttempting Download {%s}\n",fileIn);
  // DEBUG printf("\nLen = %d\n",len);
  while(setupConnection()==-1);
  reportFile();
  openfile();
  getBlockInfo();
  beginread();
  readpartial();
  fclose(fp);
  close(sockid);
  return;
}
コード例 #14
0
int main( int argc, char** argv ) {
    QApplication app( argc, argv );

    // Create a report
    KDReports::Report report;

    QFile reportFile( ":/MailMerge.xml" );
    if( !reportFile.open( QIODevice::ReadOnly ) ) {
        QMessageBox::warning(
            0, QObject::tr( "Warning" ),
            QObject::tr( "Could not open report description file 'MailMerge.xml'. "
                         "Please start this program from the HelloWorldXML directory." ) );
        return -1;
    }

    TableModel members;
    members.setDataHasVerticalHeaders( false );
    members.loadFromCSV( ":/members.csv" );
    report.associateModel( QLatin1String( "members" ), &members);
  
    for (int i = 0; i < members.rowCount(); i++ ) {
        report.setCurrentRow(&members, i);
        KDReports::ErrorDetails details;
        if( !report.loadFromXML( &reportFile, &details ) ) {
            QMessageBox::warning( 0, QObject::tr( "Warning" ), QObject::tr( "Could not parse report description file:\n%1" ).arg(details.message()) );
            reportFile.close();
            return -2;
        }
        
        if ( i < members.rowCount() - 1 )
            report.addPageBreak();

        // show a print preview:
    }
    KDReports::PreviewDialog preview( &report );
    return preview.exec();
}
コード例 #15
0
ファイル: job.cpp プロジェクト: JoelB/BITS
bool Job::generateReport(QDateTime startDate,QDateTime endDate,QString filename)
{
	QString currentLine;
	QStringList sessionParts;
	int taskId;

	QMultiMap<int,taskSession> taskSessions;
	
	QFile sessionFile(attributeValues["Filename"].toString().replace(QString(".xml"),QString(".session")));
	if (!sessionFile.open(QIODevice::ReadOnly | QIODevice::Text))
		qDebug() << "Failed to session file!";

	while (!sessionFile.atEnd())
	{
		currentLine = QString(sessionFile.readLine());
		sessionParts = currentLine.split("%");
		taskSession tempsession;
		taskId = sessionParts.at(0).toInt();
		tempsession.start = QDateTime::fromString(sessionParts.at(1),Qt::ISODate);
		tempsession.end = QDateTime::fromString(sessionParts.at(2),Qt::ISODate);
		taskSessions.insert(taskId,tempsession);
	}
	sessionFile.close();
	
	QMap<int,int> totalTimes;
	QMapIterator<int,taskSession> iter(taskSessions);
	while (iter.hasNext())
	{
		iter.next();
		int timeSum = 0;
		QList<taskSession> sessions = taskSessions.values(iter.key());
		for (int i = 0; i < sessions.size(); i++)
		{
			taskSession tempSession = sessions.at(i);
			if (tempSession.start >= startDate && tempSession.end <= endDate) // session happened completely in range
				timeSum += tempSession.start.secsTo(tempSession.end);
			else if (tempSession.start <= startDate && tempSession.end <=endDate) // started out of range, ended in range
				timeSum += startDate.secsTo(tempSession.end);
			else if (tempSession.start >= startDate && tempSession.end >= endDate) // started in range, ended out of range
				timeSum += tempSession.start.secsTo(endDate);
			else if (tempSession.start <= startDate && tempSession.end >= endDate) // continued through entire range
				timeSum += startDate.secsTo(endDate);
		}
		totalTimes.insert(iter.key(),timeSum);
	}
	
	QFile reportFile(filename);
	if (!reportFile.open(QIODevice::WriteOnly | QIODevice::Text))
	{
		qDebug() << "Failed to open new report file!";
		return false;
	}
	
	QTextStream out(&reportFile);
	out << "Job Session Report for " << startDate.toString() << " to " << endDate.toString() << "\n\n";
	out << "Job Name: " << getAttributeValue("Name").toString() << "\n";
	out << "Job Start Date: " << getAttributeValue("StartDate").toDateTime().toString() << "\n";
	out << "Job End Date: " << getAttributeValue("EndDate").toDateTime().toString() << "\n\n";
	Task *tempTask;
	int allTime = 0;
	QStringList completedTasksOutput;
	QStringList otherTasksOutput;
	for (int i=0;i<taskCount();i++)
	{
		tempTask = getTask(i);
		QString name = tempTask->getAttributeValue("Name").toString();
		QString taskNum = QString::number(tempTask->getAttributeValue("TaskID").toInt()).prepend("   ");
		
		for (int j=taskNum.size(); j < 12; j++)
			taskNum.append(" ");
		for (int j=name.size(); j < 25; j++)
			name.append(" ");
		int timeSpent = totalTimes.value(tempTask->getAttributeValue("TaskID").toInt());
		allTime += timeSpent; // keep track of total time for percentages
		QString timeTotal = QString::number(timeSpent/3600) + "hr " + QString::number((timeSpent%3600)/60) + "min " + QString::number((timeSpent%3600)%60) + "sec";

		QDateTime completedDate = QDateTime::fromString(tempTask->getAttributeValue("Completed").toString(),Qt::ISODate);
		if (completedDate >= startDate && completedDate <= endDate)
			completedTasksOutput.append(QString(taskNum + name + timeTotal));
		else if (timeSpent > 0)
			otherTasksOutput.append(QString(taskNum + name + timeTotal));
	}
	completedTasksOutput.sort();
	otherTasksOutput.sort();
	
	out << "Tasks completed during selected time:\n\n";
	out << "\tTask ID     Task Name                 Time Spent            % of Total Time\n";
	out << "\t------------------------------------------------------------------------\n";
	QString tempOutput;
	for (int i = 0; i < completedTasksOutput.size(); i++)
	{
		tempOutput = completedTasksOutput.at(i);
		for (int j = tempOutput.size(); j < 65; j++)
			tempOutput.append(" ");
		QString percentage = QString::number(((double)totalTimes.value(tempOutput.left(10).simplified().toInt())/(double)allTime)*100.0,'f',2);
		out << "\t" << tempOutput << percentage << "\n";
	}
		
	out << "\n\nTasks worked on but not completed during selected time:\n\n";
	out << "\tTask ID     Task Name                 Time Spent            % of Total Time\n";
	out << "\t------------------------------------------------------------------------\n";
	for (int i = 0; i < otherTasksOutput.size(); i++)
	{
		tempOutput = otherTasksOutput.at(i);
		for (int j = tempOutput.size(); j < 65; j++)
			tempOutput.append(" ");
		QString percentage = QString::number((double)(totalTimes.value(tempOutput.left(10).simplified().toInt())/(double)allTime)*100.0,'f',2);
		out << "\t" << tempOutput << percentage << "\n";
	}
		
	reportFile.close();
	return true;
}
コード例 #16
0
ファイル: ai_measurement.cpp プロジェクト: 8l/rose
  //! Count floating point operations seen in a subtree
  void CountFPOperations(SgLocatedNode* input)
  {
    Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(input, V_SgBinaryOp);
    for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i != nodeList.end(); i++)
    {
      fp_operation_kind_enum op_kind = e_unknown; 
//      bool isFPType = false;
      // check operation type
      SgBinaryOp* bop= isSgBinaryOp(*i);
      switch (bop->variantT())
      {
	case V_SgAddOp:
	case V_SgPlusAssignOp:
	  op_kind = e_plus; 
	  break;
	case V_SgSubtractOp:
	case V_SgMinusAssignOp:  
	  op_kind = e_minus;
	  break;	
	case V_SgMultiplyOp:
	case V_SgMultAssignOp:  
	  op_kind = e_multiply;
	  break;	
	case V_SgDivideOp:
	case V_SgDivAssignOp:  
	  op_kind = e_divide;
	  break;	
	default:
	  break;  
      } //end switch

      // skip this expression if unknown operation kind 
      if (op_kind == e_unknown) continue; 

      // Check if the operation is on float point data type
      if (bop->get_type()->isFloatType())
      {
        // we assume the traverse is inside out, the inner loop will be processed first!
        // An operation is counted once when its innermost enclosing loop is processed. 
        // Using a map to avoid double counting an operation when it is enclosed in multiple loops
        if (!FPVisitMAP[bop]) 
        {
	  addFPCount (input, op_kind);
          FPVisitMAP[bop] = true;
        }
      }	
    }  // end for
    //Must update the total counter here
    FPCounters* fp_counters = getFPCounters (input); 
    fp_counters->updateTotal ();
    // write results to a report file
    if (running_mode == e_static_counting)
    {
      ofstream reportFile(report_filename.c_str(), ios::app);
      cout<<"Writing counter results to "<< report_filename <<endl;
      reportFile<< fp_counters->toString();
    }
    // debugging info
    if (debug)
      printFPCount (input);
  }
コード例 #17
0
ファイル: main.cpp プロジェクト: GuillaumeBelz/NazaraEngine
int main()
{
	std::cout << "Initialisation en cours...";

	// On va afficher le tout via un ostringstream, pour écrire dans la console et aussi dans un fichier
	std::ostringstream oss;

	oss << "--Processeur--" << std::endl;
	// Plutôt que d'initialiser le Renderer de Nazara, nous initialisons les deux classes utilisées ici
	// Elles sont compatibles avec NzInitialiser et seront donc libérées automatiquement
	// Cela permet d'avoir une initialisation plus rapide et un coût en mémoire moindre
	NzInitializer<NzHardwareInfo> hardwareInfo;
	if (hardwareInfo)
	{
		// On commence par les informations sur le processeur, Nazara en récupère trois caractéristiques:
		// 1) La "brand string", qui est une chaîne de 48 caractères identifiant le processeur
		// 2) Le concepteur du processeur, accessible via une énumération (GetProcessorVendor) ou une chaîne de caractère (GetProcessorVendorName)
		// 3) Le nombre de processeurs logique, alias bien souvent le nombre de coeurs (logiques), cette valeur est renvoyée par l'OS (Le SMT multiplie donc la valeur réelle)
		oss << "Identification: " << NzHardwareInfo::GetProcessorBrandString() << std::endl;
		oss << "Concepteur: " << NzHardwareInfo::GetProcessorVendorName() << std::endl;
		oss << "Nombre de coeurs logiques: " << NzHardwareInfo::GetProcessorCount() << std::endl;
		oss << std::endl;

		// Ensuite, Nazara récupère les capacités du processeur, dont des jeux d'extensions supplémentaires
		oss << "Rapport des capacites: " << std::endl;// Pas d'accent car écriture dans un fichier (et on ne va pas s'embêter avec ça)
		printCap(oss, "-64bits", NzHardwareInfo::HasCapability(nzProcessorCap_x64));
		printCap(oss, "-AVX", NzHardwareInfo::HasCapability(nzProcessorCap_AVX));
		printCap(oss, "-FMA3", NzHardwareInfo::HasCapability(nzProcessorCap_FMA3));
		printCap(oss, "-FMA4", NzHardwareInfo::HasCapability(nzProcessorCap_FMA4));
		printCap(oss, "-MMX", NzHardwareInfo::HasCapability(nzProcessorCap_MMX));
		printCap(oss, "-SSE", NzHardwareInfo::HasCapability(nzProcessorCap_SSE));
		printCap(oss, "-SSE2", NzHardwareInfo::HasCapability(nzProcessorCap_SSE2));
		printCap(oss, "-SSE3", NzHardwareInfo::HasCapability(nzProcessorCap_SSE3));
		printCap(oss, "-SSSE3", NzHardwareInfo::HasCapability(nzProcessorCap_SSSE3));
		printCap(oss, "-SSE4.1", NzHardwareInfo::HasCapability(nzProcessorCap_SSE41));
		printCap(oss, "-SSE4.2", NzHardwareInfo::HasCapability(nzProcessorCap_SSE42));
		printCap(oss, "-SSE4.a", NzHardwareInfo::HasCapability(nzProcessorCap_SSE4a));
	}
	else
		oss << "Impossible de retrouver les informations du processeur" << std::endl;

	oss << std::endl << "--Carte graphique--" << std::endl;
	// La classe NzOpenGL nous donne accès à des informations sur la carte graphique
	// Cependant celle-ci n'est accessible que si le projet est compilé avec NAZARA_RENDERER_OPENGL
	// et que les répertoires d'inclusions donnent accès aux includes d'OpenGL (Cette démo utilisent ceux de Nazara)
	NzInitializer<NzOpenGL> openGL;
	if (openGL)
	{
		// Nous récupérons ensuite la version d'OpenGL sous forme d'entier (ex: OpenGL 3.3 donnera 330)
		unsigned int openglVersion = NzOpenGL::GetVersion();

		// NzOpenGL nous donne accès à trois informations principales:
		// 1) La chaîne d'identification du driver ("Renderer name")
		// 2) La chaîne d'identification du concepteur ("Vendor name")
		// 3) La version d'OpenGL
		oss << "Identification: " << NzOpenGL::GetRendererName() << std::endl;
		oss << "Concepteur: " << NzOpenGL::GetVendorName() << std::endl;
		oss << "Version d'OpenGL: " << openglVersion/100 << '.' << openglVersion%100 << std::endl;
		oss << std::endl;

		// Ainsi qu'un report des capacités de la carte graphique (avec le driver actuel)
		oss << "Rapport des capacites: " << std::endl; // Pas d'accent car écriture dans un fichier (et on ne va pas s'embêter avec ça)
		printCap(oss, "-Calculs 64bits", NzOpenGL::IsSupported(nzOpenGLExtension_FP64));
		printCap(oss, "-Compression de textures (s3tc)", NzOpenGL::IsSupported(nzOpenGLExtension_TextureCompression_s3tc));
		printCap(oss, "-Filtrage anisotrope", NzOpenGL::IsSupported(nzOpenGLExtension_AnisotropicFilter));
		printCap(oss, "-Framebuffer Object", NzOpenGL::IsSupported(nzOpenGLExtension_FrameBufferObject));
		printCap(oss, "-Mode debug", NzOpenGL::IsSupported(nzOpenGLExtension_DebugOutput));
		printCap(oss, "-Pixelbuffer Object", NzOpenGL::IsSupported(nzOpenGLExtension_PixelBufferObject));
		printCap(oss, "-Samplers Object", NzOpenGL::IsSupported(nzOpenGLExtension_SamplerObjects));
		printCap(oss, "-Separate shader objects", NzOpenGL::IsSupported(nzOpenGLExtension_SeparateShaderObjects));
		printCap(oss, "-Texture array", NzOpenGL::IsSupported(nzOpenGLExtension_TextureArray));
		printCap(oss, "-Texture storage", NzOpenGL::IsSupported(nzOpenGLExtension_TextureStorage));
		printCap(oss, "-Vertex array objects", NzOpenGL::IsSupported(nzOpenGLExtension_VertexArrayObjects));
	}
	else
		oss << "Impossible de retrouver les informations de la carte graphique" << std::endl;

	std::cout << "\r                          "; // On efface le message d'initialisation
	std::cout << '\r'; // Et on place déjà le caractère pour revenir sur la même ligne (Pour ne pas avoir un saut inutile)

	std::cout << oss.str() << std::endl;

	NzFile reportFile("RapportHardwareInfo.txt");
	if (reportFile.Open(nzOpenMode_Text | nzOpenMode_Truncate | nzOpenMode_WriteOnly))
	{
		reportFile.Write(oss.str()); // Conversion implicite en NzString
		reportFile.Close();

		char accentAigu = static_cast<char>(130); // C'est crade, mais ça marche chez 95% des Windowsiens
		std::cout << "Un fichier (RapportHardwareInfo.txt) contenant le rapport a " << accentAigu << 't' << accentAigu << " cr" << accentAigu << accentAigu << std::endl;
	}
	else
		std::cout << "Impossible de sauvegarder le rapport" << std::endl;

	std::getchar();

	return 0;
}
コード例 #18
0
void FuzzyDetector::SaveToXml(QString settingsFileName)
{

    QFile reportFile(settingsFileName);

    if( !reportFile.open(QFile::WriteOnly | QFile::Text) ) {
        qDebug() << "Could not open " << settingsFileName << " to write settings";
        return;
    }

    QXmlStreamWriter xml;

    xml.setDevice(&reportFile);
    xml.setAutoFormatting(true);

    xml.writeStartDocument();

    xml.writeStartElement("FuzzyDetectorSettings");

    xml.writeStartElement("FP_OnAir");
    for(int i=0;i<fp_onAir.count();i++) {
        xml.writeStartElement("relation");

        xml.writeAttribute("inVal", QString::number(fp_onAir.at(i).inVal));
        xml.writeAttribute("outVal", QString::number(fp_onAir.at(i).outVal));

        xml.writeEndElement();
    }
    xml.writeEndElement();

    xml.writeStartElement("FP_OnGrnd");
    for(int i=0;i<fp_onGrnd.count();i++) {
        xml.writeStartElement("relation");

        xml.writeAttribute("inVal", QString::number(fp_onGrnd.at(i).inVal));
        xml.writeAttribute("outVal", QString::number(fp_onGrnd.at(i).outVal));

        xml.writeEndElement();
    }
    xml.writeEndElement();

    xml.writeStartElement("PA_OnAir");
    for(int i=0;i<pa_onAir.count();i++) {
        xml.writeStartElement("relation");

        xml.writeAttribute("inVal", QString::number(pa_onAir.at(i).inVal));
        xml.writeAttribute("outVal", QString::number(pa_onAir.at(i).outVal));

        xml.writeEndElement();
    }
    xml.writeEndElement();

    xml.writeStartElement("PA_OnGrnd");
    for(int i=0;i<pa_onGrnd.count();i++) {
        xml.writeStartElement("relation");

        xml.writeAttribute("inVal", QString::number(pa_onGrnd.at(i).inVal));
        xml.writeAttribute("outVal", QString::number(pa_onGrnd.at(i).outVal));

        xml.writeEndElement();
    }
    xml.writeEndElement();

    xml.writeStartElement("IA_OnAir");
    for(int i=0;i<ia_onAir.count();i++) {
        xml.writeStartElement("relation");

        xml.writeAttribute("inVal", QString::number(ia_onAir.at(i).inVal));
        xml.writeAttribute("outVal", QString::number(ia_onAir.at(i).outVal));

        xml.writeEndElement();
    }
    xml.writeEndElement();

    xml.writeStartElement("IA_OnGrnd");
    for(int i=0;i<ia_onGrnd.count();i++) {
        xml.writeStartElement("relation");

        xml.writeAttribute("inVal", QString::number(ia_onGrnd.at(i).inVal));
        xml.writeAttribute("outVal", QString::number(ia_onGrnd.at(i).outVal));

        xml.writeEndElement();
    }
    xml.writeEndElement();

    xml.writeEndElement();//FuzzyDetectorSettings

    xml.writeEndDocument();

    reportFile.close();
}