#include #include "elementSnapshot.h" #include "mixedTools.h" elementSnapshot::elementSnapshot(int num) : abstractElement(), incr_(num) { setDefaultValues(); setDefaults(); elementName_ = nomdElements("snapshot"); nbParam_ = elementName_.getElementNbParameters(); parametersString_ = new string[nbParam_+1]; } void elementSnapshot::setDefaultValues() { defaultSpecificName_ = "snapshot"; } void elementSnapshot::setDefaults() { specificName_ = defaultSpecificName_; // if(incr_ < 10) { // snapshotFile_= string("cliche")+string(".00")+mixedTools::intToString(incr_); // } else if(incr_ >= 10 && incr_ < 100) { // snapshotFile_= string("cliche")+string(".0")+mixedTools::intToString(incr_); // } else { // snapshotFile_= string("cliche")+string(".")+mixedTools::intToString(incr_); // } } string* elementSnapshot::getParametersString() const { int compteur = -1; parametersString_[++compteur] = mixedTools::intToString(nbParam_); parametersString_[++compteur] = specificName_; parametersString_[++compteur] = programFile_; parametersString_[++compteur] = inputBeamFile_; parametersString_[++compteur] = outputBeamFile_; if ( compteur != nbParam_ ) { cerr << "ERROR::elementSnapshot::getParametersString() : " << nbParam_ << endl; return NULL; } return parametersString_; } void elementSnapshot::setParametersString(string* param) { if ( param == NULL ) { cerr << " elementSnaphot::setParametersString parameters empty parameter set"; return; } int compteur = -1; int nbparam = atoi(param[++compteur].c_str()); if ( nbparam != nbParam_ ) { cerr << " elementSnaphot:: setParametersString parameters do not match for a SNAPSHOT"; return; } specificName_ = param[++compteur]; programFile_ = param[++compteur]; inputBeamFile_ = param[++compteur]; outputBeamFile_ = param[++compteur]; } // string elementSnapshot::parmelaOutputFlow() const // { // // ostringstream sortie; // // return sortie.str(); // return string(""); // } // string elementSnapshot::transportOutputFlow() const // { // return string(""); // } string elementSnapshot::FileOutputFlow() const { ostringstream sortie; sortie << elementName_.getGenericLabel() << endl; sortie << specificName_ << endl; sortie << programFile_ << endl; sortie << inputBeamFile_ << endl; sortie << outputBeamFile_ << endl; return sortie.str(); } vector< pair > > elementSnapshot::parametersToSoftware () const { vector< pair > > sortie; sortie.push_back( pair >("labelsGenericSpecific", vector() ) ); sortie.back().second.push_back(elementName_.getGenericLabel()); sortie.back().second.push_back(specificName_); sortie.push_back( pair >("nameOfFiles", vector() ) ); sortie.back().second.push_back(programFile_); sortie.back().second.push_back(inputBeamFile_); sortie.back().second.push_back(outputBeamFile_); return sortie; } void elementSnapshot::FileInput(ifstream& ifs) { ifs >> specificName_; ifs >> programFile_; ifs >> inputBeamFile_; ifs >> outputBeamFile_;; } string elementSnapshot::print() { string txt = ""; txt += specificName_; txt += "\nname of file for user's program : "; txt += programFile_; txt += "\nname of input beam file for user's program : "; txt += inputBeamFile_; txt += "\nname of output beam file for user's program : "; txt += outputBeamFile_; return txt; } void elementSnapshot::InputRep(UAPNode* root) { UAPNode* node= root->addChild("snapshot"); node->addAttribute("name",specificName_); UAPNode* fichiers = node->addChild("names_of_files"); fichiers->addAttribute("program",programFile_); fichiers->addAttribute("inputf",inputBeamFile_); fichiers->addAttribute("outputf",outputBeamFile_); }