#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]; // registerAcceptableSoftware(nomDeLogiciel::transport, TBoolIgnore); // registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolIgnore); // registerAcceptableSoftware(nomDeLogiciel::generator, TBoolIgnore); // registerAcceptableSoftware(nomDeLogiciel::useraction, // TBoolOk); // registerAcceptableSoftware(nomDeLogiciel::test, TBoolIgnore); } 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] = snapshotFile_; 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 DRIFT"; return; } specificName_ = 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 << snapshotFile_ << 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 >("snapshotFile", vector() ) ); sortie.back().second.push_back(snapshotFile_); return sortie; } void elementSnapshot::FileInput(ifstream& ifs) { ifs >> specificName_; ifs >> snapshotFile_; } string elementSnapshot::print() { string txt = ""; txt += specificName_; txt += "\nname of file for snapshot : "; txt += snapshotFile_; return txt; }