#include "abstractSoftware.h" #include "dataManager.h" abstractSoftware::abstractSoftware() { globParamPtr_ = NULL; dataManager_ = NULL; nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); } abstractSoftware::abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt) { inputFileName_ = inputFileName; globParamPtr_ = globals; dataManager_ = dt; numeroDeb_ = 0; numeroFin_ = 0; nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); } bool abstractSoftware::initComputationLimits(unsigned int numeroDeb,unsigned int numeroFin) { numeroDeb_ = numeroDeb; numeroFin_ = numeroFin; return ComputationLimitsOk(); } bool abstractSoftware::ComputationLimitsOk() const { if ( numeroDeb_ < 1 || numeroFin_ < 1 || numeroDeb_ > dataManager_->getBeamLineSize() || numeroFin_ > dataManager_->getBeamLineSize() ) { dataManager_->consoleMessage(" abstractSoftware::initComputationLimit : numero of element out of limits in software " + getName() ); return false; } else { return true; } } void abstractSoftware::registerElement(nomdElements::typedElement nomdel,trivaluedBool b) { if (b == TBoolIgnore) { ignoredElements_.push_back(nomdel); } else if (b == TBoolOk) { acceptedElements_.push_back(nomdel); } } trivaluedBool abstractSoftware::doAcceptElement(nomdElements::typedElement typdel) { if (acceptedElements_.size() == 0) { return TBoolError; } if ( std::find(acceptedElements_.begin(), acceptedElements_.end(), typdel) != acceptedElements_.end()) { return TBoolOk; } if (ignoredElements_.size() == 0) { return TBoolError; } if ( std::find(ignoredElements_.begin(), ignoredElements_.end(), typdel) != ignoredElements_.end()) { return TBoolIgnore; } return TBoolOk; } bool abstractSoftware::launchJob(string commandLine, string& resul) { bool ExecuteStatus = true; FILE* pp = popen(commandLine.c_str(), "r"); ostringstream sortie; if (pp == NULL) { sortie << " launching failed : " << commandLine << endl; ExecuteStatus = false; } else { cout << " executing command : " << commandLine << endl; // on copie la sortie dans le fichier assigne char buf[132]; while (fgets(buf, sizeof buf, pp)) { sortie << buf; } pclose(pp); } resul = sortie.str(); return ExecuteStatus; }